public void ExecuteBasicAttack() { _attackType = AttackType.MELEE; _performer = TurnBasedStateMachine.ActiveCharacter; if (OpenSkillsPanel.SkillPanelEnabled) { OpenSkillsPanel.onSkillPanelToggle(); } if (_performer.Target != null) { if (_attackType == AttackType.MELEE) { _damage = _performer.Strength * _damageModifier; } else if (_attackType == AttackType.RANGED) { _damage = _performer.Accuracy * _damageModifier; } _performer.Target.CurrentHealth -= _damage; _performer.CurrentEnergy -= _energyCost; ShowCharacterStats.onUpdateHealth(); ShowCharacterStats.onUpdateEnergy(); _performer.Target.Death(); Sequence attackSequence = DOTween.Sequence(); Vector2 startPos = _performer.transform.position; Vector2 battlePos = new Vector2(0f, _performer.transform.position.y); attackSequence.Append(_performer.transform.DOMove(battlePos, 0.5f)); attackSequence.Append(_performer.transform.DOShakeScale(0.5f)); attackSequence.Append(_performer.transform.DOMove(startPos, 0.25f)); attackSequence.SetLoops(1); ShowCharacterStats.onUpdateHealth(); if (TurnBasedStateMachine.OnNextTurnEvent != null) { TurnBasedStateMachine.OnNextTurnEvent(); } } else { SaveCombatAction(); Debug.Log("Please select a target"); if (ManageTargeting.IsEnabled == false) { ManageTargeting.EnableTargets(); } else { ManageTargeting.DisableTargets(); } } }
public void ExecuteSkill() { _performer = TurnBasedStateMachine.ActiveCharacter; if (_performer.CurrentEnergy >= _energyCost) { if (_targetingType == TargetingType.SINGLE) { if (_performer.Target != null) { //if (_attackType == AttackType.MELEE) //{ // _damage = _performer.Strength * _damageModifier; //} //else if (_attackType == AttackType.RANGED) //{ // _damage = _performer.Accuracy * _damageModifier; //} CalculateDamage(); _performer.Target.CurrentHealth -= _damage; _performer.CurrentEnergy -= _energyCost; ShowCharacterStats.onUpdateHealth(); if (TurnBasedStateMachine.ActivePlayers.Contains(_performer)) { OpenSkillsPanel.onSkillPanelToggle(); ShowCharacterStats.onUpdateEnergy(); } _performer.Target.Death(); //Checks if the target died (Check is done within the Death() function) if (TurnBasedStateMachine.OnNextTurnEvent != null) { TurnBasedStateMachine.OnNextTurnEvent(); } } else { SaveCombatAction(); ManageTargeting.EnableTargets(); } } else if (_targetingType == TargetingType.ALL) { CalculateDamage(); if (TurnBasedStateMachine.ActivePlayers.Contains(_performer)) //If performer is a player character { //Target all enemies for (int i = 0; i < TurnBasedStateMachine.ActiveEnemies.Count; i++) { TurnBasedStateMachine.ActiveEnemies[i].CurrentHealth -= _damage; ShowCharacterStats.onUpdateHealth(); ShowCharacterStats.onUpdateEnergy(); TurnBasedStateMachine.ActiveEnemies[i].Death(); OpenSkillsPanel.onSkillPanelToggle(); } } if (TurnBasedStateMachine.ActiveEnemies.Contains(_performer)) //If performer is a enemy { //Target all players for (int i = 0; i < TurnBasedStateMachine.ActivePlayers.Count; i++) { TurnBasedStateMachine.ActivePlayers[i].CurrentHealth -= _damage; ShowCharacterStats.onUpdateHealth(); TurnBasedStateMachine.ActivePlayers[i].Death(); } } SaveCombatAction(); if (TurnBasedStateMachine.OnNextTurnEvent != null) { TurnBasedStateMachine.OnNextTurnEvent(); } } } }