mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
Merge pull request #80 from devZoGok/imp-71-resource-consumption
Imp 71 resource consumption
This commit is contained in:
@@ -59,6 +59,7 @@ units = {
|
||||
armor = {ArmorType.MECHANIC},
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2.9, y = 8.22, z = 2.42},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -81,6 +82,7 @@ units = {
|
||||
armor = {ArmorType.STEEL},
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2.9, y = 8.22, z = 2.42},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -103,6 +105,7 @@ units = {
|
||||
armor = {ArmorType.MECHANIC},
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2.9, y = 8.22, z = 2.42},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -125,6 +128,7 @@ units = {
|
||||
armor = {ArmorType.MECHANIC},
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 1, y = 8, z = 13.45},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -146,6 +150,7 @@ units = {
|
||||
unitType = UnitType.HOVER,
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2, y = 8.25, z = 2},
|
||||
garrisonCapacity = {2, 2, 2},
|
||||
@@ -169,6 +174,7 @@ units = {
|
||||
armor = {ArmorType.MECHANIC},
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
garrisonCapacity = {2, 2, 2},
|
||||
size = {x = 2, y = 8.25, z = 2},
|
||||
@@ -192,6 +198,7 @@ units = {
|
||||
armor = {ArmorType.CAST},
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2, y = 8.25, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -214,6 +221,7 @@ units = {
|
||||
armor = {ArmorType.STEEL},
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2, y = 8.25, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -236,6 +244,7 @@ units = {
|
||||
armor = {ArmorType.CAST},
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
garrisonCapacity = {2, 2, 2},
|
||||
size = {x = 2, y = 8.25, z = 2},
|
||||
@@ -259,6 +268,7 @@ units = {
|
||||
armor = {ArmorType.CAST},
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2, y = 8.25, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -281,6 +291,7 @@ units = {
|
||||
armor = {ArmorType.STEEL, ArmorType.COMBINED},
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2, y = 8.25, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -302,6 +313,7 @@ units = {
|
||||
unitType = UnitType.SEA_LEVEL,
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2, y = 8.25, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -332,6 +344,7 @@ units = {
|
||||
unitType = UnitType.SEA_LEVEL,
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2, y = 8.25, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -369,6 +382,7 @@ units = {
|
||||
unitType = UnitType.UNDERWATER,
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2, y = 8.25, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -399,6 +413,7 @@ units = {
|
||||
unitType = UnitType.UNDERWATER,
|
||||
isVehicle = true,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 1, y = 1.15, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -419,6 +434,7 @@ units = {
|
||||
unitType = UnitType.LAND,
|
||||
isVehicle = false,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 1, y = 1.15, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -434,6 +450,7 @@ units = {
|
||||
unitType = UnitType.SEA_LEVEL,
|
||||
isVehicle = false,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 1, y = 1.15, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -449,6 +466,7 @@ units = {
|
||||
unitType = UnitType.LAND,
|
||||
isVehicle = false,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 1, y = 1.15, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -464,6 +482,7 @@ units = {
|
||||
unitType = UnitType.LAND,
|
||||
isVehicle = false,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 1, y = 1.15, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -480,6 +499,7 @@ units = {
|
||||
unitType = UnitType.LAND,
|
||||
isVehicle = false,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 2, y = 10, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -495,6 +515,7 @@ units = {
|
||||
unitType = UnitType.LAND,
|
||||
isVehicle = false,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 4, y = 1.15, z = 4},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -510,6 +531,7 @@ units = {
|
||||
unitType = UnitType.LAND,
|
||||
isVehicle = false,
|
||||
health = 500,
|
||||
buildTime = 1000,
|
||||
cost = 500,
|
||||
size = {x = 1, y = 1.15, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
@@ -525,6 +547,7 @@ units = {
|
||||
unitType = UnitType.LAND,
|
||||
isVehicle = false,
|
||||
health = 1000,
|
||||
buildTime = 1000,
|
||||
cost = 1000,
|
||||
size = {x = 1, y = 1.15, z = 2},
|
||||
hitboxOffset = {x = 0, y = 0, z = 0},
|
||||
|
||||
+9
-5
@@ -3,22 +3,26 @@
|
||||
#include "player.h"
|
||||
#include "structure.h"
|
||||
|
||||
#include <solUtil.h>
|
||||
|
||||
namespace battleship{
|
||||
using namespace vb01;
|
||||
using namespace gameBase;
|
||||
|
||||
Engineer::Engineer(Player *player, int id, Vector3 pos, Quaternion rot) : Vehicle(player, id, pos, rot){
|
||||
}
|
||||
Engineer::Engineer(Player *player, int id, Vector3 pos, Quaternion rot) : Vehicle(player, id, pos, rot){}
|
||||
|
||||
void Engineer::build(Order order){
|
||||
if(pathPoints.empty()){
|
||||
if(!order.targets[0].unit){
|
||||
if(!order.targets[0].unit)
|
||||
player->addUnit(order.targets[0].unit);
|
||||
}
|
||||
else {
|
||||
Structure *structure = (Structure*)order.targets[0].unit;
|
||||
sol::table targTable = generateView()["units"][order.targets[0].unit->getId()];
|
||||
int costRate = (int)targTable["cost"] / 100, buildRate = (int)targTable["buildTime"] / 100;
|
||||
|
||||
if(structure->getBuildStatus() < 100 && canIncrementStructureStatus()){
|
||||
if(structure->getBuildStatus() < 100 && player->getRefineds() >= costRate && getTime() - lastIncrementTime > buildRate){
|
||||
structure->incrementBuildStatus();
|
||||
player->setRefineds(player->getRefineds() - costRate);
|
||||
lastIncrementTime = getTime();
|
||||
}
|
||||
else if(structure->getBuildStatus() >= 100){
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace battleship{
|
||||
private:
|
||||
vb01::s64 lastIncrementTime = 0;
|
||||
int buildRate = 100;
|
||||
|
||||
bool canIncrementStructureStatus(){return vb01::getTime() - lastIncrementTime > buildRate;}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+7
-11
@@ -4,19 +4,16 @@
|
||||
#include "activeGameState.h"
|
||||
|
||||
#include <stateManager.h>
|
||||
#include <solUtil.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace battleship{
|
||||
using namespace vb01;
|
||||
using namespace std;
|
||||
using namespace gameBase;
|
||||
|
||||
Factory::Factory(Player *player, int id, Vector3 pos, Quaternion rot, int buildStatus) : Structure(player, id, pos, rot, buildStatus){
|
||||
initProperties();
|
||||
}
|
||||
|
||||
void Factory::initProperties(){
|
||||
}
|
||||
Factory::Factory(Player *player, int id, Vector3 pos, Quaternion rot, int buildStatus) : Structure(player, id, pos, rot, buildStatus){}
|
||||
|
||||
void Factory::update(){
|
||||
Structure::update();
|
||||
@@ -25,10 +22,6 @@ namespace battleship{
|
||||
train();
|
||||
}
|
||||
|
||||
void Factory::appendToQueue(int uc){
|
||||
unitQueue.push_back(uc);
|
||||
}
|
||||
|
||||
void Factory::train(){
|
||||
bool training = !unitQueue.empty();
|
||||
buildStatusForeground->setVisible(training);
|
||||
@@ -42,9 +35,12 @@ namespace battleship{
|
||||
bool mainPlayerSelecting = (activeState && find(selectingPlayers.begin(), selectingPlayers.end(), mainPlayer) != selectingPlayers.end());
|
||||
|
||||
Unit::displayUnitStats(buildStatusForeground, buildStatusBackground, trainingStatus, 100, mainPlayer == player && mainPlayerSelecting, Vector2(0, -10));
|
||||
sol::table targTable = generateView()["units"][unitQueue[0]];
|
||||
int costRate = (int)targTable["cost"] / 100, trainRate = (int)targTable["buildTime"] / 100;
|
||||
|
||||
if(canTrain()){
|
||||
if(player->getRefineds() >= costRate && getTime() - lastTrainTime > trainRate){
|
||||
trainingStatus++;
|
||||
player->setRefineds(player->getRefineds() - costRate);
|
||||
lastTrainTime = getTime();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,17 +18,15 @@ namespace battleship{
|
||||
Factory(Player*, int, vb01::Vector3, vb01::Quaternion, int = 0);
|
||||
~Factory(){}
|
||||
void update();
|
||||
void appendToQueue(int);
|
||||
void appendToQueue(int uc){unitQueue.push_back(uc);}
|
||||
inline std::vector<int> getQueue(){return unitQueue;}
|
||||
private:
|
||||
const int MAX_LEN_QUEUE = 10;
|
||||
int trainingStatus = 0, rateOfTraining = 50;
|
||||
int trainingStatus = 0;
|
||||
vb01::s64 lastTrainTime = 0;
|
||||
std::vector<int> unitQueue;
|
||||
|
||||
void train();
|
||||
void initProperties();
|
||||
inline bool canTrain(){return vb01::getTime() - lastTrainTime > rateOfTraining;}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace battleship{
|
||||
UnitClass unitClass;
|
||||
UnitType type;
|
||||
std::vector<Order> orders;
|
||||
int health, maxHealth, cost, id, playerId, lenHpBar = 200;
|
||||
int health, maxHealth, id, playerId, lenHpBar = 200;
|
||||
s64 orderLineDispTime = 0, lastFireTime = 0;
|
||||
float lineOfSight;
|
||||
std::vector<GarrisonSlot> garrisonSlots;
|
||||
|
||||
Reference in New Issue
Block a user