runnable player script from Player class

This commit is contained in:
devZoGok
2022-12-04 11:37:44 +02:00
parent 139641be1f
commit 87503c7b48
7 changed files with 29 additions and 5 deletions
+1
View File
@@ -0,0 +1 @@
players = {}
+12
View File
@@ -0,0 +1,12 @@
Player = {}
function Player:new(pl)
player = pl or {}
self.__index = self
setmetatable(player, self)
return player
end
function Player:update()
print("id = " .. self.id)
end
+2 -1
View File
@@ -31,7 +31,8 @@ namespace battleship{
scriptPathBase + "options.lua",
scriptPathBase + "unitData.lua",
scriptPathBase + "vehicleData.lua",
scriptPathBase + "structureData.lua"
scriptPathBase + "structureData.lua",
scriptPathBase + "player.lua"
};
const static Bind staticBinds[numAppStates][maxStaticBinds]{
+1
View File
@@ -37,6 +37,7 @@ namespace battleship{
void GameManager::start() {
LuaManager *luaManager = LuaManager::getSingleton();
luaManager->buildScript(vector<string>{path + "Scripts/main.lua"});
luaManager->buildScript(configData::scripts);
string ind1 = "graphics", ind2 = "resolution";
+1 -1
View File
@@ -182,7 +182,7 @@ namespace battleship{
}
faction = factions[i][0] - 48;
Player *p = new Player(difficulty, faction);
Player *p = new Player(difficulty, faction, i);
players.push_back(p);
p->setId(players.size() - 1);
}
+11 -2
View File
@@ -1,19 +1,28 @@
#include "player.h"
#include <luaManager.h>
using namespace vb01;
using namespace gameBase;
using namespace std;
namespace battleship{
Player::Player(int difficulty, int faction, Vector3 spawnPoint) {
Player::Player(int difficulty, int faction, int id, Vector3 spawnPoint) {
this->difficulty = difficulty;
this->faction = faction;
this->spawnPoint=spawnPoint;
this->spawnPoint = spawnPoint;
this->id = id;
LuaManager *lm = LuaManager::getSingleton();
lm->executeCode("players[" + to_string(id + 1) + "] = Player:new({id = " + to_string(id + 1) + "})");
}
Player::~Player() {
}
void Player::update() {
LuaManager *lm = LuaManager::getSingleton();
lm->executeCode("players[" + to_string(id + 1) + "]:update()");
}
void Player::issueOrder(Order::TYPE type, vector<Order::Target> targets, bool append){
+1 -1
View File
@@ -10,7 +10,7 @@
namespace battleship{
class Player {
public:
Player(int, int, vb01::Vector3 = vb01::Vector3::VEC_ZERO);
Player(int, int, int, vb01::Vector3 = vb01::Vector3::VEC_ZERO);
~Player();
void update();
void issueOrder(Order::TYPE, std::vector<Order::Target>, bool);