Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/orxonox_tutorial/src/orxonox/objects/TutorialShip.cc @ 1859

Last change on this file since 1859 was 1859, checked in by rgrieder, 16 years ago

Disabled all spaceship effects per default.

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *                         TUTORIAL
6 */
7
8// for precompiled header files. Has to be first!
9#include "OrxonoxStableHeaders.h"
10// always include this class's header file first so that
11// it compiles on its own too.
12#include "TutorialShip.h"
13
14// Additional includes
15#include "util/Convert.h"
16#include "util/Debug.h"
17#include "core/ConfigValueIncludes.h"
18#include "core/ConsoleCommand.h"
19#include "core/CoreIncludes.h"
20#include "core/input/InputManager.h"
21#include "core/XMLPort.h"
22
23namespace orxonox
24{
25    // Specify a console command that can be used in
26    // the shell or as key binding.
27    SetConsoleCommand(TutorialShip, fire, true)
28        .keybindMode(KeybindMode::OnHold);
29
30    // Make sure we can create an object of this class by XML
31    CreateFactory(TutorialShip);
32
33    // Constructor
34    TutorialShip::TutorialShip()
35    {
36        RegisterObject(TutorialShip);
37
38        // reset variables
39        this->hasSpecialEffects_ = false;
40
41        // set config values
42        this->setConfigValues();
43    }
44
45    // Destructor
46    TutorialShip::~TutorialShip()
47    {
48    }
49
50    // Sets the configurable member variables.
51    // They can be found later in orxonox.ini directly.
52    void TutorialShip::setConfigValues()
53    {
54        SetConfigValue(reloadTime_, 0.125)
55            .description("The reload time of the weapon in seconds");
56    }
57   
58    // Called when loading an object of this class with XML
59    // You don't have to know what exactly xmlelement is.
60    // And mode is not important yet (load/save).
61    void TutorialShip::XMLPort(Element& xmlelement, XMLPort::Mode mode)
62    {
63        // Load our parameter "specialEffects". Case sensitive!
64        XMLPortParam(TutorialShip, "specialEffects", setSpecialEffects,
65            hasSpecialEffects, xmlelement, mode);
66
67        // Calls SpaceShip::XMLPort so that the SpaceShip XML parameters
68        // are loaded too.
69        SUPER(TutorialShip, XMLPort, xmlelement, mode);
70
71        // Display a message in shell/logfile/console
72        COUT(3) << "TutorialShip was loaded." << std::endl;
73    }
74
75    // XML save function. Also used by back end class SpaceShip
76    // to show or hide the special effects.
77    bool TutorialShip::hasSpecialEffects()
78    {
79        return this->hasSpecialEffects_;
80    }
81
82    // XML load function. Called by the XML macro above.
83    void TutorialShip::setSpecialEffects(bool value)
84    {
85        this->hasSpecialEffects_ = value;
86    }
87
88    /*** NOT SO IMPORTATANT... ***/
89
90    // run time update method. Gets called every frame with the delta time that
91    // has passed since the last frame.
92    void TutorialShip::tick(float dt)
93    {
94        // Also call the tick() method of the base clas.
95        SUPER(TutorialShip, tick, dt);
96    }
97
98    // virtual function used by back end class SpaceShip.
99    float TutorialShip::getReloadTime()
100    {
101        return this->reloadTime_;
102    }
103
104    // Fire a projectile. Delegated to the back end class SpaceShip.
105    // Function content is insignificant for the tutorial.
106    void TutorialShip::fire()
107    {
108        SpaceShip::getLocalShip()->doFire();
109    }
110}
Note: See TracBrowser for help on using the repository browser.