00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ArmageTron_WinZone_H
00029 #define ArmageTron_WinZone_H
00030
00031 #include "eNetGameObject.h"
00032
00033 #include <vector>
00034
00035 #include "gCycle.h"
00036 #include "rColor.h"
00037 #include "tFunction.h"
00038
00039
00040 extern REAL sg_expansionSpeed;
00041 extern REAL sg_initialSize;
00042
00043
00044 extern REAL sg_conquestDecayRate;
00045 extern REAL sg_conquestRate;
00046 extern REAL sg_defendRate;
00047
00048 class eTeam;
00049
00051 class gZone: public eNetGameObject
00052 {
00053 public:
00054 gZone(eGrid *grid, const eCoord &pos);
00055 gZone(nMessage &m);
00056 ~gZone();
00057
00058 void SetReferenceTime();
00059
00060 gZone & SetPosition ( eCoord const & position );
00061 eCoord GetPosition ( void ) const;
00062 gZone const & GetPosition ( eCoord & position ) const;
00063 gZone & SetVelocity ( eCoord const & velocity );
00064 eCoord GetVelocity ( void ) const;
00065 gZone const & GetVelocity ( eCoord & velocity ) const;
00066 gZone & SetRadius ( REAL radius );
00067 REAL GetRadius ( void ) const;
00068 gZone const & GetRadius ( REAL & radius ) const;
00069 gZone & SetExpansionSpeed ( REAL expansionSpeed );
00070 REAL GetExpansionSpeed ( void ) const;
00071 gZone const & GetExpansionSpeed ( REAL & expansionSpeed ) const;
00072 gZone & SetRotationSpeed ( REAL rotationSpeed );
00073 REAL GetRotationSpeed ( void ) const;
00074 tCoord const & GetRotation ( void ) const;
00075 gZone const & GetRotationSpeed ( REAL & rotationSpeed ) const;
00076 gZone & SetRotationAcceleration( REAL rotationAcceleration );
00077 REAL GetRotationAcceleration( void ) const;
00078 gZone const & GetRotationAcceleration( REAL & rotationAcceleration ) const;
00079 rColor const & GetColor( void ) const;
00080 protected:
00081 rColor color_;
00082 REAL createTime_;
00083
00084 REAL referenceTime_;
00085 tFunction posx_;
00086 tFunction posy_;
00087 tFunction radius_;
00088 tFunction rotationSpeed_;
00089 eCoord rotation_;
00090
00091 virtual bool Timestep(REAL currentTime);
00092 virtual void OnVanish();
00093
00094 private:
00095 virtual void WriteCreate(nMessage &m);
00096 virtual void WriteSync(nMessage &m);
00097 virtual void ReadSync(nMessage &m);
00098
00099 virtual void InteractWith( eGameObject *target,REAL time,int recursion=1 );
00100
00101 virtual void OnEnter( gCycle *target, REAL time );
00102
00103 virtual nDescriptor& CreatorDescriptor() const;
00104
00105 REAL Radius() const;
00106
00107 virtual void Render(const eCamera *cam);
00108 virtual void Render2D(tCoord scale) const;
00109
00111 virtual bool RendersAlpha() const;
00112
00113 inline REAL EvaluateFunctionNow( tFunction const & f ) const;
00114 inline void SetFunctionNow( tFunction & f, REAL value ) const;
00115 };
00116
00117
00118
00120 class gWinZoneHack: public gZone
00121 {
00122 public:
00123 gWinZoneHack(eGrid *grid, const eCoord &pos);
00124 gWinZoneHack(nMessage &m);
00125 ~gWinZoneHack();
00126
00127 protected:
00128 private:
00129 virtual void OnEnter( gCycle *target, REAL time );
00130 };
00131
00133 class gDeathZoneHack: public gZone
00134 {
00135 public:
00136 gDeathZoneHack(eGrid *grid, const eCoord &pos );
00137 gDeathZoneHack(nMessage &m);
00138 ~gDeathZoneHack();
00139
00140 protected:
00141 private:
00142 virtual void OnEnter( gCycle *target, REAL time );
00143 };
00144
00146 class gBaseZoneHack: public gZone
00147 {
00148 public:
00149 gBaseZoneHack(eGrid *grid, const eCoord &pos );
00150 gBaseZoneHack(nMessage &m);
00151 ~gBaseZoneHack();
00152
00153 private:
00154 virtual bool Timestep(REAL currentTime);
00155
00156 virtual void OnEnter( gCycle *target, REAL time );
00157 virtual void OnVanish();
00158 virtual void OnConquest();
00159 virtual void CheckSurvivor();
00160
00161 static void CountZonesOfTeam( eGrid const * grid, eTeam * otherTeam, int & count, gBaseZoneHack * & farthest );
00162
00163 REAL conquered_;
00164 int enemiesInside_;
00165 int ownersInside_;
00166
00167 bool onlySurvivor_;
00168
00169 typedef std::vector< tJUST_CONTROLLED_PTR< eTeam > > TeamArray;
00170 TeamArray enemies_;
00171 REAL lastEnemyContact_;
00172
00173 REAL teamDistance_;
00174
00175 bool touchy_;
00176
00178 enum State
00179 {
00180 State_Safe,
00181 State_Conquering,
00182 State_Conquered
00183 };
00184 State currentState_;
00185
00186 REAL lastSync_;
00187 };
00188
00190 gZone * sg_CreateWinDeathZone( eGrid * grid, const eCoord & pos );
00191
00192 #endif