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(); } } }
void DisableSkillsPanel() { _skillPanel.gameObject.SetActive(false); if (ManageTargeting.IsEnabled) { ManageTargeting.DisableTargets(); } }
public static void SetTarget(Character target) { //Character target = GetComponent<ShowCharacterStats>().Character; ManageTargeting.DisableTargets(); TurnBasedStateMachine.ActiveCharacter.Target = target; if (CombatAction.OnTargetSelect != null) { CombatAction.OnTargetSelect(); CombatAction.OnTargetSelect = null; if (OpenSkillsPanel.SkillPanelEnabled == true) { OpenSkillsPanel.onSkillPanelToggle(); } } }
public void ToggleSkillPanel() { if (_skillPanel.gameObject.activeSelf == true) { SkillPanelEnabled = false; _openPanelTween.Kill(); _closePanelTween = _rt.DOAnchorPosX(_startPos, 0.5f).SetEase(Ease.InExpo); _closePanelTween.onComplete += DisableSkillsPanel; } else { if (ManageTargeting.IsEnabled) { ManageTargeting.DisableTargets(); } SkillPanelEnabled = true; _closePanelTween.Kill(); _skillPanel.gameObject.SetActive(true); _openPanelTween = _rt.DOAnchorPosX(_endPos, 0.5f).SetEase(Ease.OutExpo); } }
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(); } } } }