Gegenstand.cpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. #include "Gegenstand.h"
  2. Resource *zResourceOfItem( GegenstandTyp typ, ResourceRegistry *zResources )
  3. {
  4. switch( typ )
  5. {
  6. case PFEIL:
  7. return zResources->zResource( R_PFEIL, 0 );
  8. case LEBEN:
  9. return zResources->zResource( R_LEBEN, 0 );
  10. case SCHILD:
  11. return zResources->zResource( R_SCHILD, 0 );
  12. case SCHUH:
  13. return zResources->zResource( R_SCHUH, 0 );
  14. case GEIST:
  15. return zResources->zResource( R_GEIST, 0 );
  16. case KUGEL:
  17. return zResources->zResource( R_KUGEL, 0 );
  18. case ROLLE:
  19. return zResources->zResource( R_ROLLE, 0 );
  20. case STURM:
  21. return zResources->zResource( R_STURM, 0 );
  22. case DRACHENAUGE:
  23. return zResources->zResource( R_DRACHENAUGE, 0 );
  24. case FEUERBALL:
  25. return zResources->zResource( R_FEUERBALL, 0 );
  26. case ENTERHAKEN:
  27. return zResources->zResource( R_ENTERHAKEN_ITEM, 0 );
  28. case MINE:
  29. return zResources->zResource( R_MINE, 0 );
  30. case RWEISHEIT:
  31. return zResources->zResource( R_RWEISHEIT, 0 );
  32. case RSTRENGTH:
  33. return zResources->zResource( R_RSTRENGTH, 0 );
  34. case RBOSHEIT:
  35. return zResources->zResource( R_RBOSHEIT, 0 );
  36. case RLEBEN:
  37. return zResources->zResource( R_RLEBEN, 0 );
  38. case RTEMPO:
  39. return zResources->zResource( R_RTEMPO, 0 );
  40. default:
  41. break;
  42. }
  43. return 0;
  44. }
  45. bool consumable( GegenstandTyp typ )
  46. {
  47. switch( typ )
  48. {
  49. case PFEIL:
  50. return 1;
  51. case LEBEN:
  52. return 1;
  53. case SCHILD:
  54. return 0;
  55. case SCHUH:
  56. return 0;
  57. case GEIST:
  58. return 0;
  59. case KUGEL:
  60. return 1;
  61. case ROLLE:
  62. return 0;
  63. case STURM:
  64. return 0;
  65. case DRACHENAUGE:
  66. return 1;
  67. case FEUERBALL:
  68. return 1;
  69. case ENTERHAKEN:
  70. return 0;
  71. case MINE:
  72. return 1;
  73. case RWEISHEIT:
  74. case RSTRENGTH:
  75. case RBOSHEIT:
  76. case RLEBEN:
  77. case RTEMPO:
  78. default:
  79. return 0;
  80. }
  81. }
  82. float abklingzeit( GegenstandTyp typ )
  83. {
  84. switch( typ )
  85. {
  86. case PFEIL:
  87. return 5;
  88. case LEBEN:
  89. return 5;
  90. case SCHILD:
  91. return 100;
  92. case SCHUH:
  93. return 100;
  94. case GEIST:
  95. return 100;
  96. case KUGEL:
  97. return 5;
  98. case ROLLE:
  99. return 30;
  100. case STURM:
  101. return 30;
  102. case DRACHENAUGE:
  103. return 5;
  104. case FEUERBALL:
  105. return 5;
  106. case ENTERHAKEN:
  107. return 60;
  108. case MINE:
  109. return 5;
  110. case RWEISHEIT:
  111. case RSTRENGTH:
  112. case RBOSHEIT:
  113. case RLEBEN:
  114. case RTEMPO:
  115. default:
  116. return 0;
  117. }
  118. }
  119. bool storable( GegenstandTyp typ )
  120. {
  121. return !(typ == RWEISHEIT || typ == RSTRENGTH || typ == RBOSHEIT || typ == RLEBEN || typ == RTEMPO);
  122. }
  123. bool brauchtRichtung( GegenstandTyp typ )
  124. {
  125. return typ == PFEIL || typ == KUGEL || typ == DRACHENAUGE || typ == FEUERBALL || typ == ENTERHAKEN || typ == ROLLE || typ == STURM;
  126. }
  127. GegenstandTypVar::GegenstandTypVar( GegenstandTyp value )
  128. : Variable( GEGENSTAND_TYP )
  129. {
  130. this->value = value;
  131. }
  132. void GegenstandTypVar::setValue( GegenstandTyp value )
  133. {
  134. this->value = value;
  135. }
  136. GegenstandTyp GegenstandTypVar::getValue() const
  137. {
  138. return value;
  139. }
  140. Gegenstand::Gegenstand( ResourceRegistry *zResources, int id, GegenstandTyp typ, int x, int y, int w, int h )
  141. : GameObject( GEGENSTAND, x, y, w, h )
  142. {
  143. this->id = id;
  144. this->typ = typ;
  145. texturScale = 1;
  146. switch( typ )
  147. {
  148. case PFEIL:
  149. this->textur = zResources->zResource( R_PFEIL, 0 )->getImages()->getThis();
  150. break;
  151. case LEBEN:
  152. this->textur = zResources->zResource( R_LEBEN, 0 )->getImages()->getThis();
  153. break;
  154. case SCHILD:
  155. this->textur = zResources->zResource( R_SCHILD, 0 )->getImages()->getThis();
  156. break;
  157. case SCHUH:
  158. this->textur = zResources->zResource( R_SCHUH, 0 )->getImages()->getThis();
  159. break;
  160. case GEIST:
  161. this->textur = zResources->zResource( R_GEIST, 0 )->getImages()->getThis();
  162. break;
  163. case KUGEL:
  164. this->textur = zResources->zResource( R_KUGEL, 0 )->getImages()->getThis();
  165. break;
  166. case ROLLE:
  167. this->textur = zResources->zResource( R_ROLLE, 0 )->getImages()->getThis();
  168. break;
  169. case STURM:
  170. this->textur = zResources->zResource( R_STURM, 0 )->getImages()->getThis();
  171. break;
  172. case DRACHENAUGE:
  173. this->textur = zResources->zResource( R_DRACHENAUGE, 0 )->getImages()->getThis();
  174. break;
  175. case FEUERBALL:
  176. this->textur = zResources->zResource( R_FEUERBALL, 0 )->getImages()->getThis();
  177. break;
  178. case ENTERHAKEN:
  179. this->textur = zResources->zResource( R_ENTERHAKEN_ITEM, 0 )->getImages()->getThis();
  180. break;
  181. case MINE:
  182. this->textur = zResources->zResource( R_MINE, 0 )->getImages()->getThis();
  183. break;
  184. case RWEISHEIT:
  185. this->textur = zResources->zResource( R_RWEISHEIT, 0 )->getImages()->getThis();
  186. break;
  187. case RSTRENGTH:
  188. this->textur = zResources->zResource( R_RSTRENGTH, 0 )->getImages()->getThis();
  189. break;
  190. case RBOSHEIT:
  191. this->textur = zResources->zResource( R_RBOSHEIT, 0 )->getImages()->getThis();
  192. break;
  193. case RLEBEN:
  194. this->textur = zResources->zResource( R_RLEBEN, 0 )->getImages()->getThis();
  195. break;
  196. case RTEMPO:
  197. this->textur = zResources->zResource( R_RTEMPO, 0 )->getImages()->getThis();
  198. break;
  199. default:
  200. break;
  201. }
  202. }
  203. int Gegenstand::getId() const
  204. {
  205. return id;
  206. }
  207. GegenstandTyp Gegenstand::getTyp() const
  208. {
  209. return typ;
  210. }