Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7039 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Feb 6, 2006, 12:47:01 AM (19 years ago)
Author:
patrick
Message:

trunk: game rules definitions added

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/game_world_data.cc

    r7036 r7039  
    376376    {
    377377      this->gameRule = dynamic_cast<GameRules*>(created);
     378      State::setGameRules(this->gameRule);
    378379    }
    379380    else
  • trunk/src/util/multiplayer_team_deathmatch.cc

    r7037 r7039  
    2020#include "factory.h"
    2121
     22#include "render2D/billboard.h"
     23#include "state.h"
     24
    2225
    2326using namespace std;
     
    3740  this->bLocalPlayerDead = false;
    3841  this->deathTimeout = 10.0f;     // 5 seconds
     42  this->deathScreen = new Billboard();
     43  this->deathScreen->setSize(State::getResX(), State::getResY());
    3944
    4045  if( root != NULL)
     
    5964  LoadParam(root, "max-kills", this, MultiplayerTeamDeathmatch, setMaxKills)
    6065      .describe("sets the maximal kills for winning condition");
     66
     67  LoadParam(root, "death-screen-image", this, MultiplayerTeamDeathmatch, setDeathScreen)
     68      .describe("sets the death screen image");
     69
    6170}
     71
     72
     73
     74void MultiplayerTeamDeathmatch::setDeathScreen(const char* imageName)
     75{
     76  if( this->deathScreen)
     77    this->deathScreen->setTexture(imageName);
     78}
     79
    6280
    6381
     
    6785 */
    6886void MultiplayerTeamDeathmatch::onPlayerSpawn(Player* player)
    69 {}
     87{
     88  this->bLocalPlayerDead = true;
     89}
    7090
    7191
     
    7595 */
    7696void MultiplayerTeamDeathmatch::onPlayerDeath(Player* player)
    77 {}
     97{
     98  this->localPlayer = player;
     99  this->bLocalPlayerDead = true;
     100}
    78101
    79102
     
    84107void MultiplayerTeamDeathmatch::tick(float dt)
    85108{
     109  this->checkGameRules();
    86110
     111  // is the local player dead and inactive
     112  if( unlikely(this->bLocalPlayerDead))
     113  {
     114    this->timeout += dt;
     115
     116    // long enough dead?
     117    if( dt >= this->deathTimeout)
     118    {
     119      this->timeout = 0.0f;
     120
     121      // respawn
     122    }
     123  }
    87124}
    88125
     
    92129 */
    93130void MultiplayerTeamDeathmatch::draw()
    94 {}
     131{
     132  if( unlikely( this->bLocalPlayerDead))
     133  {
     134
     135  }
     136}
    95137
    96138
     
    99141 */
    100142void MultiplayerTeamDeathmatch::checkGameRules()
    101 {}
     143{
     144  //
     145  // check for max killing count
     146  if( this->teamAKills >= this->maxKills)
     147  {
     148    // team A winns
     149  }
     150  else if( this->teamBKills >= this->maxKills)
     151  {
     152    // team B winns
     153  }
     154}
    102155
    103156
  • trunk/src/util/multiplayer_team_deathmatch.h

    r7037 r7039  
    1616class ObjectManager;
    1717class Player;
     18class Billboard;
    1819
    1920
     
    3738    inline void setDeathPenaltyTimeout(float time) { this->deathTimeout = time; }
    3839    inline void setMaxKills(int kills) { this->maxKills = kills; }
     40    void setDeathScreen(const char* imageName);
    3941
    4042  protected:
     
    4446    bool               bLocalPlayerDead;           //!< true if the local player is dead
    4547    float              deathTimeout;               //!< timeout a player cannot play if he/she dies
     48    float              timeout;                    //!< time counted if player dead
    4649    int                maxKills;                   //!< max kills for winning condition
    4750
    4851    int                teamAKills;                 //!< kills of team A
    4952    int                teamBKills;                 //!< kills of team B
     53
     54    Billboard*         deathScreen;                //!< the death screen
    5055};
    5156
  • trunk/src/util/state.cc

    r7032 r7039  
    4444
    4545StoryEntity* State::storyEntity = NULL;
     46GameRules* State::gameRules = NULL;
    4647
    4748Player* State::player = NULL;
  • trunk/src/util/state.h

    r7032 r7039  
    1717class StoryEntity;
    1818class ObjectManager;
     19class GameRules;
    1920
    2021
     
    6869  static inline StoryEntity* getCurrentStoryEntity() { return State::storyEntity; };
    6970
     71  /** @param gameRules sets the current GameRules */
     72  static inline void setGameRules(GameRules* gameRules) { State::gameRules = gameRules; }
     73  /** @returns the GameRules reference*/
     74  static inline GameRules* getGameRules() { return State::gameRules; }
     75
    7076  //////////////
    7177  /// PLAYER ///
     
    106112  static ObjectManager*         objectManager;      //!< A reference to the current ObjectManager
    107113  static StoryEntity*           storyEntity;        //!< A reference to the current StoryEntity played
     114  static GameRules*             gameRules;          //!< A reference to the GameRules
    108115  static Player*                player;             //!< A reference to the Player
    109116
Note: See TracChangeset for help on using the changeset viewer.