| 1 | /* | 
|---|
| 2 | orxonox - the future of 3D-vertical-scrollers | 
|---|
| 3 |  | 
|---|
| 4 | Copyright (C) 2004 orx | 
|---|
| 5 |  | 
|---|
| 6 | This program is free software; you can redistribute it and/or modify | 
|---|
| 7 | it under the terms of the GNU General Public License as published by | 
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option) | 
|---|
| 9 | any later version. | 
|---|
| 10 |  | 
|---|
| 11 | ### File Specific: | 
|---|
| 12 | main-programmer: Patrick Boenzli | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | #define DEBUG_MODULE_GAME_RULES | 
|---|
| 16 |  | 
|---|
| 17 | #include "singleplayer_shootemup.h" | 
|---|
| 18 |  | 
|---|
| 19 | #include "util/loading/load_param.h" | 
|---|
| 20 | #include "util/loading/factory.h" | 
|---|
| 21 |  | 
|---|
| 22 | #include "mission_goal.h" | 
|---|
| 23 |  | 
|---|
| 24 |  | 
|---|
| 25 |  | 
|---|
| 26 |  | 
|---|
| 27 |  | 
|---|
| 28 | ObjectListDefinition(SingleplayerShootemup); | 
|---|
| 29 | CREATE_FACTORY(SingleplayerShootemup); | 
|---|
| 30 |  | 
|---|
| 31 | /** | 
|---|
| 32 | * constructor | 
|---|
| 33 | */ | 
|---|
| 34 | SingleplayerShootemup::SingleplayerShootemup(const TiXmlElement* root) | 
|---|
| 35 | : GameRules(root) | 
|---|
| 36 | { | 
|---|
| 37 | this->registerObject(this, SingleplayerShootemup::_objectList); | 
|---|
| 38 |  | 
|---|
| 39 | if( root != NULL) | 
|---|
| 40 | this->loadParams(root); | 
|---|
| 41 | } | 
|---|
| 42 |  | 
|---|
| 43 | /** | 
|---|
| 44 | * decontsructor | 
|---|
| 45 | */ | 
|---|
| 46 | SingleplayerShootemup::~SingleplayerShootemup() | 
|---|
| 47 | { | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 |  | 
|---|
| 52 | void SingleplayerShootemup::loadParams(const TiXmlElement* root) | 
|---|
| 53 | { | 
|---|
| 54 | GameRules::loadParams(root) ; | 
|---|
| 55 |  | 
|---|
| 56 | LoadParam(root, "death-screen-image", this, SingleplayerShootemup, setDeathScreen) | 
|---|
| 57 | .describe("sets the death screen image"); | 
|---|
| 58 |  | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 |  | 
|---|
| 62 |  | 
|---|
| 63 | void SingleplayerShootemup::setDeathScreen(const std::string& imageName) | 
|---|
| 64 | {} | 
|---|
| 65 |  | 
|---|
| 66 |  | 
|---|
| 67 |  | 
|---|
| 68 | /** | 
|---|
| 69 | * called when the player enters the game | 
|---|
| 70 | * @param player the spawned player | 
|---|
| 71 | */ | 
|---|
| 72 | void SingleplayerShootemup::onPlayerSpawn() | 
|---|
| 73 | { | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 |  | 
|---|
| 77 | /** | 
|---|
| 78 | * when the player is killed | 
|---|
| 79 | * @param player the killed player | 
|---|
| 80 | */ | 
|---|
| 81 | void SingleplayerShootemup::onPlayerDeath() | 
|---|
| 82 | { | 
|---|
| 83 | } | 
|---|
| 84 |  | 
|---|
| 85 |  | 
|---|
| 86 | /** | 
|---|
| 87 | * time tick | 
|---|
| 88 | * @param dt time | 
|---|
| 89 | */ | 
|---|
| 90 | void SingleplayerShootemup::tick(float dt) | 
|---|
| 91 | { | 
|---|
| 92 | this->checkGameRules(dt); | 
|---|
| 93 | } | 
|---|
| 94 |  | 
|---|
| 95 |  | 
|---|
| 96 | /** | 
|---|
| 97 | * draws the stuff | 
|---|
| 98 | */ | 
|---|
| 99 | void SingleplayerShootemup::draw() | 
|---|
| 100 | {} | 
|---|
| 101 |  | 
|---|
| 102 |  | 
|---|
| 103 | /** | 
|---|
| 104 | * check the game rules for consistency | 
|---|
| 105 | */ | 
|---|
| 106 | void SingleplayerShootemup::checkGameRules(float dt) | 
|---|
| 107 | { | 
|---|
| 108 | //   PRINTF(0)("===========| Printing Mission State:\n"); | 
|---|
| 109 | for (std::vector<MissionGoal*>::iterator it = this->missionList.begin(); it != this->missionList.end(); it++) | 
|---|
| 110 | { | 
|---|
| 111 | if( (*it)->checkMissionGoal(dt) != MS_ACCOMPLISHED) | 
|---|
| 112 | { | 
|---|
| 113 | //       PRINTF(0)("  Mission \"%s\" is not finished yet\n", (*it)->getMissionName().c_str()); | 
|---|
| 114 | } | 
|---|
| 115 | } | 
|---|
| 116 | } | 
|---|
| 117 |  | 
|---|
| 118 |  | 
|---|
| 119 |  | 
|---|
| 120 |  | 
|---|
| 121 |  | 
|---|
| 122 |  | 
|---|