Merge pull request #156 from teamfisk/HUD-Timers
Hud timers for dash ability
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#ifndef AbilityCooldownHUDSystem_h__
|
||||
#define AbilityCooldownHUDSystem_h__
|
||||
|
||||
#include "../../Engine/Core/System.h"
|
||||
#include "../../Engine/GLM.h"
|
||||
|
||||
class AbilityCooldownHUDSystem : public ImpureSystem
|
||||
{
|
||||
public:
|
||||
AbilityCooldownHUDSystem(SystemParams params)
|
||||
: System(params)
|
||||
{ }
|
||||
|
||||
virtual void Update(double dt) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -51,6 +51,7 @@
|
||||
<xs:include schemaLocation="Components/Page.xsd"/>
|
||||
<xs:include schemaLocation="Components/SpriteIndicator.xsd"/>
|
||||
<xs:include schemaLocation="Components/Button.xsd"/>
|
||||
<xs:include schemaLocation="Components/AbilityCooldownHUD.xsd"/>
|
||||
<xs:include schemaLocation="Components/DoubleJump.xsd"/>
|
||||
<xs:include schemaLocation="Components/WeaponAttachment.xsd"/>
|
||||
<xs:include schemaLocation="Components/DefenderWeapon.xsd"/>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<AbilityCooldownHUD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="AbilityCooldownHUD.xsd">
|
||||
</AbilityCooldownHUD>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
||||
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||
<xs:element name="AbilityCooldownHUD">
|
||||
<xs:annotation>
|
||||
<xs:documentation>HUD element for tracking ability cooldown. If it has a sprite and fill component it will fill the sprite with chosen color depending on the cooldown.\n A child with text component named "Cooldown"</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -51,6 +51,7 @@
|
||||
<xs:element ref="c:Page" minOccurs="0"/>
|
||||
<xs:element ref="c:Button" minOccurs="0"/>
|
||||
<xs:element ref="c:WeaponAttachment" minOccurs="0"/>
|
||||
<xs:element ref="c:AbilityCooldownHUD" minOccurs="0"/>
|
||||
<xs:element ref="c:DefenderWeapon" minOccurs="0"/>
|
||||
<xs:element ref="c:CapturePointArrowHUD" minOccurs="0"/>
|
||||
<xs:element ref="c:BoostIconsHUD" minOccurs="0"/>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "Rendering/AnimationSystem.h"
|
||||
#include "Network/MultiplayerSnapshotFilter.h"
|
||||
#include "Game/Systems/AmmunitionHUDSystem.h"
|
||||
#include "Game/Systems/AbilityCooldownHUDSystem.h"
|
||||
#include "Game/Systems/CapturePointArrowHUDSystem.h"
|
||||
#include "Game/Systems/KillFeedSystem.h"
|
||||
#include "Game/Systems/BoostSystem.h"
|
||||
@@ -135,6 +136,7 @@ Game::Game(int argc, char* argv[])
|
||||
m_SystemPipeline->AddSystem<AmmoPickupSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AmmunitionHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AbilityCooldownHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<CapturePointArrowHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "Game/Systems/AbilityCooldownHUDSystem.h"
|
||||
|
||||
void AbilityCooldownHUDSystem::Update(double dt)
|
||||
{
|
||||
//HUD element for tracking cooldown on the parent entity with Dashability TODO: Make sure it support other abilities when they are made.
|
||||
|
||||
auto abilityHUDs = m_World->GetComponents("AbilityCooldownHUD");
|
||||
if (abilityHUDs == nullptr)
|
||||
return;
|
||||
|
||||
for (auto& abilityHUDC : *abilityHUDs) {
|
||||
EntityWrapper entity = EntityWrapper(m_World, abilityHUDC.EntityID);
|
||||
EntityWrapper abilityEntity = entity.FirstParentWithComponent("DashAbility");
|
||||
if (!abilityEntity.Valid())
|
||||
return;
|
||||
EntityWrapper cooldownTextEntity = entity.FirstChildByName("Cooldown");
|
||||
if(cooldownTextEntity.Valid()) {
|
||||
if(cooldownTextEntity.HasComponent("Text"))
|
||||
{
|
||||
double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"];
|
||||
double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"];
|
||||
currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0;
|
||||
std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3);
|
||||
if(entity.HasComponent("Fill")) {
|
||||
entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; //TODO: current time needs to be in the component.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user