Merge branch 'master' into TeamPickCamera

# Conflicts:
#	src/Game/Game.cpp
This commit is contained in:
William Moberg
2016-03-04 05:58:49 +01:00
36 changed files with 12339 additions and 1565 deletions
+1 -1
Submodule assets updated: 7a6d70787b...5d7614549b
+3 -2
View File
@@ -10,8 +10,9 @@ namespace Events
struct PlayerDeath : Event
{
//KilledBy,KilledByWhat is optional for now. It might be used later in the playerlog-system
EntityWrapper Player;
std::string KilledByWhat;
EntityWrapper Player = EntityWrapper::Invalid;
EntityWrapper Killer = EntityWrapper::Invalid;
std::string KilledByWhat = "";
};
}
+1 -1
View File
@@ -68,7 +68,7 @@ protected:
const std::string m_ComponentType;
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) = 0;
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt) = 0;
};
class ImpureSystem : public virtual System
+19
View File
@@ -0,0 +1,19 @@
#ifndef Events_KillDeath_h__
#define Events_KillDeath_h__
#include "Core/EventBroker.h"
typedef unsigned int PlayerID;
namespace Events
{
struct KillDeath : public Event
{
PlayerID Casualty = -1;
PlayerID Killer = -1;
};
}
#endif
+17
View File
@@ -0,0 +1,17 @@
#ifndef Events_PlayerConnected
#define Events_PlayerConnected
#include "Core/EventBroker.h"
namespace Events
{
struct PlayerConnected : public Event
{
std::string PlayerName = "";
int PlayerID = -1;
};
}
#endif // !Events_PlayerConnected
+7 -1
View File
@@ -21,6 +21,9 @@
#include "Core/EEntityDeleted.h"
#include "Core/EComponentDeleted.h"
#include "Core/EAmmoPickup.h"
#include "Core/EPlayerDeath.h"
#include "Network/EPlayerConnected.h"
#include "Network/EKillDeath.h"
class Server : public Network
{
@@ -77,7 +80,8 @@ private:
void parseOnPlayerDamage(Packet& packet);
void identifyPacketLoss();
void kick(PlayerID player);
PlayerID GetPlayerIDFromEndpoint();
PlayerID getPlayerIDFromEndpoint();
PlayerID getPlayerIDFromEntityID(EntityID entityID);
void parsePlayerTransform(Packet& packet);
void parseOnInputCommand(Packet& packet);
void parseClientPing();
@@ -103,6 +107,8 @@ private:
bool OnPlayerDamage(const Events::PlayerDamage& e);
EventRelay<Server, Events::AmmoPickup> m_EAmmoPickup;
bool OnAmmoPickup(const Events::AmmoPickup& e);
EventRelay<Server, Events::PlayerDeath> m_EPlayerDeath;
bool OnPlayerDeath(const Events::PlayerDeath& e);
};
#endif
@@ -30,6 +30,8 @@ private:
bool m_LeftFoot = false;
// To get a difference when calculating the walking state.
glm::vec3 m_LastPosition = glm::vec3();
// Used to track afterimages for sprint effect.
float m_SprintEffectTimer;
// The logic for making the sound play when player is moving
void playerStep(double dt);
// Spawn a hexagon at origin of an Entity
+44
View File
@@ -0,0 +1,44 @@
#ifndef ScoreScreenSystem_h__
#define ScoreScreenSystem_h__
#include "Core/System.h"
#include "Core/ResourceManager.h"
#include "Core/EntityFile.h"
#include "Network/EKillDeath.h"
#include "Core/EPlayerSpawned.h"
#include "Network/EPlayerConnected.h"
#include "Network/EPlayerDisconnected.h"
#include "GLM.h"
class ScoreScreenSystem : public PureSystem
{
public:
ScoreScreenSystem(SystemParams params);
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt) override;
EventRelay<ScoreScreenSystem, Events::KillDeath> m_EPlayerDeath;
bool OnPlayerDeath(const Events::KillDeath& e);
EventRelay<ScoreScreenSystem, Events::PlayerSpawned> m_EPlayerSpawned;
bool OnPlayerSpawn(const Events::PlayerSpawned& e);
EventRelay<ScoreScreenSystem, Events::PlayerConnected> m_EPlayerConnected;
bool OnPlayerConnected(const Events::PlayerConnected& e);
EventRelay<ScoreScreenSystem, Events::PlayerDisconnected> m_EPlayerDisconnected;
bool OnPlayerDisconnected(const Events::PlayerDisconnected& e);
private:
struct PlayerData {
int ID = -1;
std::string Name = "";
int Team = 1;
int Kills = 0;
int Deaths = 0;
EntityWrapper Player = EntityWrapper::Invalid;
};
std::vector<int> m_DisconnectedIdentities;
int m_PlayerCounter = 0;
std::unordered_map<int, PlayerData> m_PlayerIdentities;
};
#endif
+2
View File
@@ -2,6 +2,8 @@
#define AmmunitionHUDSystem_h__
#include <boost/lexical_cast.hpp>
#include <sstream>
#include <iomanip>
#include "../../Engine/Core/System.h"
#include "../../Engine/GLM.h"
+2
View File
@@ -63,4 +63,6 @@
<xs:include schemaLocation="Components/FloatingEffect.xsd"/>
<xs:include schemaLocation="Components/BoostIconsHUD.xsd"/>
<xs:include schemaLocation="Components/InputCmdButton.xsd"/>
<xs:include schemaLocation="Components/ScoreScreen.xsd"/>
<xs:include schemaLocation="Components/ScoreIdentity.xsd"/>
</xs:schema>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ScoreIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ScoreIdentity.xsd">
<Name></Name>
<ID>-1</ID>
<KD>0.0</KD>
<Kills>0</Kills>
<Deaths>0</Deaths>
<Ping>0</Ping>
<Connected>true</Connected>
</ScoreIdentity>
@@ -0,0 +1,32 @@
<?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="ScoreIdentity">
<xs:annotation><xs:documentation>A component tracking data for the score of a player.</xs:documentation></xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="Name" type="t:string" minOccurs="0">
<xs:annotation><xs:documentation>A name for tracking score identities, this should be unique.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="ID" type="t:int" minOccurs="0">
<xs:annotation><xs:documentation>An id for tracking identities</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="KD" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>The Kills per death score.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Kills" type="t:int" minOccurs="0">
<xs:annotation><xs:documentation>The amount of kills.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Deaths" type="t:int" minOccurs="0">
<xs:annotation><xs:documentation>The amount of deaths.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Ping" type="t:int" minOccurs="0">
<xs:annotation><xs:documentation>Ping of a player.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Connected" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>If the player is currently connected or not</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ScoreScreen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ScoreScreen.xsd">
<TotalIdentities>0</TotalIdentities>
<NextPosition>0</NextPosition>
<Offset X="0.0" Y="0.0" Z="0.0"/>
</ScoreScreen>
@@ -0,0 +1,20 @@
<?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="ScoreScreen">
<xs:annotation><xs:documentation>The screen where player scores will be shown.</xs:documentation></xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="TotalIdentities" type="t:int" minOccurs="0">
<xs:annotation><xs:documentation>The amount of score identities this scoreboard hold</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="NextPosition" type="t:int" minOccurs="0">
<xs:annotation><xs:documentation>Where the next scoreIdentity should be placed.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Offset" type="t:Vector" minOccurs="0">
<xs:annotation><xs:documentation>How much offset should be applied per position</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<SprintAbility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SprintAbility.xsd">
<StrengthOfEffect>2.0</StrengthOfEffect>
<StrengthOfEffect>1.3</StrengthOfEffect>
<Active>false</Active>
</SprintAbility>
@@ -12,6 +12,9 @@
<xs:element name="StrengthOfEffect" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>This is the strength of the sprint effect</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Active" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>True if currently sprinting.</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
File diff suppressed because it is too large Load Diff
+399
View File
@@ -0,0 +1,399 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="HUD" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
</c:Transform>
</Components>
<Children>
<Entity name="Crosshair">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Weapons/Crosshair/SmallThickHoleDot.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.200000003"/>
<Scale X="0.0250000004" Y="0.0250000004" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="HitMarkerSpawner">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/HitMarker.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="HealthHUD">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="HealthBar">
<Components>
<c:Fill>
<Percentage>1</Percentage>
<Color A="0.301960796" B="1" G="0" R="0"/>
</c:Fill>
<c:HealthHUD/>
<c:Sprite>
<DiffuseTexture>Textures/HUD/HealthHudTriMain.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.588235319" B="0" G="0" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="-0.263000011" Y="-0.185000002" Z="0"/>
<Orientation X="5.87300014" Y="0" Z="4.71200037"/>
<Scale X="0.0799999982" Y="0.333000004" Z="0.150000006"/>
</c:Transform>
</Components>
<Children>
<Entity name="BoostIcons">
<Components>
<c:BoostIconsHUD/>
<c:Transform/>
</Components>
<Children>
<Entity name="Sniper">
<Components>
<c:Fill>
<Color A="1" B="0.345098048" G="0" R="1"/>
</c:Fill>
<c:Sprite>
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="0.588235319" B="0.121568628" G="0" R="0.443137258"/>
</c:Sprite>
<c:Transform>
<Position X="0.225000009" Y="0.38500002" Z="0"/>
<Scale X="0.27700001" Y="0.100000001" Z="0.200000003"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Assault">
<Components>
<c:Fill>
<Color A="1" B="0.533333361" G="1" R="0.329411775"/>
</c:Fill>
<c:Sprite>
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="0.588235319" B="0.0392156877" G="0.184313729" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0.225000009" Y="0.168000013" Z="0"/>
<Scale X="0.27700001" Y="0.100000001" Z="0.200000003"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Defender">
<Components>
<c:Fill>
<Color A="1" B="1" G="0.58431375" R="0.105882354"/>
</c:Fill>
<c:Sprite>
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="0.588235319" B="0.34117648" G="0.192156866" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0.224999994" Y="0.27700001" Z="0"/>
<Scale X="0.27700001" Y="0.100000001" Z="0.200000003"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Entity name="HealthText">
<Components>
<c:Fill>
<Percentage>1</Percentage>
<Color A="1" B="1" G="0" R="0"/>
</c:Fill>
<c:Text>
<Content>100/100</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="0.505882382" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:HealthHUD/>
<c:Transform>
<Position X="-0.372000009" Y="-0.212000012" Z="0.0560000017"/>
<Orientation X="0" Y="0.410000026" Z="0"/>
<Scale X="0.0189999994" Y="0.0250000004" Z="0.0350000001"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="CapturePointHUD">
<Components>
<c:Transform>
<Position X="0" Y="0.190541431" Z="0"/>
<Scale X="0.0599999987" Y="0.0599999987" Z="0.0599999987"/>
</c:Transform>
</Components>
<Children>
<Entity name="BackgroundHexagon">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.300000012" B="1" G="1" R="1"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0.919596612" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="ProgressionHexagon">
<Components>
<c:CapturePointHUD>
<CapturePointNumber>2</CapturePointNumber>
</c:CapturePointHUD>
<c:Fill>
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
</c:Fill>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/>
<Orientation X="0" Y="0" Z="1.57079637"/>
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="BackgroundHexagon">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.300000012" B="1" G="1" R="1"/>
</c:Sprite>
<c:Transform>
<Position X="0.811270177" Y="0.440691769" Z="-0.100000001"/>
</c:Transform>
</Components>
<Children>
<Entity name="ProgressionHexagon">
<Components>
<c:CapturePointHUD>
<CapturePointNumber>3</CapturePointNumber>
</c:CapturePointHUD>
<c:Fill>
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
</c:Fill>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/>
<Orientation X="0" Y="0" Z="1.57079637"/>
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="BackgroundHexagon">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="1.62788737" Y="0.919596612" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="ProgressionHexagon">
<Components>
<c:CapturePointHUD>
<CapturePointNumber>4</CapturePointNumber>
</c:CapturePointHUD>
<c:Fill>
<Percentage>1</Percentage>
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
</c:Fill>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/>
<Orientation X="0" Y="0" Z="1.57079637"/>
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="BackgroundHexagon">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.300000012" B="1" G="1" R="1"/>
</c:Sprite>
<c:Transform>
<Position X="-0.820431828" Y="0.441878349" Z="-0.100000001"/>
</c:Transform>
</Components>
<Children>
<Entity name="ProgressionHexagon">
<Components>
<c:CapturePointHUD>
<CapturePointNumber>1</CapturePointNumber>
</c:CapturePointHUD>
<c:Fill>
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
</c:Fill>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/>
<Orientation X="0" Y="0" Z="1.57079637"/>
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="BackgroundHexagon">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.699999988" B="0" G="0" R="1"/>
</c:Sprite>
<c:Transform>
<Position X="-1.58304751" Y="0.919596612" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="ProgressionHexagon">
<Components>
<c:CapturePointHUD/>
<c:Fill>
<Percentage>1</Percentage>
<Color A="0.699999988" B="0" G="0" R="1"/>
</c:Fill>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/>
<Orientation X="0" Y="0" Z="4.71238899"/>
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Entity name="KillFeed">
<Components>
<c:KillFeed/>
<c:Transform>
<Position X="0.486000031" Y="0.26000002" Z="0"/>
<Scale X="0.0149999997" Y="0.0149999997" Z="0.0149999997"/>
</c:Transform>
</Components>
<Children>
<Entity name="KillFeed1">
<Components>
<c:Text>
<Content></Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Right/>
</Alignment>
</c:Text>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="KillFeed2">
<Components>
<c:Text>
<Content></Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Right/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="0" Y="-1" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="KillFeed3">
<Components>
<c:Text>
<Content></Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Right/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="0" Y="-2" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="CapturePointArrow">
<Components>
<c:CapturePointArrowHUD/>
<c:Model>
<Resource>Models/Widgets/Arrows/Arrow5.mesh</Resource>
</c:Model>
<c:Team>
<Team>
<Blue/>
</Team>
</c:Team>
<c:Transform>
<Position X="0" Y="0.714000046" Z="-1.30000007"/>
<Orientation X="0.405680239" Y="0.369605929" Z="0"/>
<Scale X="0.200000003" Y="0.200000003" Z="0.200000003"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+107
View File
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="ScoreBoardOrigin" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform>
<Position X="66.4319992" Y="37.9560013" Z="0"/>
<Orientation X="0" Y="4.71199989" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="Background_Main">
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
</c:Model>
<c:Transform>
<Scale X="60" Y="30" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="BlueSide">
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
<Color A="1" B="1" G="0.505882382" R="0"/>
</c:Model>
<c:Transform>
<Position X="16" Y="0" Z="0.5"/>
<Scale X="25" Y="28" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="RedSide">
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
<Color A="1" B="0" G="0.219607845" R="1"/>
</c:Model>
<c:Transform>
<Position X="-16" Y="0" Z="0.5"/>
<Scale X="25" Y="28" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Background_Spectator">
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0" Y="-20.5" Z="0"/>
<Scale X="20" Y="10" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="ScoreBoard_Blue">
<Components>
<c:ScoreScreen>
<Offset X="0" Y="-2" Z="0"/>
</c:ScoreScreen>
<c:Team>
<Team>
<Blue/>
</Team>
</c:Team>
<c:Transform>
<Position X="16" Y="12" Z="1.5"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="ScoreBoard_Red">
<Components>
<c:ScoreScreen>
<Offset X="0" Y="-2" Z="0"/>
</c:ScoreScreen>
<c:Team>
<Team>
<Red/>
</Team>
</c:Team>
<c:Transform>
<Position X="-16" Y="12" Z="1.5"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="ScoreBoard_Spectators">
<Components>
<c:ScoreScreen>
<Offset X="0" Y="-1" Z="0"/>
</c:ScoreScreen>
<c:Team/>
<c:Transform>
<Position X="0" Y="-17.5" Z="1.5"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="ScoreBoard_Blue_Origin" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="BlueSide">
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
<Color A="1" B="1" G="0.505882382" R="0"/>
</c:Model>
<c:Transform>
<Position X="0" Y="0" Z="0.5"/>
<Scale X="32" Y="23" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="ScoreBoard_Blue">
<Components>
<c:ScoreScreen>
<Offset X="0" Y="-3" Z="0"/>
</c:ScoreScreen>
<c:Team>
<Team>
<Blue/>
</Team>
</c:Team>
<c:Transform>
<Position X="0" Y="7" Z="1.5"/>
</c:Transform>
</Components>
<Children>
<Entity name="IDText">
<Components>
<c:Text>
<Content>ID</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="-13" Y="2.5" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="NameText">
<Components>
<c:Text>
<Content>Name</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="-10" Y="2.5" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="KDText">
<Components>
<c:Text>
<Content>KD</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="1.28838646" Y="2.5" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="KillsText">
<Components>
<c:Text>
<Content>Kills</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="4.6874299" Y="2.5" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="DeathsText">
<Components>
<c:Text>
<Content>Deaths</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="8.9577198" Y="2.5" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="ScoreBoard_Main_Origin" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="Background_Spectator">
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0" Y="-19" Z="0"/>
<Scale X="30" Y="12" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="ScoreBoard_Spectators">
<Components>
<c:ScoreScreen>
<Offset X="0" Y="-1" Z="0"/>
</c:ScoreScreen>
<c:Team/>
<c:Transform>
<Position X="0" Y="-14" Z="1.5"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Background_Main">
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
</c:Model>
<c:Transform>
<Scale X="69" Y="25" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Spawner_1">
<Components>
<c:Spawner>
<EntityFile></EntityFile>
</c:Spawner>
<c:Transform>
<Position X="16.5" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Spawner_2">
<Components>
<c:Spawner>
<EntityFile></EntityFile>
</c:Spawner>
<c:Transform>
<Position X="-16.5" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="ScoreBoard_Red_Origin" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="RedSide">
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
<Color A="1" B="0" G="0.0862745121" R="1"/>
</c:Model>
<c:Transform>
<Position X="0" Y="0" Z="0.5"/>
<Scale X="32" Y="23" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="ScoreBoard_Red">
<Components>
<c:ScoreScreen>
<Offset X="0" Y="-3" Z="0"/>
</c:ScoreScreen>
<c:Team>
<Team>
<Red/>
</Team>
</c:Team>
<c:Transform>
<Position X="0" Y="7" Z="1.5"/>
</c:Transform>
</Components>
<Children>
<Entity name="IDText">
<Components>
<c:Text>
<Content>ID</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="-13" Y="2.5" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="NameText">
<Components>
<c:Text>
<Content>Name</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="-10" Y="2.5" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="KDText">
<Components>
<c:Text>
<Content>KD</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="1.28838646" Y="2.5" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="KillsText">
<Components>
<c:Text>
<Content>Kills</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="4.6874299" Y="2.5" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="DeathsText">
<Components>
<c:Text>
<Content>Deaths</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="8.9577198" Y="2.5" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
+119
View File
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="ScoreIdentity" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:ScoreIdentity>
<Name></Name>
</c:ScoreIdentity>
<c:Transform/>
</Components>
<Children>
<Entity name="ID">
<Components>
<c:Text>
<Content>-1</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:TextFieldReader>
<ParentEntityName>ScoreIdentity</ParentEntityName>
<ComponentType>ScoreIdentity</ComponentType>
<Field>ID</Field>
</c:TextFieldReader>
<c:Transform>
<Position X="-13" Y="0" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Name">
<Components>
<c:Text>
<Content></Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:TextFieldReader>
<ParentEntityName>ScoreIdentity</ParentEntityName>
<ComponentType>ScoreIdentity</ComponentType>
<Field>Name</Field>
</c:TextFieldReader>
<c:Transform>
<Position X="-10" Y="0" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="KD">
<Components>
<c:Text>
<Content>0.0</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:TextFieldReader>
<ParentEntityName>ScoreIdentity</ParentEntityName>
<ComponentType>ScoreIdentity</ComponentType>
<Field>KD</Field>
</c:TextFieldReader>
<c:Transform>
<Position X="1.28572214" Y="0" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Kills">
<Components>
<c:Text>
<Content>0</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:TextFieldReader>
<ParentEntityName>ScoreIdentity</ParentEntityName>
<ComponentType>ScoreIdentity</ComponentType>
<Field>Kills</Field>
</c:TextFieldReader>
<c:Transform>
<Position X="6" Y="0" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Deaths">
<Components>
<c:Text>
<Content>0</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:TextFieldReader>
<ParentEntityName>ScoreIdentity</ParentEntityName>
<ComponentType>ScoreIdentity</ComponentType>
<Field>Deaths</Field>
</c:TextFieldReader>
<c:Transform>
<Position X="10" Y="0" Z="0"/>
<Scale X="2" Y="2" Z="2"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="SprintEffect" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Animation>
<AnimationName1></AnimationName1>
<AnimationName2></AnimationName2>
<AnimationName3></AnimationName3>
</c:Animation>
<c:Lifetime>
<Lifetime>0.15</Lifetime>
</c:Lifetime>
<c:ExplosionEffect>
<Velocity X="0" Y="0" Z="0"/>
<ExplosionDuration>0.15</ExplosionDuration>
</c:ExplosionEffect>
<c:Model>
<Resource></Resource>
</c:Model>
<c:Transform/>
</Components>
<Children/>
</Entity>
+2
View File
@@ -66,6 +66,8 @@
<xs:element ref="c:HealthHUD" minOccurs="0"/>
<xs:element ref="c:SpriteIndicator" minOccurs="0"/>
<xs:element ref="c:InputCmdButton" minOccurs="0"/>
<xs:element ref="c:ScoreScreen" minOccurs="0"/>
<xs:element ref="c:ScoreIdentity" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
+39 -9
View File
@@ -14,6 +14,7 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
EVENT_SUBSCRIBE_MEMBER(m_EComponentDeleted, &Server::OnComponentDeleted);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage);
EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &Server::OnAmmoPickup);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &Server::OnPlayerDeath);
// BindWW
if (port == 0) {
port = config->Get<float>("Networking.Port", 27666);
@@ -351,7 +352,7 @@ void Server::parseTCPConnect(Packet & packet)
LOG_INFO("Parsing connections");
// Check if player is already connected
// Ska vara till lagd i TCPServer receive
PlayerID playerID = GetPlayerIDFromEndpoint();
PlayerID playerID = getPlayerIDFromEndpoint();
if (playerID == -1) {
return;
}
@@ -363,6 +364,11 @@ void Server::parseTCPConnect(Packet & packet)
m_ConnectedPlayers.at(playerID).TCPAddress = m_Address;
m_ConnectedPlayers.at(playerID).TCPPort = m_Port;
Events::PlayerConnected e;
e.PlayerID = playerID;
e.PlayerName = m_ConnectedPlayers.at(playerID).Name;
m_EventBroker->Publish(e);
LOG_INFO("parseTCPConnect: Spectator \"%s\" connected on IP: %s", m_ConnectedPlayers.at(playerID).Name.c_str(),
m_ConnectedPlayers.at(playerID).TCPAddress.to_string().c_str());
@@ -526,10 +532,20 @@ bool Server::OnAmmoPickup(const Events::AmmoPickup & e)
return true;
}
bool Server::OnPlayerDeath(const Events::PlayerDeath& e)
{
Events::KillDeath eKD;
eKD.Casualty = getPlayerIDFromEntityID(e.Player.ID);
eKD.Killer = getPlayerIDFromEntityID(e.Killer.ID);
m_EventBroker->Publish(eKD);
return false;
}
void Server::parseClientPing()
{
LOG_INFO("%i: Parsing ping", m_PacketID);
PlayerID player = GetPlayerIDFromEndpoint();
PlayerID player = getPlayerIDFromEndpoint();
if (player == -1) {
return;
}
@@ -567,7 +583,7 @@ void Server::parseOnInputCommand(Packet& packet)
{
PlayerID player = -1;
// Check which player it was who sent the message
player = GetPlayerIDFromEndpoint();
player = getPlayerIDFromEndpoint();
if (player != -1) {
while (packet.DataReadSize() < packet.Size()) {
Events::InputCommand e;
@@ -586,7 +602,7 @@ void Server::parseOnInputCommand(Packet& packet)
void Server::parsePlayerTransform(Packet& packet)
{
PlayerID playerID = GetPlayerIDFromEndpoint();
PlayerID playerID = getPlayerIDFromEndpoint();
if (playerID == -1) {
return;
}
@@ -630,12 +646,16 @@ bool Server::shouldSendToClient(EntityWrapper childEntity)
return true;
}
}
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|| childEntity.HasComponent("CapturePoint") || childEntity.HasComponent("HealthPickup")
|| childEntity.HasComponent("AmmoPickup");
return childEntity.HasComponent("Player")
|| childEntity.FirstParentWithComponent("Player").Valid()
|| childEntity.HasComponent("CapturePoint")
|| childEntity.HasComponent("HealthPickup")
|| childEntity.HasComponent("AmmoPickup")
|| childEntity.HasComponent("ScoreScreen")
|| childEntity.FirstParentWithComponent("ScoreScreen").Valid();
}
PlayerID Server::GetPlayerIDFromEndpoint()
PlayerID Server::getPlayerIDFromEndpoint()
{
// check both tcp and udp connection
for (auto& kv : m_ConnectedPlayers) {
@@ -647,4 +667,14 @@ PlayerID Server::GetPlayerIDFromEndpoint()
}
}
return -1;
}
}
PlayerID Server::getPlayerIDFromEntityID(EntityID entityID)
{
for(auto& kv : m_ConnectedPlayers) {
if (entityID == kv.second.EntityID) {
return kv.first;
}
}
return -1;
}
+10 -7
View File
@@ -76,7 +76,7 @@ size_t TCPClient::readBuffer()
memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int));
if (sizeOfPacket > m_Socket->available()) {
LOG_WARNING("TCPClient::readBuffer(): We haven't got the whole packet yet.");
return 0;
//return 0;
}
// if the buffer is to small increase the size of it
// TODO if message is huge 1 time the buffer will not decrease.
@@ -85,12 +85,15 @@ size_t TCPClient::readBuffer()
m_ReadBuffer = new char[sizeOfPacket];
m_BufferSize = sizeOfPacket;
}
// Read the rest of the message
size_t bytesReceived = m_Socket->read_some(boost
::asio::buffer((void*)(m_ReadBuffer), sizeOfPacket),
error);
if (error) {
//LOG_ERROR("receive: %s", error.message().c_str());
size_t bytesReceived = 0;
while (sizeOfPacket > bytesReceived) {
// Read the rest of the message
bytesReceived += m_Socket->read_some(boost
::asio::buffer((void*)(m_ReadBuffer), sizeOfPacket - bytesReceived),
error);
if (error) {
//LOG_ERROR("receive: %s", error.message().c_str());
}
}
if (sizeOfPacket > 1000000)
LOG_WARNING("The packets received are bigger than 1MB");
+2
View File
@@ -34,6 +34,7 @@
#include "Game/Systems/KillFeedSystem.h"
#include "Game/Systems/BoostSystem.h"
#include "Game/Systems/BoostIconsHUDSystem.h"
#include "Game/Systems/ScoreScreenSystem.h"
#include "Game/Systems/SpectatorCameraSystem.h"
#include "GUI/ButtonSystem.h"
#include "GUI/MainMenuSystem.h"
@@ -156,6 +157,7 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<ButtonSystem>(updateOrderLevel, m_Renderer);
m_SystemPipeline->AddSystem<MainMenuSystem>(updateOrderLevel, m_Renderer);
m_SystemPipeline->AddSystem<BoostIconsHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<ScoreScreenSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<SpectatorCameraSystem>(updateOrderLevel);
// Populate Octree with collidables
++updateOrderLevel;
@@ -14,17 +14,20 @@ void AbilityCooldownHUDSystem::Update(double dt)
if (!abilityEntity.Valid())
return;
EntityWrapper cooldownTextEntity = entity.FirstChildByName("Cooldown");
double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"];
double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"];
currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0;
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.
}
}
}
if (entity.HasComponent("Fill")) {
entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD;
}
}
}
+8 -2
View File
@@ -11,10 +11,16 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
if (e.Victim.ID == e.Inflictor.ID) {
return false;
}
if (!e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
if (!e.Victim.Valid() || !LocalPlayer.Valid()) {
return false;
}
if (!e.Inflictor.Valid() || !e.Victim.Valid()) {
if (e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
return false;
}
if (!e.Inflictor.Valid()) {
return false;
}
+3 -3
View File
@@ -9,7 +9,7 @@ CapturePointHUDSystem::CapturePointHUDSystem(SystemParams params)
void CapturePointHUDSystem::Update(double dt)
{
bool LoadCheck = true;
bool loadCheck = true;
int redTeam;
int blueTeam;
int spectatorTeam;
@@ -35,11 +35,11 @@ void CapturePointHUDSystem::Update(double dt)
//Check if the HUD corresponds to the Capture Point Number
if (HUD_ID == (int)entityCP["CapturePoint"]["CapturePointNumber"]) {
ComponentWrapper& teamComponent = entityCP["Team"];
if (LoadCheck) {
if (loadCheck) {
redTeam = (int)teamComponent["Team"].Enum("Red");
blueTeam = (int)teamComponent["Team"].Enum("Blue");
spectatorTeam = (int)teamComponent["Team"].Enum("Spectator");
LoadCheck = false;
loadCheck = false;
}
//Color hud with team color
auto capturePointTeam = (int)teamComponent["Team"];
+11 -10
View File
@@ -12,15 +12,7 @@ HealthSystem::HealthSystem(SystemParams params)
}
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cHealth, double dt)
{
double& health = cHealth["Health"];
if (health <= 0.0) {
Events::PlayerDeath ePlayerDeath;
ePlayerDeath.Player = entity;
m_EventBroker->Publish(ePlayerDeath);
//Note: we will delete the entity in PlayerDeathSystem
}
}
{ }
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
{
@@ -35,7 +27,16 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
if (playerBoostDefenderEntity.Valid()) {
e.Damage -= (double)playerBoostDefenderEntity["BoostDefender"]["StrengthOfEffect"];
}
health -= e.Damage;
if (health > 0) {
health -= e.Damage;
if (health <= 0.0) {
Events::PlayerDeath ePlayerDeath;
ePlayerDeath.Player = e.Victim;
ePlayerDeath.Killer = e.Inflictor;
m_EventBroker->Publish(ePlayerDeath);
//Note: we will delete the entity in PlayerDeathSystem
}
}
return true;
}
+44 -2
View File
@@ -2,6 +2,7 @@
PlayerMovementSystem::PlayerMovementSystem(SystemParams params)
: System(params)
, m_SprintEffectTimer(0.f)
{
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned);
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump);
@@ -19,8 +20,48 @@ void PlayerMovementSystem::Update(double dt)
{
updateMovementControllers(dt);
// Only do physics calculations on client and only for themselves.
if (IsClient && LocalPlayer.Valid()) {
updateVelocity(LocalPlayer, dt);
if (IsClient) {
if (LocalPlayer.Valid()){
updateVelocity(LocalPlayer, dt);
}
m_SprintEffectTimer += dt;
if (m_SprintEffectTimer < 0.016f) {
return;
}
m_SprintEffectTimer = 0.f;
const ComponentPool* pool = m_World->GetComponents("SprintAbility");
if (pool == nullptr) {
return;
}
for (auto cSprint : *pool) {
if (cSprint.EntityID != LocalPlayer.ID && (bool)cSprint["Active"]) {
// Spawn one afterimage for each player that sprints.
EntityWrapper player(m_World, cSprint.EntityID);
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/SprintEffect.xml");
EntityWrapper sprintEffect = entityFile->MergeInto(m_World);
auto playerModel = player.FirstChildByName("PlayerModel");
if (!playerModel.Valid()) {
continue;
}
if (!playerModel.HasComponent("Model")) {
continue;
}
if (!playerModel.HasComponent("Animation")) {
continue;
}
auto playerEntityModel = playerModel["Model"];
auto playerEntityAnimation = playerModel["Animation"];
playerEntityModel.Copy(sprintEffect["Model"]);
playerEntityAnimation.Copy(sprintEffect["Animation"]);
sprintEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"];
((glm::vec4&)sprintEffect["ExplosionEffect"]["EndColor"]).w = 0.f;
sprintEffect["Animation"]["Speed1"] = 0.0;
sprintEffect["Animation"]["Speed2"] = 0.0;
sprintEffect["Animation"]["Speed3"] = 0.0;
sprintEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
sprintEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"];
}
}
}
}
@@ -64,6 +105,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
}
bool sniperSprinting = false;
if (player.HasComponent("SprintAbility")) {
(bool)player["SprintAbility"]["Active"] = controller->SpecialAbilityKeyDown();
if (controller->SpecialAbilityKeyDown()) {
playerMovementSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"];
playerCrouchSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"];
+158
View File
@@ -0,0 +1,158 @@
#include "Game/Systems/ScoreScreenSystem.h"
ScoreScreenSystem::ScoreScreenSystem(SystemParams params)
: System(params)
, PureSystem("ScoreScreen")
{
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &ScoreScreenSystem::OnPlayerDeath);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerConnected, &ScoreScreenSystem::OnPlayerConnected);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDisconnected, &ScoreScreenSystem::OnPlayerDisconnected);
}
void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt)
{
if (!IsServer) {
return;
}
if(!entity.HasComponent("ScoreScreen")){
return;
}
int currentTeam = 0;
if(entity.HasComponent("Team")) {
currentTeam = (int)entity["Team"]["Team"];
} else {
return;
}
auto children = entity.ChildrenWithComponent("ScoreIdentity");
float position = 0.f;
for (auto it = m_PlayerIdentities.begin(); it != m_PlayerIdentities.end(); ++it) {
bool found = false;
for (auto& child : children) {
int ID = (int)child["ScoreIdentity"]["ID"];
if (it->first == ID) {
if (it->second.Team != currentTeam) {
m_World->DeleteEntity(child.ID);
(int&)entity["ScoreScreen"]["TotalIdentities"] -= 1;
break;
}
for (auto it2 = m_DisconnectedIdentities.begin(); it2 != m_DisconnectedIdentities.end(); ++it2) {
if (ID == *it2) {
m_World->DeleteEntity(child.ID);
(int&)entity["ScoreScreen"]["TotalIdentities"] -= 1;
it2 = m_DisconnectedIdentities.erase(it2);
it = m_PlayerIdentities.erase(it);
//Remove from m_playerIdentities
break;
}
}
found = true;
if(!child.Valid()) {
break;
}
//Update Deaths for child
(int&)child["ScoreIdentity"]["Kills"] = it->second.Kills;
//Update Kills for child
(int&)child["ScoreIdentity"]["Deaths"] = it->second.Deaths;
//KD is not updated at the moment.
if (it->second.Deaths != 0) {
(double&)child["ScoreIdentity"]["KD"] = it->second.Kills/it->second.Deaths;
}
//Update position for child
glm::vec3 offset = (glm::vec3)entity["ScoreScreen"]["Offset"];
(glm::vec3&) child["Transform"]["Position"] = offset * position;
position += 1.f;
break;
}
}
if (it == m_PlayerIdentities.end()) {
break;
}
if(found == false) {
if(it->second.Team != currentTeam) {
//This player is not the same team as this scoreboard should show.
continue;
}
//There is no entry for this player, create one.
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/ScoreIdentity.xml");
EntityWrapper scoreIdentity = entityFile->MergeInto(m_World);
glm::vec3 offset = (glm::vec3)entity["ScoreScreen"]["Offset"];
int newPosition = (int)entity["ScoreScreen"]["TotalIdentities"];
(glm::vec3&) scoreIdentity["Transform"]["Position"] = offset * (float)newPosition;
auto cScoreIdentity = scoreIdentity["ScoreIdentity"];
auto data = it->second;
(std::string&)cScoreIdentity["Name"] = data.Name;
(int&)cScoreIdentity["ID"] = data.ID;
m_World->SetParent(scoreIdentity.ID, entity.ID);
(int&)entity["ScoreScreen"]["TotalIdentities"] += 1;
}
}
//Local player should have an icon, compare with LocalPlayer somthing
}
bool ScoreScreenSystem::OnPlayerDeath(const Events::KillDeath& e)
{
//When player die, add it to his score, and when possible the player who killed him.
std::unordered_map<int, PlayerData>::iterator got;
got = m_PlayerIdentities.find(e.Casualty);
if(got != m_PlayerIdentities.end()) {
got->second.Deaths++;
}
got = m_PlayerIdentities.find(e.Killer);
if (got != m_PlayerIdentities.end()) {
got->second.Kills++;
}
return 0;
}
bool ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e)
{
//When a player spawn, add data to the list entry with the same ID.
std::unordered_map<int, PlayerData>::iterator got;
got = m_PlayerIdentities.find(e.PlayerID);
if(got == m_PlayerIdentities.end()) {
LOG_ERROR("Player spawned without having an entry on score screen");
return 0;
}
auto& data = got->second;
data.Player = e.Player;
data.Team = (int)data.Player["Team"]["Team"];
return 0;
}
bool ScoreScreenSystem::OnPlayerConnected(const Events::PlayerConnected& e)
{
//player has connected, add his data to the list of ScoreIdentities
PlayerData data;
data.ID = e.PlayerID;
data.Name = e.PlayerName;
m_PlayerIdentities.insert( {data.ID, data} );
return 0;
}
bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e)
{
//player has disconnected, remove him from list of ScoreIdentities
m_DisconnectedIdentities.push_back(e.PlayerID);
return 0;
}
+10 -2
View File
@@ -35,9 +35,17 @@ void TextFieldReader::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
if (field.Type == "int") {
text = boost::lexical_cast<std::string>((const int&)component[fieldName]);
} else if (field.Type == "float") {
text = boost::lexical_cast<std::string>((const float&)component[fieldName]);
std::ostringstream ss;
float f = (float)component[fieldName];
ss << std::fixed << std::setprecision(2);
ss << f;
text = ss.str();
} else if (field.Type == "double") {
text = boost::lexical_cast<std::string>((const double&)component[fieldName]);
std::ostringstream ss;
double d = (double)component[fieldName];
ss << std::fixed << std::setprecision(1);
ss << d;
text = ss.str();
} else if (field.Type == "bool") {
text = boost::lexical_cast<std::string>((const bool&)component[fieldName]);
} else if (field.Type == "string") {