JNR
laCollectable.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 #ifndef M_COLLECTABLE_H
30 #define M_COLLECTABLE_H
31 
33 
34 
40 
42 
44  public laObject
45 {
46  //Can be constructed from class name
47  CLASS_NAME(laCollectable);
48 
49 protected:
50 
51  // HP/XP value
52  //
53  unsigned _nHP;
54  unsigned _nXP;
55 
56  // Item/Weapon value
57  //
58  // TODO: Other item types, e.g. keys, access cards
59  // should be instantiated as rpgItem or derrived form it,
60  // and added here;
61  //
62  M_BOOL _bWeapon;
63  //M_BOOL _bItem;
64  rpgItem *pItem;
65 
66  // Potion value
67  //
68  rpgPotion *_pPotion;
69  M_BOOL _bOwnPotionObject; // certain potions (in attacks) maintain the memory themselves
70 
71  int _nPotionID; // ID of the potion if active, otherwise -1
72  laTimeTrig _ttDuration; // Duration timer
73 
74  // State
75  //
76  double _dPlayerDistance;
77  M_BOOL _bTaken;
78  double _dRotAngle;
79  unsigned _nWaveIndex;
80 
81  //Fx
82  fxParticleSystem _fxCollect;
83 
84  // Internal methods
85  //
86  void _load_collect_fx();
87  void _collect_mechanic();
88  void _potion_mechanic();
89 
90  virtual M_BOOL _collect_actions(); // Actions to be performed when the item is collected
91  M_BOOL _reset_potion_icon();
92  void _disable_potion_icon();
93 
94 public:
95  laCollectable(void);
96  ~laCollectable(void);
97 
98  //Collect the item
99  M_BOOL forceCollect() { return _collect_actions(); }
100  void resetPotion();
101 
102  //Dynamic create
103  virtual void create(laPoint3 pos, rpgPotion* pPot = NULL);
104 
105  //Respawn
106  virtual void respawn();
107 
108  //Draw
109  virtual void drawGeometry(laRenderer *r, laPoint3 ptBasePos);
110  virtual void _drawFx_positioned(laRenderer *r);
111 
112  //Animate
113  virtual void animate(laTimer &t);
114 
115  //This method is part of the laLoadableObj interface
116  virtual void load(class laFileParser *fp);
117 };
119 #endif
Potion RPG Properties.
Definition: rpgPotion.h:44
Time-triggered events.
Definition: laTimeTrig.h:41
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98
Base Class for Level Objects.
Definition: laObject.h:43
File Parser.
Definition: laFileParser.h:41
Collectable Level Object.
Definition: laCollectable.h:43