mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
initting technologies
This commit is contained in:
@@ -1,10 +1,49 @@
|
||||
TechnologyId = {
|
||||
APT = 0,
|
||||
EFT = 1,
|
||||
PCT = 2,
|
||||
FPT = 3,
|
||||
}
|
||||
|
||||
technologies = {
|
||||
{
|
||||
name = '',
|
||||
cost = 10,
|
||||
id = TechnologyId.APT
|
||||
name = 'Advanced power technology',
|
||||
cost = 1000,
|
||||
icon = '',
|
||||
description = '',
|
||||
abilities = {0},
|
||||
units = {}
|
||||
}
|
||||
parents = {},
|
||||
children = {},
|
||||
abilities = {},
|
||||
},
|
||||
{
|
||||
id = TechnologyId.EFT
|
||||
name = 'Energy field technology',
|
||||
cost = 1000,
|
||||
icon = '',
|
||||
description = '',
|
||||
parents = {},
|
||||
children = {},
|
||||
abilities = {},
|
||||
},
|
||||
{
|
||||
id = TechnologyId.PCT
|
||||
name = 'Plasma casting technology',
|
||||
cost = 1000,
|
||||
icon = '',
|
||||
description = '',
|
||||
parents = {},
|
||||
children = {},
|
||||
abilities = {},
|
||||
},
|
||||
{
|
||||
id = TechnologyId.FPT
|
||||
name = 'Fusion power technology',
|
||||
cost = 1000,
|
||||
icon = '',
|
||||
description = '',
|
||||
parents = {},
|
||||
children = {},
|
||||
abilities = {},
|
||||
},
|
||||
}
|
||||
|
||||
+2
-1
@@ -50,7 +50,8 @@ namespace battleship{
|
||||
"Scripts/GameObjects/Projectiles/projectileData.lua",
|
||||
"Scripts/GameObjects/Units/unitData.lua",
|
||||
"Scripts/aiAgent.lua",
|
||||
"Scripts/Core/player.lua"
|
||||
"Scripts/Core/player.lua",
|
||||
"Scripts/Technologies/technologyData.lua",
|
||||
};
|
||||
|
||||
const static Bind staticBinds[numAppStates][maxStaticBinds]{
|
||||
|
||||
@@ -214,4 +214,43 @@ namespace battleship{
|
||||
unit->setPlayer(newPlayer);
|
||||
unit->halt();
|
||||
}
|
||||
|
||||
vector<int> Game::parseTechTable(int tid, string techKey, string numVarKey, string varKey){
|
||||
sol::state_view SOL_LUA_VIEW = generateView();
|
||||
SOL_LUA_VIEW.script(numVarKey + " = #" + techKey + "[" + to_string(tid + 1) + "]." + varKey);
|
||||
int numVar = SOL_LUA_VIEW[numVarKey];
|
||||
sol::table techTable = SOL_LUA_VIEW[techKey][tid + 1];
|
||||
|
||||
vector<int> varVec;
|
||||
|
||||
for(int i = 0; i < numVar; i++)
|
||||
varVec.push_back(techTable[varKey][i + 1]);
|
||||
|
||||
return varVec;
|
||||
}
|
||||
|
||||
void Game::initTechnologies(){
|
||||
technologies.clear();
|
||||
|
||||
sol::state_view SOL_LUA_VIEW = generateView();
|
||||
string techKey = "technologies";
|
||||
SOL_LUA_VIEW.script("numTechs = #" + techKey);
|
||||
int numTechs = SOL_LUA_VIEW["numTechs"];
|
||||
|
||||
for(int i = 0; i < numTechs; i++){
|
||||
sol::table techTable = SOL_LUA_VIEW[techKey][i + 1];
|
||||
|
||||
Technology t;
|
||||
t.id = techTable["id"];
|
||||
t.cost = techTable["cost"];
|
||||
t.name = techTable["name"];
|
||||
t.icon = techTable["icon"];
|
||||
t.description = techTable["description"];
|
||||
t.parents = parseTechTable(i, techKey, "numParents", "parents");
|
||||
t.children = parseTechTable(i, techKey, "numChildren", "children");
|
||||
t.abilities = parseTechTable(i, techKey, "numAbilities", "abilities");
|
||||
|
||||
technologies.push_back(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define GAME_H
|
||||
|
||||
#include "fx.h"
|
||||
#include "technology.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -23,6 +24,7 @@ namespace battleship{
|
||||
void removeAllElements();
|
||||
void explode(vb01::Vector3, int, float, sf::Sound*);
|
||||
void changeUnitPlayer(Unit*, Player*);
|
||||
void initTechnologies();
|
||||
inline void addFx(Fx f){fx.push_back(f);}
|
||||
inline void addPlayer(Player *pl){players.push_back(pl);}
|
||||
inline std::vector<Player*>& getPlayers(){return players;}
|
||||
@@ -32,9 +34,11 @@ namespace battleship{
|
||||
Game(){}
|
||||
void resetLuaGameObjects();
|
||||
void endGame(bool);
|
||||
std::vector<int> parseTechTable(int, std::string, std::string, std::string);
|
||||
|
||||
bool paused = false, ended = false;
|
||||
std::vector<Fx> fx;
|
||||
std::vector<Technology> technologies;
|
||||
std::vector<Player*> players;
|
||||
};
|
||||
}
|
||||
|
||||
+4
-1
@@ -28,6 +28,9 @@ namespace battleship{
|
||||
|
||||
for(int i = 0; i < factionsListboxes.size(); i++)
|
||||
factions.push_back(to_string(factionsListboxes[i]->getSelectedOption()));
|
||||
|
||||
Game *game = Game::getSingleton();
|
||||
game->initTechnologies();
|
||||
|
||||
int selectedMap = mapListbox->getSelectedOption();
|
||||
string mapName = wstringToString(mapListbox->getContents()[selectedMap]);
|
||||
@@ -39,7 +42,7 @@ namespace battleship{
|
||||
for(int i = 0; i < numPlayers; i++){
|
||||
bool cpuPlayer = (i < numPlayers - 1);
|
||||
string name = (cpuPlayer ? "CPU player #" + to_string(i) : "Player");
|
||||
Game::getSingleton()->addPlayer(new Player(0, 0, i, Vector3(1, 1, 1), cpuPlayer, map->getSpawnPoint(i), name));
|
||||
game->addPlayer(new Player(0, 0, i, Vector3(1, 1, 1), cpuPlayer, map->getSpawnPoint(i), name));
|
||||
}
|
||||
|
||||
map->loadPlayerGameObjects();
|
||||
|
||||
@@ -72,9 +72,16 @@ namespace battleship{
|
||||
inline void incStructuresLost(){structuresLost++;}
|
||||
inline vb01::Vector3 getColor(){return color;}
|
||||
inline std::string getName(){return name;}
|
||||
inline std::vector<int> getTechnologies(){return technologies;}
|
||||
inline void addTechnology(int tid){technologies.push_back(tid);}
|
||||
private:
|
||||
bool cpuPlayer = false;
|
||||
int refineds = 0, wealth = 0, research = 0, faction, difficulty, team, luaPlayerId, vehiclesBuilt = 0, vehiclesDestroyed = 0, vehiclesLost = 0, structuresBuilt = 0, structuresDestroyed = 0, structuresLost = 0;
|
||||
std::vector<int> technologies;
|
||||
int luaPlayerId;
|
||||
int refineds = 0, wealth = 0, research = 0;
|
||||
int faction, difficulty, team;
|
||||
int vehiclesBuilt = 0, vehiclesDestroyed = 0, vehiclesLost = 0;
|
||||
int structuresBuilt = 0, structuresDestroyed = 0, structuresLost = 0;
|
||||
std::string name;
|
||||
std::vector<Unit*> units, selectedUnits;
|
||||
std::vector<Projectile*> projectiles;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef TECHNOLOGY_H
|
||||
#define TECHNOLOGY_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace battleship{
|
||||
struct Technology{
|
||||
int id, cost;
|
||||
std::string name;
|
||||
std::string icon;
|
||||
std::string description;
|
||||
std::vector<int> parents;
|
||||
std::vector<int> children;
|
||||
std::vector<int> abilities;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user