void ProtagInputDone() { PreformList.Add(ProtagChoice); // getting rid of panel clearAttackPanel(); ProtagsToManage[0].transform.Find("Selector").gameObject.SetActive(false); ProtagsToManage.RemoveAt(0); ProtagInput = ProtagGUI.ACTIVATE; }
void Start() { currentAction = PreformAction.WAIT; EnemiesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy")); ProtagsInBattle.AddRange(GameObject.FindGameObjectsWithTag("Protag")); ProtagInput = ProtagGUI.ACTIVATE; AttackPanel.SetActive(false); EnemySelectPanel.SetActive(false); MagicPanel.SetActive(false); EnemyButtons(); }
// Update is called once per frame void Update() { switch (currentAction) { case (PreformAction.WAIT): if (PreformList.Count > 0) { currentAction = PreformAction.TAKEACTION; } break; case (PreformAction.TAKEACTION): GameObject preformer = GameObject.Find(PreformList[0].Attacker); if (PreformList[0].Type == "Enemy") { EnemyStateMachine ESM = preformer.GetComponent <EnemyStateMachine>(); for (int i = 0; i < ProtagsInBattle.Count; i++) { if (PreformList[0].AttackersTarget == ProtagsInBattle[i]) { ESM.ProtagToAttack = PreformList[0].AttackersTarget; ESM.currentState = EnemyStateMachine.TurnState.ACTION; break; } else { PreformList[0].AttackersTarget = ProtagsInBattle[Random.Range(0, ProtagsInBattle.Count)]; ESM.ProtagToAttack = PreformList[0].AttackersTarget; ESM.currentState = EnemyStateMachine.TurnState.ACTION; } } } if (PreformList[0].Type == "Protag") { ProtagStateMachine PSM = preformer.GetComponent <ProtagStateMachine>(); PSM.EnemyToAttack = PreformList[0].AttackersTarget; PSM.currentState = ProtagStateMachine.TurnState.ACTION; } currentAction = PreformAction.PREFORMACTION; break; case (PreformAction.PREFORMACTION): //idle break; case (PreformAction.CHECKALIVE): if (ProtagsInBattle.Count < 1) { currentAction = PreformAction.LOSE; } else if (EnemiesInBattle.Count < 1) { currentAction = PreformAction.WIN; } else { clearAttackPanel(); ProtagInput = ProtagGUI.ACTIVATE; } break; case (PreformAction.LOSE): { Debug.Log("You lost the Battle!"); } break; case (PreformAction.WIN): { Debug.Log("You won the Battle!"); for (int i = 0; i < ProtagsInBattle.Count; i++) { ProtagsInBattle[i].GetComponent <ProtagStateMachine>().currentState = ProtagStateMachine.TurnState.WAITING; } } break; } switch (ProtagInput) { case (ProtagGUI.ACTIVATE): if (ProtagsToManage.Count > 0) { ProtagsToManage[0].transform.Find("Selector").gameObject.SetActive(true); ProtagChoice = new HandleTurns(); AttackPanel.SetActive(true); CreateAttackButtons(); ProtagInput = ProtagGUI.WAITING; } break; case (ProtagGUI.WAITING): //idle break; case (ProtagGUI.DONE): ProtagInputDone(); break; } }
public void Input2(GameObject choosenEnemy) { ProtagChoice.AttackersTarget = choosenEnemy; ProtagInput = ProtagGUI.DONE; }