Pac-Man Evolution
Loading...
Searching...
No Matches
ObjectsGhost.h
1/*----------------------------------------------------------------------
2Pac-Man Evolution - Roberto Prieto
3Copyright (C) 2018-2024 MegaStorm Systems
4contact@megastormsystems.com - http://www.megastormsystems.com
5
6This software is provided 'as-is', without any express or implied
7warranty. In no event will the authors be held liable for any damages
8arising from the use of this software.
9
10Permission is granted to anyone to use this software for any purpose,
11including commercial applications, and to alter it and redistribute it
12freely, subject to the following restrictions:
13
141. The origin of this software must not be misrepresented; you must not
15claim that you wrote the original software. If you use this software
16in a product, an acknowledgment in the product documentation would be
17appreciated but is not required.
182. Altered source versions must be plainly marked as such, and must not be
19misrepresented as being the original software.
203. This notice may not be removed or altered from any source distribution.
21
22------------------------------------------------------------------------
23
24Ghost class
25
26------------------------------------------------------------------------ */
27
28#ifndef OBJECTSGHOSTPME_H
29#define OBJECTSGHOSTPME_H
30
31// Includes and forward definitions
32#include "Objects.h"
33
34// Init State
35class GhostStateInit : public State
36{
37public:
38 explicit GhostStateInit(const string&);
39 void enter(Actor*);
40 void execute(Actor*);
41private:
42 Uint32 iTime;
43};
44
45// Evading State
46class GhostStateEvading : public State
47{
48public:
49 explicit GhostStateEvading(const string&);
50 void enter(Actor*);
51 void execute(Actor*);
52 void exit(Actor*);
53};
54
55// Chasing State
56class GhostStateChasing : public State
57{
58public:
59 explicit GhostStateChasing(const string&);
60 void enter(Actor*);
61 void execute(Actor*);
62 void exit(Actor*);
63private:
64 Sint32 iTX, iTY, iITX, iITY;
65 bool bGetNewTarget;
66};
67
68// Scattering State
69class GhostStateScattering : public State
70{
71public:
72 explicit GhostStateScattering(const string&);
73 void enter(Actor*);
74 void execute(Actor*);
75 void exit(Actor*);
76};
77
78// Death State
79class GhostStateDeath : public State
80{
81public:
82 explicit GhostStateDeath(const string&);
83 void enter(Actor*);
84 void execute(Actor*);
85 void exit(Actor*);
86};
87
88// Ghost class
89class Ghost : public Actor
90{
91 // State classes can access to all attributes
92 friend class GhostStateInit;
93 friend class GhostStateEvading;
94 friend class GhostStateChasing;
95 friend class GhostStateScattering;
96 friend class GhostStateDeath;
97
98public:
99 Ghost(Sint32 iObjID, Sint32 iMX, Sint32 iMY, GameField* GF);
100 ~Ghost();
101 Sint32 execute();
102 Sint32 debug(Sint32);
103
104 // Messages that modified our state
105 Sint32 msgGoInit();
106 Sint32 msgPelletPowerEaten(Sint32, Sint32);
107 Sint32 msgGhostCollision();
108
109 // Get Scattering predefined target
110 Sint32 getScatteringTarget(Sint32&, Sint32&);
111
112protected:
113 // Protected methods
114 Sint32 applyMovementRules(Sint32, Sint32);
115
116 // Attributes
117 Sint32 iGoingOutTrigger;
118 MazePoint pointEvadingTarget;
119 MazePoint pointScatteringTarget;
120
121 // Ghost states
122 GhostStateInit* pStateInit;
123 GhostStateEvading* pStateEvading;
124 GhostStateChasing* pStateChasing;
125 GhostStateScattering* pStateScattering;
126 GhostStateDeath* pStateDeath;
127};
128
129#endif