| [7391] | 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 |  | 
|---|
| [7464] | 22 | #include "mission_goal.h" | 
|---|
| [7391] | 23 |  | 
|---|
|  | 24 |  | 
|---|
|  | 25 |  | 
|---|
|  | 26 |  | 
|---|
| [9357] | 27 |  | 
|---|
| [7391] | 28 | CREATE_FACTORY(SingleplayerShootemup, CL_SINGLEPLAYER_SHOOTEMUP); | 
|---|
|  | 29 |  | 
|---|
|  | 30 |  | 
|---|
| [7462] | 31 |  | 
|---|
| [7391] | 32 | /** | 
|---|
|  | 33 | * constructor | 
|---|
|  | 34 | */ | 
|---|
|  | 35 | SingleplayerShootemup::SingleplayerShootemup(const TiXmlElement* root) | 
|---|
|  | 36 | : GameRules(root) | 
|---|
|  | 37 | { | 
|---|
|  | 38 | this->setClassID(CL_SINGLEPLAYER_SHOOTEMUP, "SingleplayerShootemup"); | 
|---|
|  | 39 |  | 
|---|
|  | 40 | if( root != NULL) | 
|---|
|  | 41 | this->loadParams(root); | 
|---|
|  | 42 | } | 
|---|
|  | 43 |  | 
|---|
|  | 44 | /** | 
|---|
|  | 45 | * decontsructor | 
|---|
|  | 46 | */ | 
|---|
|  | 47 | SingleplayerShootemup::~SingleplayerShootemup() | 
|---|
|  | 48 | { | 
|---|
|  | 49 | } | 
|---|
|  | 50 |  | 
|---|
|  | 51 |  | 
|---|
|  | 52 |  | 
|---|
|  | 53 | void SingleplayerShootemup::loadParams(const TiXmlElement* root) | 
|---|
|  | 54 | { | 
|---|
|  | 55 | GameRules::loadParams(root) ; | 
|---|
|  | 56 |  | 
|---|
| [7464] | 57 | LoadParam(root, "death-screen-image", this, SingleplayerShootemup, setDeathScreen) | 
|---|
|  | 58 | .describe("sets the death screen image"); | 
|---|
| [7391] | 59 |  | 
|---|
|  | 60 | } | 
|---|
|  | 61 |  | 
|---|
|  | 62 |  | 
|---|
|  | 63 |  | 
|---|
|  | 64 | void SingleplayerShootemup::setDeathScreen(const std::string& imageName) | 
|---|
|  | 65 | {} | 
|---|
|  | 66 |  | 
|---|
|  | 67 |  | 
|---|
|  | 68 |  | 
|---|
|  | 69 | /** | 
|---|
|  | 70 | * called when the player enters the game | 
|---|
|  | 71 | * @param player the spawned player | 
|---|
|  | 72 | */ | 
|---|
|  | 73 | void SingleplayerShootemup::onPlayerSpawn() | 
|---|
|  | 74 | { | 
|---|
|  | 75 | } | 
|---|
|  | 76 |  | 
|---|
|  | 77 |  | 
|---|
|  | 78 | /** | 
|---|
|  | 79 | * when the player is killed | 
|---|
|  | 80 | * @param player the killed player | 
|---|
|  | 81 | */ | 
|---|
|  | 82 | void SingleplayerShootemup::onPlayerDeath() | 
|---|
|  | 83 | { | 
|---|
|  | 84 | } | 
|---|
|  | 85 |  | 
|---|
|  | 86 |  | 
|---|
|  | 87 | /** | 
|---|
|  | 88 | * time tick | 
|---|
|  | 89 | * @param dt time | 
|---|
|  | 90 | */ | 
|---|
|  | 91 | void SingleplayerShootemup::tick(float dt) | 
|---|
|  | 92 | { | 
|---|
| [7464] | 93 | this->checkGameRules(dt); | 
|---|
| [7391] | 94 | } | 
|---|
|  | 95 |  | 
|---|
|  | 96 |  | 
|---|
|  | 97 | /** | 
|---|
|  | 98 | * draws the stuff | 
|---|
|  | 99 | */ | 
|---|
|  | 100 | void SingleplayerShootemup::draw() | 
|---|
|  | 101 | {} | 
|---|
|  | 102 |  | 
|---|
|  | 103 |  | 
|---|
|  | 104 | /** | 
|---|
|  | 105 | * check the game rules for consistency | 
|---|
|  | 106 | */ | 
|---|
| [7464] | 107 | void SingleplayerShootemup::checkGameRules(float dt) | 
|---|
|  | 108 | { | 
|---|
| [7488] | 109 | //   PRINTF(0)("===========| Printing Mission State:\n"); | 
|---|
| [7464] | 110 | for (std::vector<MissionGoal*>::iterator it = this->missionList.begin(); it != this->missionList.end(); it++) | 
|---|
|  | 111 | { | 
|---|
|  | 112 | if( (*it)->checkMissionGoal(dt) != MS_ACCOMPLISHED) | 
|---|
|  | 113 | { | 
|---|
| [7488] | 114 | //       PRINTF(0)("  Mission \"%s\" is not finished yet\n", (*it)->getMissionName().c_str()); | 
|---|
| [7464] | 115 | } | 
|---|
|  | 116 | } | 
|---|
|  | 117 | } | 
|---|
| [7391] | 118 |  | 
|---|
|  | 119 |  | 
|---|
|  | 120 |  | 
|---|
|  | 121 |  | 
|---|
|  | 122 |  | 
|---|
|  | 123 |  | 
|---|