mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
runnable player script from Player class
This commit is contained in:
@@ -0,0 +1 @@
|
||||
players = {}
|
||||
@@ -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
@@ -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]{
|
||||
|
||||
@@ -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
@@ -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
@@ -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){
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user