mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
placeable resource deposits in the map editor
This commit is contained in:
@@ -9,5 +9,17 @@ resources = {
|
||||
},
|
||||
basePath = {
|
||||
PATH .. 'Models/Resources/'
|
||||
},
|
||||
unitCornerPoints = {
|
||||
{
|
||||
{x = .9, y = -1, z = -6},
|
||||
{x = -.9, y = -1, z = -6},
|
||||
{x = -.9, y = -1, z = 5.8},
|
||||
{x = .9, y = -1, z = 5.8},
|
||||
{x = .9, y = 3.5, z = -6},
|
||||
{x = -.9, y = 3.5, z = -6},
|
||||
{x = -.9, y = 3.5, z = 5.8},
|
||||
{x = .9, y = 3.5, z = 5.8}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace battleship{
|
||||
inline vb01::Vector3 getLeftVec() {return leftVec;}
|
||||
inline vb01::Vector3 getUpVec() {return upVec;}
|
||||
inline int getId() {return id;}
|
||||
inline Type getType(){return type;}
|
||||
private:
|
||||
protected:
|
||||
virtual void initProperties();
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace battleship{
|
||||
}
|
||||
}
|
||||
|
||||
Projectile* createProjectile(Unit*, int, vb01::Vector3, vb01::Quaternion){
|
||||
Projectile* GameObjectFactory::createProjectile(Unit *unti, int id, Vector3 pos, Quaternion rot){
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ResourceDeposit* createResourceDeposit(int, vb01::Vector3, vb01::Quaternion){
|
||||
return nullptr;
|
||||
ResourceDeposit* GameObjectFactory::createResourceDeposit(int id, Vector3 pos, Quaternion rot){
|
||||
return new ResourceDeposit(id, pos, rot);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace battleship{
|
||||
public:
|
||||
enum GameObjectType{UNIT, PROJECTILE, RESOURCE_DEPOSIT};
|
||||
static Unit* createUnit(Player*, int, vb01::Vector3, vb01::Quaternion);
|
||||
static Projectile* createProjectile(Player*, Unit*, int, vb01::Vector3, vb01::Quaternion);
|
||||
static Projectile* createProjectile(Unit*, int, vb01::Vector3, vb01::Quaternion);
|
||||
static ResourceDeposit* createResourceDeposit(int, vb01::Vector3, vb01::Quaternion);
|
||||
private:
|
||||
};
|
||||
|
||||
+13
-2
@@ -2,6 +2,7 @@
|
||||
#include "gameManager.h"
|
||||
#include "defConfigs.h"
|
||||
#include "cameraController.h"
|
||||
#include "gameObjectFactory.h"
|
||||
#include "gameObjectFrameController.h"
|
||||
#include "player.h"
|
||||
#include "map.h"
|
||||
@@ -56,6 +57,7 @@ namespace battleship{
|
||||
|
||||
AssetManager *assetManager = AssetManager::getSingleton();
|
||||
assetManager->load(basePath + "Models/Units/", true);
|
||||
assetManager->load(basePath + "Models/Resources/", true);
|
||||
assetManager->load(basePath + DEFAULT_TEXTURE);
|
||||
}
|
||||
|
||||
@@ -583,9 +585,18 @@ namespace battleship{
|
||||
switch((Bind)bind){
|
||||
case Bind::LOOK_AROUND:
|
||||
if(ufCtr->isPlacingFrames()){
|
||||
Player *player = Map::getSingleton()->getPlayer(0);
|
||||
Map *map = Map::getSingleton();
|
||||
Player *player = map->getPlayer(0);
|
||||
GameObjectFrame &frame = ufCtr->getGameObjectFrame(0);
|
||||
player->addUnit(new Unit(player, frame.getId(), frame.getModel()->getPosition(), frame.getModel()->getOrientation()));
|
||||
Model *model = frame.getModel();
|
||||
Vector3 pos = model->getPosition();
|
||||
Quaternion rot = model->getOrientation();
|
||||
|
||||
if(frame.getType() == GameObject::Type::RESOURCE_DEPOSIT){
|
||||
ResourceDeposit *dep = GameObjectFactory::createResourceDeposit(frame.getId(), pos, rot);
|
||||
}
|
||||
else
|
||||
player->addUnit(GameObjectFactory::createUnit(player, frame.getId(), pos, rot));
|
||||
}
|
||||
else
|
||||
CameraController::getSingleton()->setLookingAround(isPressed);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "resourceDeposit.h"
|
||||
|
||||
namespace battleship{
|
||||
using namespace vb01;
|
||||
|
||||
ResourceDeposit::ResourceDeposit(int id, Vector3 pos, Quaternion rot) : GameObject(GameObject::Type::RESOURCE_DEPOSIT, id, nullptr, pos, rot){
|
||||
initModel();
|
||||
placeAt(pos);
|
||||
orientAt(rot);
|
||||
}
|
||||
|
||||
void ResourceDeposit::update(){
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef RESOURCE_DEPOSIT_H
|
||||
#define RESOURCE_DEPOSIT_H
|
||||
|
||||
#include "gameObject.h"
|
||||
|
||||
namespace battleship{
|
||||
class ResourceDeposit : public GameObject{
|
||||
public:
|
||||
ResourceDeposit(int, vb01::Vector3, vb01::Quaternion);
|
||||
void update();
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user