Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
action.hpp
1 //////////////////////////////
2 //
3 // File: lxs/game/action.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Feb 28 2013
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __LXS_ACTN__
15 #define __LXS_ACTN__
16 namespace LxS
17 {
18  namespace Game
19  {
20  class GameObject;
21 
22  //! Actions are enqueued by UI or AI agents and are processed by game objects in appropriate order
23  class Action
24  {
25  public:
26  enum
27  {
28  MOVE, //!< exploration mode only = params: coordinates
29  ATTACK,//!< battle mode only = params: game object (character to attack)
30  POTION,//!< each mode = params: game object (item to consume)
31  FOLLOW,//!< Exploration mode, for AI only = params: game object to follow
32  ESCAPE,//!< leave combat mode = no params (or maybe a target set of coordinates?)
33  SURPRISED//!<In battle mode
34  };
35  private:
36  int action_type;
37  union
38  {
39  //! Target as a set of coordinates
40  struct {
41  float x, y, z;
42  }target_c;
43  //! target as an object
45  };
46  public:
47  //! constructor. correct type of action must be given
48  Action(int atype) {action_type=atype;}
49  //! return type of action
50  int GetType() { return action_type;}
51  //! stringified type of action (for UI)
52  const char * GetTypeAsString();
53  //! if target of action is an object
54  void SetTarget(GameObject * go)
55  {
56  target_p = go;
57  }
58  //! if target is set of coordinates
59  void SetTarget(float x, float y, float z)
60  {
61  target_c.x=x;
62  target_c.y=y;
63  target_c.z=z;
64  }
65  //! return total time for execution of action in battle mode
66  float GetActionTime() {return 1.5;}
67  //! get target coordinate X
68  //! (works only if target was given
69  //! as a set of coordinates)
70  float GetTX() { return target_c.x;}
71  //! get target coordinate Y
72  //! (works only if target was given
73  //! as a set of coordinates)
74  float GetTY() { return target_c.y;}
75  //! get target coordinate Z
76  //! (works only if target was given
77  //! as a set of coordinates)
78  float GetTZ() { return target_c.z;}
79  //! get target game object
80  //! (works only if target was given
81  //! as a game object)
83  };
84  }
85 }
86 
87 #endif