mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
labs generate research
This commit is contained in:
@@ -494,6 +494,8 @@ units = {
|
||||
size = {x = 1, y = 1.15, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
lineOfSight = 5,
|
||||
generationRate = 10000,
|
||||
generationSpeed = 10,
|
||||
name = 'Lab',
|
||||
basePath = PATH .. structurePrefix .. 'Labs/',
|
||||
meshPath = 'lab.xml',
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ set(CORE gameManager.cpp game.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
|
||||
set(PROJECTILES projectile.cpp cruiseMissile.cpp)
|
||||
set(FX fx.cpp)
|
||||
set(VEHICLES vehicle.cpp engineer.cpp resourceRover.cpp)
|
||||
set(STRUCTURES structure.cpp factory.cpp pointDefense.cpp extractor.cpp)
|
||||
set(STRUCTURES structure.cpp factory.cpp pointDefense.cpp extractor.cpp researchStruct.cpp)
|
||||
set(UNITS gameObjectFactory.cpp unit.cpp ${STRUCTURES} ${VEHICLES})
|
||||
set(CONTENT player.cpp pathfinder.cpp map.cpp gameObject.cpp gameObjectFrame.h resourceDeposit.cpp ${UNITS} ${PROJECTILES} ${FX})
|
||||
set(GAME_SRC ${STATES} ${GUI} ${CORE} ${CONTENT} ${UTIL})
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "pointDefense.h"
|
||||
#include "extractor.h"
|
||||
#include "cruiseMissile.h"
|
||||
#include "researchStruct.h"
|
||||
#include "defConfigs.h"
|
||||
|
||||
#include <solUtil.h>
|
||||
@@ -32,8 +33,9 @@ namespace battleship{
|
||||
return new PointDefense(player, id, pos, rot, buildStatus, Unit::State::STAND_GROUND);
|
||||
case UnitClass::EXTRACTOR:
|
||||
return new Extractor(player, id, pos, rot, buildStatus);
|
||||
case UnitClass::MARKET:
|
||||
case UnitClass::LAB:
|
||||
return new ResearchStruct(player, id, pos, rot, buildStatus);
|
||||
case UnitClass::MARKET:
|
||||
case UnitClass::REFINERY:
|
||||
return new Structure(player, id, pos, rot, buildStatus, Unit::State::STAND_GROUND);
|
||||
case UnitClass::ENGINEER:
|
||||
|
||||
@@ -48,12 +48,15 @@ namespace battleship{
|
||||
inline int getRefineds(){return refineds;}
|
||||
inline void setRefineds(int ref){this->refineds = ref;}
|
||||
inline void addRefineds(int ref){this->refineds += ref;}
|
||||
inline void subtractRefineds(int ref){this->refineds -= ref;}
|
||||
inline int getWealth(){return wealth;}
|
||||
inline void setWealth(int w){this->wealth = w;}
|
||||
inline void addWealth(int w){this->wealth += w;}
|
||||
inline void subtractWealth(int w){this->wealth -= w;}
|
||||
inline int getResearch(){return research;}
|
||||
inline void setResearch(int r){this->research = r;}
|
||||
inline void addResearch(int r){this->research += r;}
|
||||
inline void subtractResearch(int r){this->research -= r;}
|
||||
inline bool isCpuPlayer(){return cpuPlayer;}
|
||||
inline int getNumVehiclesBuilt(){return vehiclesBuilt;}
|
||||
inline int getNumVehiclesDestroyed(){return vehiclesDestroyed;}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "researchStruct.h"
|
||||
#include "player.h"
|
||||
|
||||
namespace battleship{
|
||||
using namespace std;
|
||||
using namespace vb01;
|
||||
using namespace gameBase;
|
||||
|
||||
ResearchStruct::ResearchStruct(Player *player, int id, Vector3 pos, Quaternion rot, int buildStatus, Unit::State state) : Structure(player, id, pos, rot, buildStatus, state){
|
||||
sol::table unitTable = generateView()["units"][id + 1];
|
||||
generationRate = unitTable["generationRate"];
|
||||
generationSpeed = unitTable["generationSpeed"];
|
||||
}
|
||||
|
||||
void ResearchStruct::update(){
|
||||
Structure::update();
|
||||
int cost = 1;
|
||||
|
||||
if(player->getRefineds() >= cost && canGenerateResearch()){
|
||||
player->addResearch(generationSpeed);
|
||||
player->subtractRefineds(cost);
|
||||
lastGenTime = getTime();
|
||||
}
|
||||
}
|
||||
|
||||
void ResearchStruct::researchTechnology(int techId){
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef RESEARCH_STRUCT_H
|
||||
#define RESEARCH_STRUCT_H
|
||||
|
||||
#include "structure.h"
|
||||
|
||||
namespace battleship{
|
||||
class ResearchStruct : public Structure{
|
||||
public:
|
||||
ResearchStruct(Player*, int, vb01::Vector3, vb01::Quaternion, int = 0, Unit::State = Unit::State::STAND_GROUND);
|
||||
void update();
|
||||
private:
|
||||
vb01::s64 lastGenTime = 0;
|
||||
int generationRate, generationSpeed;
|
||||
|
||||
bool canGenerateResearch(){return vb01::getTime() - lastGenTime > generationRate;}
|
||||
void generateResearch();
|
||||
void researchTechnology(int);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user