Gegenstand.cpp 4.2 KB

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