mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
freezer ships can freeze units
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@ set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceComman
|
||||
set(CORE gameManager.cpp game.cpp environment.cpp fxManager.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
|
||||
|
||||
set(PROJECTILES projectile.cpp missile.cpp cruiseMissile.cpp shell.cpp)
|
||||
set(VEHICLES vehicle.cpp submarine.cpp engineer.cpp resourceRover.cpp)
|
||||
set(VEHICLES vehicle.cpp submarine.cpp engineer.cpp resourceRover.cpp freezer.cpp)
|
||||
set(STRUCTURES structure.cpp factory.cpp pointDefense.cpp extractor.cpp researchStruct.cpp iceSheet.cpp)
|
||||
set(UNITS gameObjectFactory.cpp unit.cpp weapon.cpp ${STRUCTURES} ${VEHICLES})
|
||||
set(CONTENT player.cpp trader.cpp pathfinder.cpp map.cpp gameObject.cpp gameObjectFrame.h resourceDeposit.cpp ${UNITS} ${PROJECTILES})
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#include "freezer.h"
|
||||
|
||||
namespace battleship{
|
||||
using namespace vb01;
|
||||
|
||||
//TODO rename the class to a more generic name
|
||||
Freezer::Freezer(Player *player, int id, Vector3 pos, Quaternion rot, Unit::State state) : Vehicle(player, id, pos, rot, state){}
|
||||
|
||||
void Freezer::attack(Order order){
|
||||
Vehicle::attack(order);
|
||||
|
||||
Unit *target = order.targets[0].unit;
|
||||
|
||||
if(target && target->getFreezeStatus() == 100)
|
||||
removeOrder(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef FREEZER_H
|
||||
#define FREEZER_H
|
||||
|
||||
#include "vehicle.h"
|
||||
|
||||
namespace battleship{
|
||||
class Freezer : public Vehicle{
|
||||
public:
|
||||
Freezer(Player*, int, vb01::Vector3, vb01::Quaternion, Unit::State);
|
||||
private:
|
||||
void attack(Order);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "resourceDeposit.h"
|
||||
#include "pointDefense.h"
|
||||
#include "extractor.h"
|
||||
#include "freezer.h"
|
||||
#include "researchStruct.h"
|
||||
#include "missile.h"
|
||||
#include "cruiseMissile.h"
|
||||
@@ -37,6 +38,8 @@ namespace battleship{
|
||||
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);
|
||||
case UnitClass::FREEZER:
|
||||
return new Freezer(player, id, pos, rot, Unit::State::STAND_GROUND);
|
||||
default:
|
||||
return new Vehicle(player, id, pos, rot, Unit::State::STAND_GROUND);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace battleship{
|
||||
|
||||
if(wtOpt != sol::nullopt) wt = unitTable[tblName][i + 1]["type"];
|
||||
|
||||
Weapon *weapon = ((Weapon::Type)wt == Weapon::Type::FREEZER ? new Freezer(this, unitTable, i) : new Weapon(this, unitTable, i));
|
||||
Weapon *weapon = ((Weapon::Type)wt == Weapon::Type::FREEZER ? new CryoGun(this, unitTable, i) : new Weapon(this, unitTable, i));
|
||||
weapons.push_back(weapon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace battleship{
|
||||
void navigateToTarget(float);
|
||||
void preparePathpoints(Order&, vb01::Vector3, bool = false);
|
||||
void alignToSurface();
|
||||
void attack(Order);
|
||||
virtual void attack(Order);
|
||||
void garrison(Order);
|
||||
void patrol(Order);
|
||||
virtual void initProperties();
|
||||
|
||||
+2
-2
@@ -234,9 +234,9 @@ namespace battleship{
|
||||
//if(vertNode) alignNode(targPos, vertNode, false);
|
||||
}
|
||||
|
||||
Freezer::Freezer(Unit *u, sol::table unitTable, int wid) : Weapon(u, unitTable, wid){}
|
||||
CryoGun::CryoGun(Unit *u, sol::table unitTable, int wid) : Weapon(u, unitTable, wid){}
|
||||
|
||||
void Freezer::updateTargetUnit(Unit *targetUnit){
|
||||
void CryoGun::updateTargetUnit(Unit *targetUnit){
|
||||
if(canFreeze()){
|
||||
targetUnit->setFreezeStatus(targetUnit->getFreezeStatus() + 1);
|
||||
lastFreezeTime = getTime();
|
||||
|
||||
@@ -54,12 +54,12 @@ namespace battleship{
|
||||
protected:
|
||||
int rateOfFire;
|
||||
|
||||
void updateTargetUnit(Unit*);
|
||||
virtual void updateTargetUnit(Unit*);
|
||||
};
|
||||
|
||||
class Freezer : public Weapon{
|
||||
class CryoGun : public Weapon{
|
||||
public:
|
||||
Freezer(Unit*, sol::table, int);
|
||||
CryoGun(Unit*, sol::table, int);
|
||||
private:
|
||||
vb01::s64 lastFreezeTime = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user