Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/towerdefenseFS15/src/modules/towerdefense/TowerDefenseTower.cc @ 10319

Last change on this file since 10319 was 10319, checked in by erbj, 9 years ago

tower now inherits from turret

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1//
2//  TowerDefenseTower.cc
3//  Orxonox
4//
5//  Created by Fabian Mentzer on 29.04.12.
6//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
7//
8
9/* Not implemented fully */
10
11#include "TowerDefenseTower.h"
12
13#include "core/CoreIncludes.h"
14//#include "core/XMLPort.h"
15
16namespace orxonox
17{
18    RegisterClass(TowerDefenseTower);
19
20    /**
21    @brief
22        Constructor. Registers and initializes the object.
23    */
24    TowerDefenseTower::TowerDefenseTower(Context* context) : Turret(context)
25    {
26        RegisterObject(TowerDefenseTower);
27        game_ =NULL;
28        this->setCollisionType(WorldEntity::Dynamic);
29        upgrade = 0;
30
31
32
33
34        //this->removeAllEngines();
35
36        /*
37        this->size_ = 10.0f;
38        this->delay_ = false;
39        this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
40        */
41    }
42
43    void TowerDefenseTower::setOrientation(const Quaternion& orientation)
44    {
45    }
46
47    void TowerDefenseTower::rotateYaw(const Vector2& value)
48    {
49    }
50
51    void TowerDefenseTower::rotatePitch(const Vector2& value)
52    {
53    }
54
55    void TowerDefenseTower::rotateRoll(const Vector2& value)
56    {
57    }
58
59    bool TowerDefenseTower::upgradeTower()
60    {
61        if(upgrade < 3)
62        {
63            upgrade++;
64            float reloadrate = getReloadRate();
65            float reloadwaittime = getReloadWaitTime();
66            this->setDamageMultiplier(5000);
67
68            reloadrate = 0.5f*reloadrate;
69            reloadwaittime = 0.5f*reloadwaittime;
70            setReloadRate(reloadrate);
71            setReloadWaitTime(reloadwaittime);
72            this->addTemplate("towerturret1");
73        }
74        else
75        {
76            orxout() << "Tower fully upgraded" << endl;
77            return false;
78        }
79        return true;
80    }
81
82    // This function is called whenever a player presses the up or the down key.
83    // You have to implement what happens when the up or the down key is pressed.
84    // value.x < 0 means: down key is pressed.
85    // I suggest to create a new class which is a controllable entity I will refer to as "TowerDefenseTowerMover". This is the controllable entity that the
86    // player controls in order to move the TowerDefenseTower along the centerpoint and in order to place the TowerDefenseTower at the appropriate position.
87    //
88
89    // The TowerDefenseTower itsself is controlled by a WayPointPatroController at the instance you place it on the centerpoint.
90    //(don't forget to set the team_ parameter such that all TowerDefenseTower are in the same team)
91
92    //How to move a TowerDefenseTower: simply attach the TowerDefenseTower to the TowerDefenseTowerMover
93    //How to place a TowerDefenseTower: detach the TowerDefenseTower from the TowerDefenseTowerMover
94
95    /**
96    @brief
97        Overloaded the function to rotate the stone.
98    @param value
99        A vector whose first component is the angle by which to rotate.
100    */
101    /*
102    void TowerDefenseTower::moveFrontBack(const Vector2& value)
103    {
104        //orxout() << "frontBack.x: " << value.x << endl;
105    }
106    */
107
108    /**
109    @brief
110        Overloaded the function to steer the stone right and left
111    @param value
112        A vector whose first component is the direction in which we want to steer the stone.
113    */
114    /*
115    void TowerDefenseTower::moveRightLeft(const Vector2& value)
116    {
117        //orxout() << "rightLeft.x: " << value.x << endl;
118
119        if(!this->delay_)
120        {
121            const Vector3& position = this->getPosition();
122            Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
123            if(!this->tetris_->isValidMove(this, newPos))
124                return;
125
126            this->setPosition(newPos);
127            this->delay_ = true;
128            this->delayTimer_.startTimer();
129        }
130    }
131    */
132}
Note: See TracBrowser for help on using the repository browser.