[Orxonox-commit 5442] r10105 - in code/branches/towerdefenseHS14: data/levels src/modules/towerdefense
erbj at orxonox.net
erbj at orxonox.net
Mon Nov 3 16:33:55 CET 2014
Author: erbj
Date: 2014-11-03 16:33:54 +0100 (Mon, 03 Nov 2014)
New Revision: 10105
Added:
code/branches/towerdefenseHS14/src/modules/towerdefense/Enemy.cc
code/branches/towerdefenseHS14/src/modules/towerdefense/Enemy.h
code/branches/towerdefenseHS14/src/modules/towerdefense/TDCoordinate.cc
code/branches/towerdefenseHS14/src/modules/towerdefense/TDCoordinate.h
Modified:
code/branches/towerdefenseHS14/data/levels/towerDefense.oxw
code/branches/towerdefenseHS14/src/modules/towerdefense/CMakeLists.txt
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc
code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h
Log:
Added TDCoordinate and more updates
Modified: code/branches/towerdefenseHS14/data/levels/towerDefense.oxw
===================================================================
--- code/branches/towerdefenseHS14/data/levels/towerDefense.oxw 2014-10-29 15:11:05 UTC (rev 10104)
+++ code/branches/towerdefenseHS14/data/levels/towerDefense.oxw 2014-11-03 15:33:54 UTC (rev 10105)
@@ -83,11 +83,11 @@
<WaypointController accuracy=60>
<waypoints>
<!-- 1,3 10,3 10,11, 13,11 -->
- <Model mesh="cube.mesh" scale=0 position="-700,-500, 150" />
- <Model mesh="cube.mesh" scale=0 position=" 200,-500, 150" />
- <Model mesh="cube.mesh" scale=0 position=" 200, 300, 150" />
- <Model mesh="cube.mesh" scale=0 position=" 500, 300, 150" />
- <Model mesh="cube.mesh" scale=0 position=" 500, 700, 150" />
+ <Model mesh="cube.mesh" scale=10 position="-700,-500, 150" />
+ <Model mesh="cube.mesh" scale=10 position=" 200,-500, 150" />
+ <Model mesh="cube.mesh" scale=10 position=" 200, 300, 150" />
+ <Model mesh="cube.mesh" scale=10 position=" 500, 300, 150" />
+ <Model mesh="cube.mesh" scale=10 position=" 500, 700, 150" />
</waypoints>
</WaypointController>
</controller>
Modified: code/branches/towerdefenseHS14/src/modules/towerdefense/CMakeLists.txt
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/CMakeLists.txt 2014-10-29 15:11:05 UTC (rev 10104)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/CMakeLists.txt 2014-11-03 15:33:54 UTC (rev 10105)
@@ -4,7 +4,9 @@
TowerDefenseCenterpoint.cc
TowerDefenseHUDController.cc
TowerDefensePlayerStats.cc
- TowerTurret.cc
+ TDCoordinate.cc
+ Enemy.cc
+
)
ORXONOX_ADD_LIBRARY(towerdefense
Added: code/branches/towerdefenseHS14/src/modules/towerdefense/Enemy.cc
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/Enemy.cc (rev 0)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/Enemy.cc 2014-11-03 15:33:54 UTC (rev 10105)
@@ -0,0 +1,58 @@
+//
+// Enemy.cc
+// Orxonox
+//
+// Created by Jonas Erb on 22.10.14.
+
+/**
+ at brief
+See TowerDefenseReadme.txt for Information.
+
+ at ingroup TowerDefense
+*/
+#include "Enemy.h"
+
+#include "core/CoreIncludes.h"
+//#include "core/XMLPort.h"
+
+namespace orxonox
+{
+ RegisterClass(Enemy);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object.
+ */
+ Enemy::Enemy(Context* context) : Pawn(context)
+ {
+ RegisterObject(Enemy);
+
+ this->setCollisionType(WorldEntity::Dynamic);
+
+ }
+
+ void Enemy::addWaypoint(TDCoordinate coord)
+ {
+ Waypointsvector_.push_back(coord);
+ }
+
+ void Enemy::popWaypoint()
+ {
+ if(Waypointsvector_.size()>0)
+ Waypointsvector_.pop_back();
+ }
+
+ TDCoordinate Enemy::peekWaypoint()
+ {
+ if(Waypointsvector_.size()<=0){
+ TDCoordinate coord = {-1,-1};
+ return coord;
+ }else{
+ return Waypointsvector_.at(Waypointsvector_.size()-1);
+
+ }
+
+
+ }
+
+}
Added: code/branches/towerdefenseHS14/src/modules/towerdefense/Enemy.h
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/Enemy.h (rev 0)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/Enemy.h 2014-11-03 15:33:54 UTC (rev 10105)
@@ -0,0 +1,53 @@
+//
+// Enemy.h
+// Orxonox
+//
+// Created by Jonas Erb on 22.10.14.
+
+/**
+ at brief
+See TowerDefenseReadme.txt for Information.
+
+ at ingroup TowerDefense
+*/
+
+
+
+#ifndef Orxonox_Tower_h
+#define Orxonox_Tower_h
+
+#include "TDCoordinate.h"
+#include "towerdefense/TowerDefense.h"
+#include "gametypes/Deathmatch.h"
+#include "towerdefense/TowerDefensePrereqs.h"
+#include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+/* Class to give the enemy spaceships waypoints and
+ *
+ */
+ class _TowerDefenseExport Enemy : public Pawn
+ {
+
+ public:
+
+ Enemy(Context* context);
+ virtual ~Enemy() {};
+
+ //health gibt es unter: health_
+
+ void addWaypoint(TDCoordinate coord);
+ void popWaypoint();
+ TDCoordinate peekWaypoint();
+ private:
+
+ std::vector<TDCoordinate> Waypointsvector_;
+
+ };
+
+
+
+}
+
+#endif /* _TowerDefense_H__ */
Added: code/branches/towerdefenseHS14/src/modules/towerdefense/TDCoordinate.cc
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TDCoordinate.cc (rev 0)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TDCoordinate.cc 2014-11-03 15:33:54 UTC (rev 10105)
@@ -0,0 +1,42 @@
+#include "TDCoordinate.h"
+
+#include "towerdefense/TowerDefensePrereqs.h"
+
+
+
+
+namespace orxonox
+{
+ RegisterClass(TDCoordinate);
+
+ /**
+ @brief
+ Constructor. Registers and initializes the object.
+ */
+ TDCoordinate::TDCoordinate()
+ {
+ RegisterObject(TDCoordinate);
+ x=0;
+ y=0;
+
+ }
+
+ TDCoordinate::TDCoordinate(int x, int y)
+ {
+ this->x=x;
+ this->y=y;
+ }
+
+
+ Vector3 TDCoordinate::get3dcoordinate()
+ {
+ int tileScale = 100;
+
+ Vector3 coord = new Vector3();
+ coord.x= (x-8) * tileScale;
+ coord.y= (y-8) * tileScale;
+ coord.z=0;
+
+ return coord;
+ }
+}
Added: code/branches/towerdefenseHS14/src/modules/towerdefense/TDCoordinate.h
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TDCoordinate.h (rev 0)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TDCoordinate.h 2014-11-03 15:33:54 UTC (rev 10105)
@@ -0,0 +1,32 @@
+#ifndef _TDCoordinate_H__
+#define _TDCoordinate_H__
+
+#include "core/CoreIncludes.h"
+#include "TDCoordinate.h"
+#include "towerdefense/TowerDefense.h"
+#include "gametypes/Deathmatch.h"
+#include "towerdefense/TowerDefensePrereqs.h"
+#include "worldentities/pawns/SpaceShip.h"
+namespace orxonox{
+
+
+//Class to save the Coordinates in a class instead of struct
+//Convert 2d coordinates to 3d in order to set waypoints
+class _TowerDefenseExport TDCoordinate: public Pawn {
+public:
+ int x;
+ int y;
+
+ TDCoordinate();
+
+ Vector3 get3dcoordinate();
+
+ virtual ~TDCoordinate() {};
+
+ TDCoordinate(int x, int y);
+ };
+
+
+}
+
+#endif /* _TDCoordinate_H__ */
Modified: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc 2014-10-29 15:11:05 UTC (rev 10104)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.cc 2014-11-03 15:33:54 UTC (rev 10105)
@@ -77,7 +77,7 @@
//#include "Tower.h"
#include "TowerTurret.h"
#include "TowerDefenseCenterpoint.h"
-
+//#include "TDCoordinate.h"
#include "worldentities/SpawnPoint.h"
#include "worldentities/pawns/Pawn.h"
#include "worldentities/pawns/SpaceShip.h"
@@ -130,12 +130,12 @@
Deathmatch::start();
const int kInitialTowerCount = 3;
- Coordinate initialTowerCoordinates[kInitialTowerCount] = {{3,2}, {8,5}, {12,10}};
for (int i = 0; i < kInitialTowerCount; i++)
{
- Coordinate coordinate = initialTowerCoordinates[i];
- addTower(coordinate.x, coordinate.y);
+ //{{3,2}, {8,5}, {12,10}}; old coordinates
+ TDCoordinate* coordinate = new TDCoordinate(i,(i*2));
+ addTower(coordinate->x, coordinate->y);
}
ChatManager::message("Use the console command addTower x y to add towers");
@@ -143,6 +143,9 @@
//TODO: let the player control his controllable entity && TODO: create a new ControllableEntity for the player
}
+ void TowerDefense::addEnemy(){}
+
+
void TowerDefense::end()
{
Deathmatch::end();
@@ -150,6 +153,8 @@
ChatManager::message("Match is over");
}
+
+
void TowerDefense::addTower(int x, int y)
{
const TowerCost towerCost = TDDefaultTowerCost;
@@ -183,7 +188,11 @@
orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl;
// Add tower to coordinatesStack
- Coordinate newTowerCoordinates = {x, y};
+ TDCoordinate newTowerCoordinates;
+ newTowerCoordinates.x=x;
+ newTowerCoordinates.y=y;
+
+
addedTowersCoordinates_.push_back(newTowerCoordinates);
// Reduce credit
@@ -204,9 +213,9 @@
bool TowerDefense::towerExists(int x, int y)
{
- for(std::vector<Coordinate>::iterator it = addedTowersCoordinates_.begin(); it != addedTowersCoordinates_.end(); ++it)
+ for(std::vector<TDCoordinate>::iterator it = addedTowersCoordinates_.begin(); it != addedTowersCoordinates_.end(); ++it)
{
- Coordinate currentCoordinates = (Coordinate) (*it);
+ TDCoordinate currentCoordinates = (TDCoordinate) (*it);
if (currentCoordinates.x == x && currentCoordinates.y == y)
return true;
}
Modified: code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h
===================================================================
--- code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h 2014-10-29 15:11:05 UTC (rev 10104)
+++ code/branches/towerdefenseHS14/src/modules/towerdefense/TowerDefense.h 2014-11-03 15:33:54 UTC (rev 10105)
@@ -36,7 +36,7 @@
#ifndef _TowerDefense_H__
#define _TowerDefense_H__
-
+#include "TDCoordinate.h"
#include "towerdefense/TowerDefensePrereqs.h"
#include "gametypes/Deathmatch.h"
@@ -50,6 +50,7 @@
TowerDefense(Context* context);
virtual ~TowerDefense();
+ void addEnemy();
virtual void start(); //<! The function is called when the gametype starts
virtual void end();
virtual void tick(float dt);
@@ -85,12 +86,8 @@
bool towerExists(int x, int y);
- typedef struct {
- int x;
- int y;
- } Coordinate;
- std::vector<Coordinate> addedTowersCoordinates_;
+ std::vector<TDCoordinate> addedTowersCoordinates_;
std::vector<TowerTurret*> towers_;
};
}
More information about the Orxonox-commit
mailing list