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:
@@ -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