public void AttackEnemy() { HidePanels(); if (!currentUnit.actionPhase) { currentUnit.FindPathThenAttack(selectedUnit.GetComponent <Unit>()); } else { currentUnit.AttackOpponent(selectedUnit.GetComponent <Unit>()); currentUnit.ResetFoundTiles(); } }
public void AttackEnemy(TacticsMove attackedEnemy) { BasePlayer enemy = attackedEnemy.GetComponent <ClassInfo>().player; BasePlayer hero = this.GetComponent <ClassInfo>().player; int damageDone = Mathf.Max(1, hero.PlayerAttack - enemy.PlayerDefense); enemy.PlayerHealth = Mathf.Max(0, enemy.PlayerHealth - damageDone); if (enemy.PlayerHealth <= 0) { BattleManager.KillUnit(attackedEnemy); Destroy(attackedEnemy.gameObject); } hasAttacked = true; }
public static void StartTurn() { if (turnTeam.Count > 0) { TacticsMove unit = turnTeam.Peek(); unit.currentlySelected = true; if (unit.CompareTag("Player")) { unit.GetComponent <PlayerMove>().SelectedClick(); } else { unit.currentlySelected = false; } unit.BeginTurn(); } }
public static void EndTurn() { TacticsMove unit = turnTeam.Dequeue(); //Debug.Log(unit.name); if (endedTurn == true) { foreach (TacticsMove u in turnTeam) { u.EndTurn(); } endedTurn = false; } unit.EndTurn(); if (unit.currentlySelected == true) { if (unit.CompareTag("Player")) { unit.currentlySelected = false; unit.GetComponent <PlayerMove>().SelectedClick(); } } if (turnTeam.Count > 0) { StartTurn(); } else { string team = turnKey.Dequeue(); turnKey.Enqueue(team); InitTeamTurnQueue(); } }