Added Assault,Defender,Sniper Components,Entities. Added ShieldAbility,Sprintability-Component (not implemented). Changed BoostSystem to use a childed Boost to the player. All friendly fire is 0 damage.
This commit is contained in:
@@ -20,6 +20,6 @@ private:
|
||||
EventRelay<BoostSystem, Events::PlayerDamage> m_EPlayerDamage;
|
||||
bool OnPlayerDamage(Events::PlayerDamage& e);
|
||||
|
||||
std::string determineClass(EntityWrapper player);
|
||||
std::string DetermineClass(EntityWrapper player);
|
||||
};
|
||||
#endif
|
||||
@@ -35,9 +35,12 @@
|
||||
<xs:include schemaLocation="Components/AmmoPickup.xsd"/>
|
||||
<xs:include schemaLocation="Components/AnimationOffset.xsd"/>
|
||||
<xs:include schemaLocation="Components/DashAbility.xsd"/>
|
||||
<xs:include schemaLocation="Components/ShieldAbility.xsd"/>
|
||||
<xs:include schemaLocation="Components/SprintAbility.xsd"/>
|
||||
<xs:include schemaLocation="Components/AssaultWeapon.xsd"/>
|
||||
<xs:include schemaLocation="Components/BoostAssault.xsd"/>
|
||||
<xs:include schemaLocation="Components/BoostDefender.xsd"/>
|
||||
<xs:include schemaLocation="Components/BoostSniper.xsd"/>
|
||||
<xs:include schemaLocation="Components/Shield.xsd"/>
|
||||
<xs:include schemaLocation="Components/Sprite.xsd"/>
|
||||
<xs:include schemaLocation="Components/Shielded.xsd"/>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<BoostAssault xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BoostAssault.xsd">
|
||||
<StrengthOfEffect>2</StrengthOfEffect>
|
||||
<LifeTimeOfEffect>5</LifeTimeOfEffect>
|
||||
</BoostAssault>
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
<xs:element name="StrengthOfEffect" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>This is the strength of the boost effect</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="LifeTimeOfEffect" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>How long the effect lasts</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<BoostDefender xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BoostDefender.xsd">
|
||||
<StrengthOfEffect>10</StrengthOfEffect>
|
||||
<LifeTimeOfEffect>5</LifeTimeOfEffect>
|
||||
</BoostDefender>
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
<xs:element name="StrengthOfEffect" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>This is the strength of the boost effect</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="LifeTimeOfEffect" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>How long the effect lasts</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<BoostSniper xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BoostSniper.xsd">
|
||||
<StrengthOfEffect>10</StrengthOfEffect>
|
||||
</BoostSniper>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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="BoostSniper">
|
||||
<xs:annotation>
|
||||
<xs:documentation>This is the defender's class boost component</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="StrengthOfEffect" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>This is the strength of the boost effect</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<ShieldAbility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ShieldAbility.xsd">
|
||||
<CoolDownMaxTimer>2.0</CoolDownMaxTimer>
|
||||
</ShieldAbility>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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="ShieldAbility">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A dash component for one of the classes</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="CoolDownMaxTimer" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>This is the cooldown on dash</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<SprintAbility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SprintAbility.xsd">
|
||||
<CoolDownMaxTimer>2.0</CoolDownMaxTimer>
|
||||
</SprintAbility>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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="SprintAbility">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A dash component for one of the classes</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="CoolDownMaxTimer" type="t:double" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>This is the cooldown on dash</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -4,7 +4,7 @@
|
||||
<Components>
|
||||
<c:BoostAssault/>
|
||||
<c:Lifetime>
|
||||
<Lifetime>55</Lifetime>
|
||||
<Lifetime>10</Lifetime>
|
||||
</c:Lifetime>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||
|
||||
<Components>
|
||||
<c:BoostDefender/>
|
||||
<c:Lifetime>
|
||||
<Lifetime>10</Lifetime>
|
||||
</c:Lifetime>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
|
||||
<Children/>
|
||||
|
||||
</Entity>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||
|
||||
<Components>
|
||||
<c:BoostSniper/>
|
||||
<c:Lifetime>
|
||||
<Lifetime>10</Lifetime>
|
||||
</c:Lifetime>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
|
||||
<Children/>
|
||||
|
||||
</Entity>
|
||||
@@ -25,35 +25,38 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
||||
return false;
|
||||
}
|
||||
|
||||
//friendly fire
|
||||
|
||||
auto className = determineClass(e.Inflictor);
|
||||
auto className = DetermineClass(e.Inflictor);
|
||||
if (className == "") {
|
||||
return false;
|
||||
}
|
||||
//"Schema/Entities/BoostAssault.xml"
|
||||
//"Schema/Entities/Boost-.xml"
|
||||
std::string classXML = "Schema/Entities/" + className + ".xml";
|
||||
|
||||
//class
|
||||
|
||||
//check if player already has the component
|
||||
auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className);
|
||||
if (playerBoostAssaultEntity.Valid()) {
|
||||
m_World->DeleteEntity(playerBoostAssaultEntity.ID);
|
||||
}
|
||||
//load & set the BoostAssault Component
|
||||
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityID boostAssaultEntity = parser.MergeEntities(m_World);
|
||||
m_World->SetName(boostAssaultEntity, className);
|
||||
m_World->SetParent(boostAssaultEntity, e.Victim.ID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string BoostSystem::determineClass(EntityWrapper player)
|
||||
std::string BoostSystem::DetermineClass(EntityWrapper inflictorPlayer)
|
||||
{
|
||||
if (m_World->HasComponent(player.ID, "DashAbility")) {
|
||||
//determine the class based on what component the inflictor-player has
|
||||
if (m_World->HasComponent(inflictorPlayer.ID, "DashAbility")) {
|
||||
return "BoostAssault";
|
||||
}
|
||||
if (m_World->HasComponent(player.ID, "DefenderShield")) {
|
||||
if (m_World->HasComponent(inflictorPlayer.ID, "ShieldAbility")) {
|
||||
return "BoostDefender";
|
||||
}
|
||||
if (m_World->HasComponent(player.ID, "SniperSprint")) {
|
||||
if (m_World->HasComponent(inflictorPlayer.ID, "SprintAbility")) {
|
||||
return "BoostSniper";
|
||||
}
|
||||
return "";
|
||||
|
||||
@@ -30,8 +30,9 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
|
||||
|
||||
ComponentWrapper cHealth = e.Victim["Health"];
|
||||
double& health = cHealth["Health"];
|
||||
if (e.Victim.HasComponent("BoostDefender")) {
|
||||
e.Damage -= (double)e.Victim["BoostDefender"]["StrengthOfEffect"];
|
||||
auto playerBoostDefenderEntity = e.Victim.FirstChildByName("BoostDefender");
|
||||
if (playerBoostDefenderEntity.Valid()) {
|
||||
e.Damage -= (double)playerBoostDefenderEntity["BoostDefender"]["StrengthOfEffect"];
|
||||
}
|
||||
health -= e.Damage;
|
||||
|
||||
|
||||
@@ -53,9 +53,10 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
float playerMovementSpeed = player["Player"]["MovementSpeed"];
|
||||
float playerCrouchSpeed = player["Player"]["CrouchSpeed"];
|
||||
glm::vec3& wishDirection = player["Player"]["CurrentWishDirection"];
|
||||
if (player.HasComponent("BoostAssault")) {
|
||||
playerMovementSpeed *= (double)player["BoostAssault"]["StrengthOfEffect"];
|
||||
playerCrouchSpeed *= (double)player["BoostAssault"]["StrengthOfEffect"];
|
||||
auto playerBoostAssaultEntity = player.FirstChildByName("BoostAssault");
|
||||
if (playerBoostAssaultEntity.Valid()) {
|
||||
playerMovementSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"];
|
||||
playerCrouchSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"];
|
||||
}
|
||||
|
||||
|
||||
@@ -110,8 +111,8 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 40.0f : 1.0f;
|
||||
accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f);
|
||||
//if player has Boost from an Assault class, accelerate the player faster
|
||||
if (player.HasComponent("BoostAssault")) {
|
||||
accelerationSpeed *= (double)player["BoostAssault"]["StrengthOfEffect"];
|
||||
if (playerBoostAssaultEntity.Valid()) {
|
||||
accelerationSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"];
|
||||
}
|
||||
velocity += accelerationSpeed * wishDirection;
|
||||
ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
|
||||
|
||||
@@ -385,11 +385,10 @@ bool AssaultWeaponBehaviour::shoot(double damage)
|
||||
}
|
||||
|
||||
|
||||
// Do Not Check for friendly fire
|
||||
//// Check for friendly fire
|
||||
//if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) {
|
||||
// return false;
|
||||
//}
|
||||
// BoostUpdate: If friendly fire - reduce damage to 0
|
||||
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) {
|
||||
damage = 0;
|
||||
}
|
||||
|
||||
// Deal damage!
|
||||
Events::PlayerDamage ePlayerDamage;
|
||||
|
||||
Reference in New Issue
Block a user