Vehicle spawning
This commit is contained in:
+2
-1
@@ -27,11 +27,12 @@ public:
|
||||
vp1->Width = this->Width / 2.f;
|
||||
//new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
||||
new VehicleSelection(vp1, "VehicleSelection", m_World, 1);
|
||||
|
||||
|
||||
vp2 = new Viewport(worldFrame, "Viewport2", m_World);
|
||||
vp2->X = vp1->Right();
|
||||
vp2->Width = this->Width / 2.f;
|
||||
new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||
//new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||
|
||||
m_FreeCamViewport = new Viewport(worldFrame, "ViewportFreeCam", m_World);
|
||||
m_FreeCamViewport->Hide();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "GUI/HealthOverlay.h"
|
||||
#include "Events/SpawnVehicle.h"
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
@@ -37,14 +38,8 @@ namespace GUI
|
||||
m_Background->SetTexture("Textures/GUI/VehicleSelection/1.png");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Update(double dt) override
|
||||
{
|
||||
|
||||
|
||||
glm::vec2 posDiff = m_TargetCoordinate - m_CurrentCoordinate;
|
||||
m_CurrentCoordinate += posDiff * 2.f * (float)dt;
|
||||
|
||||
@@ -76,6 +71,12 @@ namespace GUI
|
||||
|
||||
bool OnCommand(const Events::InputCommand &event) override
|
||||
{
|
||||
if (Hidden())
|
||||
return false;
|
||||
|
||||
if (event.PlayerID != m_PlayerID)
|
||||
return false;
|
||||
|
||||
// Menu movement
|
||||
if (event.Command == "interface_horizontal" || event.Command == "interface_vertical")
|
||||
{
|
||||
@@ -119,6 +120,23 @@ namespace GUI
|
||||
m_TargetSize = size * scale;
|
||||
}
|
||||
|
||||
// Vehicle select
|
||||
if (event.Command == "interface_confirm" && event.Value > 0)
|
||||
{
|
||||
Events::SpawnVehicle e;
|
||||
e.PlayerID = m_PlayerID;
|
||||
if (m_CurrentSelection == 0)
|
||||
e.VehicleType = "Tank"; // HACK: Base on selected vehicle ID
|
||||
else if (m_CurrentSelection == 1)
|
||||
e.VehicleType = "Helicopter";
|
||||
else if (m_CurrentSelection == 2)
|
||||
e.VehicleType = "HRSV";
|
||||
else if (m_CurrentSelection == 3)
|
||||
e.VehicleType = "Jeep";
|
||||
EventBroker->Publish(e);
|
||||
Hide();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user