Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10394 was 10340, checked in by erbj, 10 years ago

Tower upgrade now implemented and towers are now saved in the towerTurretMatrix and the Models in the towerModelMatrix

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