mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
simple color coded unit models
This commit is contained in:
@@ -184,7 +184,8 @@ units = {
|
||||
lineOfSight = 25,
|
||||
name = 'Tank',
|
||||
basePath = PATH .. vehiclePrefix .. 'Tanks/',
|
||||
meshPath = 'tank.xml',
|
||||
meshPath = 'tank2.xml',
|
||||
colorNodes = {'Antenna_S', 'Antenna_L', 'Hatch'},
|
||||
selectionSfx = PATH .. 'Sounds/Units/Tanks/selection.ogg',
|
||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||
speed = .1,
|
||||
@@ -912,7 +913,7 @@ units = {
|
||||
lineOfSight = 5,
|
||||
name = 'Fort',
|
||||
basePath = PATH .. structurePrefix .. 'Forts/',
|
||||
meshPath = 'fort.xml',
|
||||
meshPath = 'fort2.xml',
|
||||
guiScreen = 'fortCommands.lua',
|
||||
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
|
||||
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
|
||||
|
||||
@@ -101,6 +101,23 @@ namespace battleship{
|
||||
}
|
||||
|
||||
model->setMaterial(mat);
|
||||
|
||||
if((sol::optional<sol::table>)gameObjTable["colorNodes"] != sol::nullopt){
|
||||
int numColorNodes = ((sol::table)gameObjTable["colorNodes"]).size();
|
||||
|
||||
for(int i = 0; i < numColorNodes; i++){
|
||||
string name = gameObjTable["colorNodes"][i + 1];
|
||||
Node *node = model->findDescendant(name, true);
|
||||
|
||||
if(!node) continue;
|
||||
|
||||
vector<Mesh*> meshes = node->getMeshes();
|
||||
|
||||
for(Mesh *mesh : meshes)
|
||||
mesh->setMaterial(player->getColorMaterial());
|
||||
}
|
||||
}
|
||||
|
||||
root->getRootNode()->attachChild(model);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -42,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->addPlayer(new Player(0, 0, i, Vector3(1, 1, 1), cpuPlayer, map->getSpawnPoint(i), name));
|
||||
game->addPlayer(new Player(0, 0, i, Vector3(i, i, i), cpuPlayer, map->getSpawnPoint(i), name));
|
||||
}
|
||||
|
||||
map->loadPlayerGameObjects();
|
||||
|
||||
+19
-2
@@ -12,9 +12,26 @@ namespace battleship{
|
||||
using namespace gameBase;
|
||||
using namespace std;
|
||||
|
||||
Player::Player(int diff, int fac, int t, Vector3 col, bool cpuPl, Vector3 sp, string n) : difficulty(diff), faction(fac), team(t), color(col), cpuPlayer(cpuPl), spawnPoint(sp), name("pl"), refineds(30000), trader(new Trader()) {}
|
||||
Player::Player(int diff, int fac, int t, Vector3 col, bool cpuPl, Vector3 sp, string n) :
|
||||
difficulty(diff),
|
||||
faction(fac),
|
||||
team(t),
|
||||
color(col),
|
||||
cpuPlayer(cpuPl),
|
||||
spawnPoint(sp),
|
||||
name("pl"),
|
||||
refineds(30000),
|
||||
trader(new Trader())
|
||||
{
|
||||
colorMaterial = new Material(Root::getSingleton()->getLibPath() + "texture");
|
||||
colorMaterial->addBoolUniform("lightingEnabled", false);
|
||||
colorMaterial->addBoolUniform("texturingEnabled", false);
|
||||
colorMaterial->addVec4Uniform("diffuseColor", Vector4(color.x, color.y, color.z, 1));
|
||||
}
|
||||
|
||||
Player::~Player() {}
|
||||
Player::~Player() {
|
||||
delete colorMaterial;
|
||||
}
|
||||
|
||||
void Player::update() {
|
||||
trader->update();
|
||||
|
||||
@@ -68,6 +68,7 @@ namespace battleship{
|
||||
inline void incStructuresLost(){structuresLost++;}
|
||||
inline vb01::Vector3 getColor(){return color;}
|
||||
inline std::string getName(){return name;}
|
||||
inline vb01::Material* getColorMaterial(){return colorMaterial;}
|
||||
inline std::vector<int> getTechnologies(){return technologies;}
|
||||
private:
|
||||
bool cpuPlayer = false;
|
||||
@@ -83,6 +84,7 @@ namespace battleship{
|
||||
std::vector<Projectile*> projectiles;
|
||||
std::vector<ResourceDeposit*> resourceDeposits;
|
||||
vb01::Vector3 spawnPoint, color;
|
||||
vb01::Material *colorMaterial = nullptr;
|
||||
|
||||
int getOrderLineId(Order::TYPE, vb01::Vector3, vb01::Vector3);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user