private void Awake() { //grab all the buttonBehaviours and store in a list stateManager = GetComponent <StateManager>(); moveConfirmMenu = GetComponent <MoveConfirmMenu>(); ContinueUi = GetComponent <ContinueUI>(); }
// Use this for initialization void Start() { //turn on feedback scripts FloatingTextController.DamageEnemy(); FloatingTextController.DamageAlly(); FloatingTextController.Miss(); FloatingTextController.HealEnemy(); FloatingTextController.HealAlly(); RPG.BattleManager battleManager = RPG.BattleManager.Instance; battleManager.stateManager = this; turnBehaviour = GetComponent <TurnBehaviour>(); decalUI = GetComponent <DecalUI>(); confirmMenu = GetComponent <MoveConfirmMenu>(); camMovement = GetComponent <CameraMovement>(); storeTargets = new List <Character>(); if (camera == null) { camera = Camera.main; } characters = new List <Character>(); enemies = new List <Character>(); deadCharactersREVIVE = new List <Character>(); // Activate own and enemy team from battleManager, and move enemy team into this scene battleManager.playerTeam.gameObject.SetActive(true); battleManager.enemyTeam.gameObject.SetActive(true); SceneManager.MoveGameObjectToScene(battleManager.enemyTeam.gameObject, gameObject.scene); enemyBehav = battleManager.enemyTeam.GetComponentsInChildren <EnemyBehaviour>(true); GameObject go = Instantiate(selector); selector = go; selector.SetActive(false); // move Selector into this scene SceneManager.MoveGameObjectToScene(selector, this.gameObject.scene); //game over menu stuff GameOverUI = GameObject.Find("GameOverMenu"); GameOverTextLose = GameObject.Find("LoseText"); GameOverTextWin = GameObject.Find("WinText"); GameOverUI.SetActive(false); GameOverNext.gameObject.SetActive(false); GameOverInfo.gameObject.SetActive(false); GameOverTextLose.SetActive(false); GameOverTextWin.SetActive(false); descriptionUI.gameObject.SetActive(false); //grabbing players/enemies from the scene to fill lists characters.AddRange(battleManager.playerTeam.GetComponentsInChildren <Character>(true)); //sort player list based on their choiceOrder number(so you can make it that the closest one to the screen picks first ect) List <Character> sortedList = characters.OrderBy(o => o.ChoiceOrder).ToList(); characters = sortedList; battleUIController = GetComponent <BattleUIController>(); battleUIController.UISetup(characters); //setting all characters to be inactive foreach (Character chara in characters) { chara.ActivePlayer = false; } //TODO place characters in scene positions based on this order (ie List<Transform> playerPositions and List<Transform> enemyPositions) enemies.AddRange(battleManager.enemyTeam.GetComponentsInChildren <Character>(true)); //////PLACES CHARACTERS TO PRE-SET LOCATIONS foreach (Character chara in characters) { //chara.GetComponent<ButtonBehaviour>().Setup(buttonBehaviourObjects); chara.GetComponent <TargetSelection>().Init(this.gameObject, camera); } // place player team in set positions for (int i = 0; i < playerPositions.Count && i < characters.Count; ++i) { characters[i].transform.position = playerPositions[i].position; characters[i].transform.rotation = playerPositions[i].rotation; } ////// List <Character> tmp = new List <Character>(); //when battle reentered, forces any dead characters to act like it foreach (Character chara in characters) { if (chara.Hp <= 0) { tmp.Add(chara); Death(chara, tmp); } } //moving enemies into position for (int i = 0; i < enemyPositions.Count && i < enemies.Count; ++i) { enemies[i].transform.position = enemyPositions[i].position; enemies[i].transform.rotation = enemyPositions[i].rotation; } //shows enemy ui foreach (Character enemy in enemies) { enemy.GetComponent <EnemyUI>().enemyUISetup(uiCanvas); } foreach (Character enemy in enemies) { enemy.GetComponent <EnemyUI>().ShowUI(); } turnBehaviour.Setup(characters, enemies); result = EBattleResult.Flee; // initialize XP to 0 xpEarned = 0; //starting game loops StartCoroutine(GameLoop()); }