/// <summary> /// Decrease the unit's current health. /// </summary> /// <param name="decrease"> The amount to decrease the unit's health by. </param> public void DecreaseCurrentHealth() { ParticlesManager.m_Instance.RemoveUnitFromTarget(); int damage = (int)m_DealingDamage + m_TakeExtraDamage; m_Healthbar.m_KeepFocus = false; SetCurrentHealth(m_CurrentHealth - damage); m_TakeExtraDamage = 0; if (m_PassiveSkill != null) { if (m_PassiveSkill.CheckPrecondition(TriggerType.OnTakeDamage, this)) { if (m_PassiveSkill.GetAffectSelf() == true) { m_PassiveSkill.TakeEffect(this); } else { m_PassiveSkill.TakeEffect(); } } if (m_PassiveSkill.CheckPrecondition(TriggerType.OnTakeDamage)) { if (m_PassiveSkill.GetAffectSelf() == true) { m_PassiveSkill.TakeEffect(this); } else { m_PassiveSkill.TakeEffect(); } } } foreach (InflictableStatus status in m_StatusEffects) { if (status.CheckPrecondition(TriggerType.OnTakeDamage) == true) { status.TakeEffect(this); } } if (m_Healthbar != null) { m_Healthbar.m_HealthChangeIndicator.text = "-" + damage; m_HealthChangeIndicatorScript.HealthDecrease(); } }
/// <summary> /// End the current turn. /// </summary> public void EndCurrentTurn() { if (m_TeamCurrentTurn == Allegiance.Enemy) { m_TeamCurrentTurn = Allegiance.Player; } else if (m_TeamCurrentTurn == Allegiance.Player) { m_TeamCurrentTurn = Allegiance.Enemy; } Debug.Log($"============{m_TeamCurrentTurn} turn============"); UIManager.m_Instance.SwapTurnIndicator(m_TeamCurrentTurn); UIManager.m_Instance.SlideSkills(UIManager.ScreenState.Offscreen); // Play the end turn sound on the camera. //FMODUnity.RuntimeManager.PlayOneShot(m_TurnEndSound, Camera.main.transform.position); foreach (Unit unit in m_TeamCurrentTurn == Allegiance.Player ? UnitsManager.m_Instance.m_PlayerUnits : UnitsManager.m_Instance.m_ActiveEnemyUnits) { unit.SetDealExtraDamage(0); unit.ResetActionPoints(); unit.ResetCurrentMovement(); // Check the passives of all the player units for any that trigger at the start of their turn. PassiveSkill ps = unit.GetPassiveSkill(); if (ps) { if (ps.CheckPrecondition(TriggerType.OnTurnStart)) { ps.TakeEffect(unit); } } // Reduce cooldowns foreach (BaseSkill s in unit.GetSkills()) { s.DecrementCooldown(); } // Deal with inflicted statuses // So using .ToList() creates a compy of the list to iterate through // but continues romoving from the source list. Not particularly // efficient for large lists, but easy enough here. foreach (InflictableStatus status in unit.GetInflictableStatuses().ToList()) { // If returns true, status effect's duration has reached 0, remove the status effect. if (status.DecrementDuration()) { unit.RemoveStatusEffect(status); } // Otherwise do the effect else if (status.CheckPrecondition(TriggerType.OnTurnStart) == true) { status.TakeEffect(unit); } } } }