mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
83 lines
2.9 KiB
C++
Executable File
83 lines
2.9 KiB
C++
Executable File
#pragma once
|
|
#ifndef ACTIVE_GAME_STATE_H
|
|
#define ACTIVE_GAME_STATE_H
|
|
|
|
#include "guiAppState.h"
|
|
#include "player.h"
|
|
#include "map.h"
|
|
|
|
namespace vb01{
|
|
class Node;
|
|
}
|
|
|
|
namespace battleship{
|
|
class ActiveGameState : public gameBase::AbstractAppState {
|
|
public:
|
|
ActiveGameState(GuiAppState*, Map*, std::vector<Player*> players, int);
|
|
~ActiveGameState();
|
|
void onAttached();
|
|
void onDettached();
|
|
void update();
|
|
void onAction(int, bool);
|
|
void onAnalog(int, float);
|
|
inline void setSelectingLaunchPoint(bool s){this->selectingGuidedMissileTarget=s;}
|
|
inline Player* getPlayer(){return mainPlayer;}
|
|
inline std::vector<Unit*>& getSelectedUnits(){return selectedUnits;}
|
|
inline std::vector<Unit*>& getUnitGroup(int i){return unitGroups[i];}
|
|
private:
|
|
class UnitButton : public vb01Gui::Button{
|
|
public:
|
|
UnitButton(ActiveGameState*, vb01::Vector2, vb01::Vector2, std::string, int, int);
|
|
~UnitButton(){}
|
|
virtual void onClick();
|
|
virtual void onMouseOver();
|
|
virtual void onMouseAway();
|
|
private:
|
|
ActiveGameState *activeState;
|
|
int faction, unitId;
|
|
};
|
|
|
|
class UnitActionButton : public vb01Gui::Button{
|
|
public:
|
|
UnitActionButton(unitData::UNIT_TYPE, vb01::Vector2, vb01::Vector2, std::string, std::string);
|
|
~UnitActionButton(){}
|
|
virtual void onClick();
|
|
virtual void onMouseOver();
|
|
virtual void onMouseAway();
|
|
protected:
|
|
unitData::UNIT_TYPE type;
|
|
std::vector<Unit*> units;
|
|
ActiveGameState *activeState;
|
|
};
|
|
|
|
void deselectUnits();
|
|
void renderGUIBorders();
|
|
void renderActionButtons();
|
|
void renderUnits();
|
|
void updateCameraPosition();
|
|
void updateSelectionBox();
|
|
void addPos();
|
|
void issueOrder(Order::TYPE, std::vector<Order::Target>, bool);
|
|
void lookAround(bool);
|
|
void orientCamera(vb01::Vector3, double);
|
|
|
|
GuiAppState *guiState;
|
|
Map *map;
|
|
std::vector<Player*> players;
|
|
Player *mainPlayer;
|
|
vb01::Quad *dragbox = nullptr;
|
|
vb01::Node *dragboxNode = nullptr;
|
|
vb01::Vector2 clickPoint;
|
|
std::vector<vb01::Vector2> unitScreenPosVec;
|
|
std::vector<vb01::Vector3*> orderPos;
|
|
std::vector<vb01::Node*> unitLightNodes;
|
|
std::vector<Unit*> unitGroups[9], selectedUnits;
|
|
UnitActionButton *actionButtons[4]{nullptr, nullptr, nullptr, nullptr};
|
|
bool isSelectionBox = false, shiftPressed=false, controlPressed = false, selectingPatrolPoints = false, selectingGuidedMissileTarget = false,lookingAround=false;
|
|
bool isInLineOfSight(vb01::Vector3, float, Unit*);
|
|
int playerId, zooms = 0;
|
|
};
|
|
}
|
|
|
|
#endif
|