Gegenstand.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. timeLeft = 120;
  144. this->id = id;
  145. this->typ = typ;
  146. texturScale = 1;
  147. switch( typ )
  148. {
  149. case PFEIL:
  150. this->textur = zResources->zResource( R_PFEIL, 0 )->getImages()->getThis();
  151. break;
  152. case LEBEN:
  153. this->textur = zResources->zResource( R_LEBEN, 0 )->getImages()->getThis();
  154. break;
  155. case SCHILD:
  156. this->textur = zResources->zResource( R_SCHILD, 0 )->getImages()->getThis();
  157. break;
  158. case SCHUH:
  159. this->textur = zResources->zResource( R_SCHUH, 0 )->getImages()->getThis();
  160. break;
  161. case GEIST:
  162. this->textur = zResources->zResource( R_GEIST, 0 )->getImages()->getThis();
  163. break;
  164. case KUGEL:
  165. this->textur = zResources->zResource( R_KUGEL, 0 )->getImages()->getThis();
  166. break;
  167. case ROLLE:
  168. this->textur = zResources->zResource( R_ROLLE, 0 )->getImages()->getThis();
  169. break;
  170. case STURM:
  171. this->textur = zResources->zResource( R_STURM, 0 )->getImages()->getThis();
  172. break;
  173. case DRACHENAUGE:
  174. this->textur = zResources->zResource( R_DRACHENAUGE, 0 )->getImages()->getThis();
  175. break;
  176. case FEUERBALL:
  177. this->textur = zResources->zResource( R_FEUERBALL, 0 )->getImages()->getThis();
  178. break;
  179. case ENTERHAKEN:
  180. this->textur = zResources->zResource( R_ENTERHAKEN_ITEM, 0 )->getImages()->getThis();
  181. break;
  182. case MINE:
  183. this->textur = zResources->zResource( R_MINE, 0 )->getImages()->getThis();
  184. break;
  185. case RWEISHEIT:
  186. this->textur = zResources->zResource( R_RWEISHEIT, 0 )->getImages()->getThis();
  187. break;
  188. case RSTRENGTH:
  189. this->textur = zResources->zResource( R_RSTRENGTH, 0 )->getImages()->getThis();
  190. break;
  191. case RBOSHEIT:
  192. this->textur = zResources->zResource( R_RBOSHEIT, 0 )->getImages()->getThis();
  193. break;
  194. case RLEBEN:
  195. this->textur = zResources->zResource( R_RLEBEN, 0 )->getImages()->getThis();
  196. break;
  197. case RTEMPO:
  198. this->textur = zResources->zResource( R_RTEMPO, 0 )->getImages()->getThis();
  199. break;
  200. default:
  201. break;
  202. }
  203. }
  204. int Gegenstand::getId() const
  205. {
  206. return id;
  207. }
  208. bool Gegenstand::tick( double zeit )
  209. {
  210. timeLeft -= zeit;
  211. return timeLeft <= 0;
  212. }
  213. GegenstandTyp Gegenstand::getTyp() const
  214. {
  215. return typ;
  216. }