public void NextTurn() { bool won = true; bool lost = true; foreach (UnitStats unit in units) { if (unit.unitType == UnitType.Friendly) { lost = false; } if (unit.unitType == UnitType.Enemy) { won = false; } } if (won) { ui.ShowVictoryScreen(); } if (lost) { SceneMgmt.LoseFight(); } if (!won && !lost) { units.Sort(); if (units[0].turnCounter == units[1].turnCounter) { if (units[1].modAgility > units[0].modAgility) { UnitStats temp = units[0]; units[0] = units[1]; units[1] = temp; } else if (units[1].modAgility == units[0].modAgility) { if (units[1].baseAgility > units[0].baseAgility) { UnitStats temp = units[0]; units[0] = units[1]; units[1] = temp; } else if (units[1].baseAgility == units[0].baseAgility) { if (units[1].unitType == UnitType.Friendly && units[0].unitType == UnitType.Enemy) { UnitStats temp = units[0]; units[0] = units[1]; units[1] = temp; } } } } ui.UpdateTurnOrder(); /* * //Check if beat all enemies * GameObject[] remainingEnemyUnits = GameObject.FindGameObjectsWithTag ("EnemyUnit"); * if (remainingEnemyUnits.Length == 0) { * //enemyEncounter.GetComponent<CollectReward> ().GetReward (); * SceneManager.LoadScene ("Town"); * } * * //Check if game over * GameObject[] remainingPlayerUnits = GameObject.FindGameObjectsWithTag("PlayerUnit"); * if (remainingPlayerUnits.Length == 0) { * SceneManager.LoadScene ("Title"); * } */ currentUnit = units [0]; units.Remove(currentUnit); ui.UpdateActionButtons(currentUnit); if (currentUnit.gameObject.tag == "EnemyUnit") { currentUnit.enemyAI.TakeAction(); } /* * if (!currentUnitStats.IsDead ()) { * GameObject currentUnit = currentUnitStats.gameObject; * * currentUnitStats.CalculateTurnCounter (1); * units.Add (currentUnitStats); * units.Sort (); * //ui.SetTurnOrderImages(units.ToArray()); * * if (currentUnit.tag == "PlayerUnit") { * Debug.Log("Player turn!"); * //ui.DisplayActions(currentUnitStats); * WaitThenNextTurn(); * //GameObject.Find("PlayerParty").GetComponent<SelectUnit> ().SelectCurrentUnit (currentUnit.gameObject); * } * else { * //currentUnit.GetComponent<EnemyUnitAction> ().Act (); * Debug.Log("Enemy turn!"); * //ui.HideActions(); * WaitThenNextTurn(); * } * } * else { * NextTurn (); * } */ } }