public void NextTurn() { battleText.gameObject.SetActive(false); FighterStats currentFighterStats = fighterStats[0]; fighterStats.Remove(currentFighterStats); if (!currentFighterStats.GetDead()) { GameObject currentUnit = currentFighterStats.gameObject; currentFighterStats.CalculateNextTurn(currentFighterStats.nextActTurn); fighterStats.Add(currentFighterStats); fighterStats.Sort(); if (currentUnit.tag == "Hero") { this.battleMenu.SetActive(true); } else { this.battleMenu.SetActive(false); string attackType = Random.Range(0, 2) == 1 ? "Melee" : "Magic"; currentUnit.GetComponent <FighterAction>().SelectAttack(attackType); } } else { NextTurn(); } }
void Start() { fighterStats = new List <FighterStats>(); GameObject hero = GameObject.FindGameObjectWithTag("Hero"); FighterStats currentHeroStats = hero.GetComponent <FighterStats>(); currentHeroStats.CalculateNextTurn(0); fighterStats.Add(currentHeroStats); GameObject enemy = GameObject.FindGameObjectWithTag("Enemy"); FighterStats currentEnemyStats = enemy.GetComponent <FighterStats>(); currentEnemyStats.CalculateNextTurn(0); fighterStats.Add(currentEnemyStats); fighterStats.Sort(); NextTurn(); }