Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationFS15/src/modules/towerdefense/TowerDefenseTower.cc @ 10485

Last change on this file since 10485 was 10452, checked in by maxima, 9 years ago

Towerdefense merged to Presentation

  • Property svn:eol-style set to native
File size: 4.0 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::None);
29        upgrade = 0;
30        this->addTemplate("towerdefensetower");
31
32        upgradeMax = 5;
33
34
35        //this->removeAllEngines();
36
37        /*
38        this->size_ = 10.0f;
39        this->delay_ = false;
40        this->delayTimer_.setTimer(0.2f, false, createExecutor(createFunctor(&TetrisStone::enableMovement, this)));
41        */
42    }
43
44    /*
45    void TowerDefenseTower::setOrientation(const Quaternion& orientation)
46    {
47    }
48
49    void TowerDefenseTower::rotateYaw(const Vector2& value)
50    {
51    }
52
53    void TowerDefenseTower::rotatePitch(const Vector2& value)
54    {
55    }
56
57    void TowerDefenseTower::rotateRoll(const Vector2& value)
58    {
59    }
60    */
61
62    bool TowerDefenseTower::upgradeTower()
63    {
64        if(upgrade < upgradeMax)
65        {
66            upgrade++;
67            float reloadrate = getReloadRate();
68            float reloadwaittime = getReloadWaitTime();
69            this->setDamageMultiplier((upgrade+1)*1.5);
70            this->setRotationThrust(2*this->getRotationThrust());
71            reloadrate = 0.7f*reloadrate;
72            reloadwaittime = 0.7f*reloadwaittime;
73            setReloadRate(reloadrate);
74            setReloadWaitTime(reloadwaittime);
75            //this->addTemplate("towerturret1");
76        }
77        else
78        {
79            orxout() << "Tower fully upgraded" << endl;
80            return false;
81        }
82        return true;
83    }
84
85    // This function is called whenever a player presses the up or the down key.
86    // You have to implement what happens when the up or the down key is pressed.
87    // value.x < 0 means: down key is pressed.
88    // 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
89    // player controls in order to move the TowerDefenseTower along the centerpoint and in order to place the TowerDefenseTower at the appropriate position.
90    //
91
92    // The TowerDefenseTower itsself is controlled by a WayPointPatroController at the instance you place it on the centerpoint.
93    //(don't forget to set the team_ parameter such that all TowerDefenseTower are in the same team)
94
95    //How to move a TowerDefenseTower: simply attach the TowerDefenseTower to the TowerDefenseTowerMover
96    //How to place a TowerDefenseTower: detach the TowerDefenseTower from the TowerDefenseTowerMover
97
98    /**
99    @brief
100        Overloaded the function to rotate the stone.
101    @param value
102        A vector whose first component is the angle by which to rotate.
103    */
104    /*
105    void TowerDefenseTower::moveFrontBack(const Vector2& value)
106    {
107        //orxout() << "frontBack.x: " << value.x << endl;
108    }
109    */
110
111    /**
112    @brief
113        Overloaded the function to steer the stone right and left
114    @param value
115        A vector whose first component is the direction in which we want to steer the stone.
116    */
117    /*
118    void TowerDefenseTower::moveRightLeft(const Vector2& value)
119    {
120        //orxout() << "rightLeft.x: " << value.x << endl;
121
122        if(!this->delay_)
123        {
124            const Vector3& position = this->getPosition();
125            Vector3 newPos = Vector3(position.x+value.x/abs(value.x)*this->size_, position.y, position.z);
126            if(!this->tetris_->isValidMove(this, newPos))
127                return;
128
129            this->setPosition(newPos);
130            this->delay_ = true;
131            this->delayTimer_.startTimer();
132        }
133    }
134    */
135}
Note: See TracBrowser for help on using the repository browser.