mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
subs can only fire missiles when reemerged
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@ set(CONTROLLERS gameObjectFrameController.cpp cameraController.cpp)
|
|||||||
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp addTechnologyCommand.cpp toggleDebugCommand.cpp)
|
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp addTechnologyCommand.cpp toggleDebugCommand.cpp)
|
||||||
set(CORE gameManager.cpp game.cpp fxManager.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
|
set(CORE gameManager.cpp game.cpp fxManager.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
|
||||||
set(PROJECTILES projectile.cpp missile.cpp cruiseMissile.cpp shell.cpp)
|
set(PROJECTILES projectile.cpp missile.cpp cruiseMissile.cpp shell.cpp)
|
||||||
set(VEHICLES vehicle.cpp engineer.cpp resourceRover.cpp)
|
set(VEHICLES vehicle.cpp submarine.cpp engineer.cpp resourceRover.cpp)
|
||||||
set(STRUCTURES structure.cpp factory.cpp pointDefense.cpp extractor.cpp researchStruct.cpp)
|
set(STRUCTURES structure.cpp factory.cpp pointDefense.cpp extractor.cpp researchStruct.cpp)
|
||||||
set(UNITS gameObjectFactory.cpp unit.cpp ${STRUCTURES} ${VEHICLES})
|
set(UNITS gameObjectFactory.cpp unit.cpp ${STRUCTURES} ${VEHICLES})
|
||||||
set(CONTENT player.cpp trader.cpp pathfinder.cpp map.cpp gameObject.cpp gameObjectFrame.h resourceDeposit.cpp ${UNITS} ${PROJECTILES})
|
set(CONTENT player.cpp trader.cpp pathfinder.cpp map.cpp gameObject.cpp gameObjectFrame.h resourceDeposit.cpp ${UNITS} ${PROJECTILES})
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "factory.h"
|
#include "factory.h"
|
||||||
#include "engineer.h"
|
#include "engineer.h"
|
||||||
|
#include "submarine.h"
|
||||||
#include "resourceRover.h"
|
#include "resourceRover.h"
|
||||||
#include "projectile.h"
|
#include "projectile.h"
|
||||||
#include "resourceDeposit.h"
|
#include "resourceDeposit.h"
|
||||||
@@ -44,6 +45,8 @@ namespace battleship{
|
|||||||
return new Engineer(player, id, pos, rot, Unit::State::STAND_GROUND);
|
return new Engineer(player, id, pos, rot, Unit::State::STAND_GROUND);
|
||||||
case UnitClass::RESOURCE_ROVER:
|
case UnitClass::RESOURCE_ROVER:
|
||||||
return new ResourceRover(player, id, pos, rot, Unit::State::STAND_GROUND);
|
return new ResourceRover(player, id, pos, rot, Unit::State::STAND_GROUND);
|
||||||
|
case UnitClass::SUBMARINE:
|
||||||
|
return new Submarine(player, id, pos, rot, Unit::State::STAND_GROUND);
|
||||||
default:
|
default:
|
||||||
return new Vehicle(player, id, pos, rot, Unit::State::STAND_GROUND);
|
return new Vehicle(player, id, pos, rot, Unit::State::STAND_GROUND);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include "submarine.h"
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
|
#include <quad.h>
|
||||||
|
|
||||||
|
namespace battleship{
|
||||||
|
using namespace vb01;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
Submarine::Submarine(Player *player, int id, Vector3 pos, Quaternion rot, Unit::State state) : Vehicle(player, id, pos, rot, state){}
|
||||||
|
|
||||||
|
bool Submarine::validateLaunchOrder(){
|
||||||
|
if(!Unit::validateLaunchOrder()) return false;
|
||||||
|
|
||||||
|
vector<Node*> terrainNodes = Map::getSingleton()->getNodeParent()->getChildren();
|
||||||
|
|
||||||
|
for(int i = 1; i < terrainNodes.size(); i++){
|
||||||
|
Vector3 wbPos = terrainNodes[i]->getPosition();
|
||||||
|
Vector3 size = ((Quad*)terrainNodes[i]->getMesh(0))->getSize();
|
||||||
|
|
||||||
|
if(fabs(wbPos.x - pos.x) < .5 * size.x && fabs(wbPos.z - pos.z) < .5 * size.y && pos.y - wbPos.y > -.1)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef SUBMARINE_H
|
||||||
|
#define SUBMARINE_H
|
||||||
|
|
||||||
|
#include "vehicle.h"
|
||||||
|
|
||||||
|
namespace battleship{
|
||||||
|
class Submarine : public Vehicle{
|
||||||
|
public:
|
||||||
|
Submarine(Player*, int, vb01::Vector3, vb01::Quaternion, Unit::State);
|
||||||
|
private:
|
||||||
|
bool validateLaunchOrder();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -769,7 +769,7 @@ namespace battleship{
|
|||||||
case Order::TYPE::EJECT:
|
case Order::TYPE::EJECT:
|
||||||
return !garrisonSlots.empty();
|
return !garrisonSlots.empty();
|
||||||
case Order::TYPE::LAUNCH:
|
case Order::TYPE::LAUNCH:
|
||||||
return !getWeaponsByOrder(Order::TYPE::LAUNCH).empty();
|
return validateLaunchOrder();
|
||||||
case Order::TYPE::SUPPLY:
|
case Order::TYPE::SUPPLY:
|
||||||
case Order::TYPE::LOAD:
|
case Order::TYPE::LOAD:
|
||||||
case Order::TYPE::UNLOAD:
|
case Order::TYPE::UNLOAD:
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ namespace battleship{
|
|||||||
|
|
||||||
std::vector<Player*> getSelectingPlayers();
|
std::vector<Player*> getSelectingPlayers();
|
||||||
void removeOrder(int);
|
void removeOrder(int);
|
||||||
|
virtual bool validateLaunchOrder(){return !getWeaponsByOrder(Order::TYPE::LAUNCH).empty();}
|
||||||
virtual bool validateGarrisonOrder(Order){return false;}
|
virtual bool validateGarrisonOrder(Order){return false;}
|
||||||
virtual void targetUnitsAutomatically();
|
virtual void targetUnitsAutomatically();
|
||||||
virtual void reinit();
|
virtual void reinit();
|
||||||
|
|||||||
Reference in New Issue
Block a user