// Use this for initialization
 void Start()
 {
     _rc = FindObjectOfType<RoachController> ();
     _hero = FindObjectOfType<HeroStateMachine> ();
     _crystals = FindObjectsOfType<DomeCrystal>();
     _dsc = FindObjectOfType<DomeStateController> ();
 }
Пример #2
0
    // Update is called once per frame
    private void Update()
    {
        switch (battleState)
        {
        case PerformAction.Waiting:
            if (actions.Count > 0)
            {
                battleState = PerformAction.PrepareAction;
            }
            break;

        case PerformAction.PrepareAction:
            BattleAction action = actions[0];

            GameObject performer = action.attackerGameObject;
            if (action.attackerType == BattleAction.ToonType.Enemy)
            {
                EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine>();
                esm.heroToAttack = action.defenderGameObject;
                esm.currentState = EnemyStateMachine.TurnState.PerformAction;
            }
            else     // if hero
            {
                HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>();
                hsm.enemyToAttack = action.defenderGameObject;
                hsm.currentState  = HeroStateMachine.TurnState.PerformAction;
            }

            battleState = PerformAction.PerformAction;
            break;

        case PerformAction.PerformAction:
            // idle
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        switch (HeroInput)
        {
        case HeroGui.Activate:
            if (heroesToManage.Count > 0)
            {
                // heroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                heroesToManage[0].GetComponent <HeroStateMachine>().Selector.SetActive(true);

                AttackPanel.SetActive(true);
                HeroInput = HeroGui.Waiting;
            }
            break;

        case HeroGui.Waiting:
            // idle;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        switch (battleStates)
        {
        case (PerformAction.WAIT):
            if (performList.Count > 0)
            {
                battleStates = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = GameObject.Find(performList[0].attacker);
            if (performList[0].type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                ESM.targetToAttack = performList[0].targetOfAttacker;
                ESM.currentState   = EnemyStateMachine.TurnState.ACTION;
            }
            if (performList[0].type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.targetToAttack = performList[0].targetOfAttacker;
                HSM.currentState   = HeroStateMachine.TurnState.ACTION;
            }
            battleStates = PerformAction.PERFORMACTION;
            break;

        case (PerformAction.PERFORMACTION):

            break;
        }

        switch (heroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (heroesToManage.Count > 0)
            {
                heroesToManage[0].transform.FindChild("Selector").gameObject.SetActive(true);
                heroChoice = new TurnHandler();
                attackPanel.SetActive(true);
                heroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):
            //idle
            break;

        case (HeroGUI.DONE):
            heroInputDone();
            break;
        }
    }
    void Update()
    {
        switch (battleStates)
        {
        case (PerformAction.Wait):
            if (PerformList.Count > 0)
            {
                battleStates = PerformAction.ActionTake;
            }
            break;

        case (PerformAction.ActionTake):
            GameObject performer = PerformList[0].AttacksGameObject;
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                ESM.HeroToAttack = PerformList[0].AttackersTarget;
                ESM.currentState = EnemyStateMachine.TurnState.Action;
            }
            if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.EnemyToAttack = PerformList[0].AttackersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.Action;
            }
            battleStates = PerformAction.ActionPerform;
            break;

        case (PerformAction.ActionPerform):
            //Idle
            break;
        }

        switch (HeroInput)
        {
        case (HeroGUI.Activate):
            if (HeroesToManage.Count > 0)
            {
                //FIXME HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoice = new HandleTurn();
                attackPanel.SetActive(true);
                HeroInput = HeroGUI.Wait;
            }
            break;

        case (HeroGUI.Wait):
            //Idle
            break;

        case (HeroGUI.Done):
            HeroInputDone();
            break;
        }
    }
Пример #5
0
    public void InputEnemy(GameObject enemySelected)
    {
        HeroStateMachine hsm = HeroSelected.GetComponent <HeroStateMachine>();

        hsm.MakeNewAction(enemySelected);
        hsm.Selector.SetActive(false);

        heroesToManage.RemoveAt(0);

        EnemySelectPanel.SetActive(false);
        HeroInput = HeroGui.Activate;
    }
    void HeroButtons()
    {
        foreach (GameObject hero in HeroesInBattle)
        {
            GameObject       newButton = Instantiate(heroButton) as GameObject;
            HeroSelectButton button    = newButton.GetComponent <HeroSelectButton>();

            HeroStateMachine cur_hero = hero.GetComponent <HeroStateMachine>();

            Text buttonText = newButton.transform.Find("Text").gameObject.GetComponent <Text>();
            buttonText.text = cur_hero.hero.theName;

            button.HeroPrefab = hero;

            newButton.transform.SetParent(Spacer2, false);
        }
    }
Пример #7
0
    // Update is called once per frame
    void Update()
    {
        currentState = Hero.GetComponent <HeroStateMachine>();
        battleState  = BattleManager.GetComponent <BattleStateMachine>();


        if (currentState.currentState == HeroStateMachine.TurnState.Action)
        {
            anim.SetTrigger("Attack");
        }

        if (currentState.currentState == HeroStateMachine.TurnState.Processing || currentState.currentState == HeroStateMachine.TurnState.Waiting)
        {
            anim.SetTrigger("Stationary");
        }

        if (battleState.battlestates == BattleStateMachine.PerformAction.Win)
        {
            anim.SetTrigger("Victory");
        }
    }
Пример #8
0
    void HeroButtons()
    {
        foreach (GameObject hero in HeroesInBattle)
        {
            if (hero.tag != "DeadHero")
            {
                GameObject       targetButton = Instantiate(heroButton) as GameObject;
                HeroSelectButton button       = targetButton.GetComponent <HeroSelectButton>();

                HeroStateMachine cur_Hero = hero.GetComponent <HeroStateMachine>();

                Text targetButtonText = targetButton.transform.Find("Text").gameObject.GetComponent <Text>();
                targetButtonText.text = cur_Hero.hero.characterName;

                button.HeroPrefab = hero;

                TargetButtons.Add(targetButton);

                targetButton.transform.SetParent(TargetPanelSpacer, false);
            }
        }
    }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        switch (battleStates)
        {
        case (PerformAction.WAIT):
            if (PerformList.Count > 0)
            {
                battleStates = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = GameObject.Find(PerformList[0].Attacker);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (PerformList[0].AttackersTarget == HerosInBattle[i])
                    {
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }
            if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.EnemyToAttack = PerformList[0].AttackersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.ACTION;
            }
            battleStates = PerformAction.PERFORMACTION;
            break;

        case (PerformAction.PERFORMACTION):

            break;

        case (PerformAction.CHECKALIVE):
            if (HerosInBattle.Count < 1)
            {
                battleStates = PerformAction.LOSE;
            }
            else if (EnemysInBattle.Count < 1)
            {
                battleStates = PerformAction.WIN;
            }
            else
            {
                clearAttackPanel();
                //call a function
                HeroInput = HeroGUI.ACTIVATE;
            }

            break;

        case (PerformAction.LOSE):
        {
            Debug.Log("YOU LOST!");
        }
        break;

        case (PerformAction.WIN):
        {
            Debug.Log("YOU WON!");
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
            }

            GameManager.instance.LoadSceneAfterBattle();
            GameManager.instance.gameState = GameManager.GameStates.WORLD_STATE;
            GameManager.instance.enemysToBattle.Clear();
        }
        break;
        }
        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (HerosToManage.Count > 0)
            {
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoice = new HandleTurn();

                AttackPanel.SetActive(true);

                CreateAttackbuttons();
                HeroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):

            break;

        case (HeroGUI.DONE):
            HeroInputDone();
            break;
        }
    }
Пример #10
0
    // Update is called once per frame
    void Update()
    {
        switch (battleState)
        {
        //truong hop battle dang trong trang thai wait
        case PerformAction.WAIT:
            //neu list hanh dong can thuc hien > 0
            if (PerformList.Count > 0)
            {
                //chuyen trang thai ve tackeaction
                battleState = PerformAction.TAKEACTION;
            }
            break;

        //truong hop battle dang trong trang thai takeaction
        case PerformAction.TAKEACTION:
            //tim gameobject co ten la ten phan tu dau tien trong list thuc hien
            GameObject performer = GameObject.Find(PerformList[0].attacker);
            //neu ng thuc hien thuoc type monster
            if (PerformList[0].type == "Monster")
            {
                //get component MSM cua no
                MonsterStateMachine MSM = performer.GetComponent <MonsterStateMachine>();

                MSM.playerToAttack = PerformList[0].AttackersTarget;
                //chuyen trang thai cua monster sang action
                MSM.currentState = MonsterStateMachine.TurnState.ACTION;
            }
            else if (PerformList[0].type == "Player")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.enemyToAttack = PerformList[0].AttackersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.ACTION;
            }
            //chuyen trang thai cua battle sang perform action
            battleState = PerformAction.PERFORMACTION;
            break;

        case PerformAction.PERFORMACTION:
            break;
        }

        switch (playerInput)
        {
        case PlayerGUI.ACTIVATE:
            //neu player quan li > 0
            if (PlayerToManager.Count > 0)
            {
                //tim gameobject selector va set active = true
                PlayerToManager[0].transform.Find("selector").gameObject.SetActive(true);
                //tao moi 1 handler turn
                playerChoice = new HandleTurn();
                //hien thi attack panel
                AttackPanel.SetActive(true);
                //chuyen trang thai playerGUI ve waiting
                playerInput = PlayerGUI.WAITING;
            }
            break;

        case PlayerGUI.WAITING:
            break;

        case PlayerGUI.DONE:
            //thuc hien ham PlayerInputDone()
            PlayerInputDone();
            break;
        }
    }
Пример #11
0
    // Update is called once per frame
    void Update()
    {
        switch (battleStates)
        {
        case (PerformAction.WAIT):
            if (performList.Count > 0)
            {
                battleStates = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = GameObject.Find(performList[0].attacker);
            if (performList[0].type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < playersInBattle.Count; i++)
                {
                    if (performList[0].targetOfAttacker == playersInBattle[i])
                    {
                        ESM.targetToAttack = performList[0].targetOfAttacker;
                        ESM.currentState   = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        performList[0].targetOfAttacker = playersInBattle[Random.Range(0, playersInBattle.Count)];
                        ESM.targetToAttack = performList[0].targetOfAttacker;
                        ESM.currentState   = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }
            if (performList[0].type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.targetToAttack = performList[0].targetOfAttacker;
                HSM.currentState   = HeroStateMachine.TurnState.ACTION;
            }
            battleStates = PerformAction.PERFORMACTION;
            break;

        case (PerformAction.PERFORMACTION):
            //idle state
            break;

        case (PerformAction.CHECKALIVE):
            if (playersInBattle.Count < 1)
            {
                battleStates = PerformAction.LOSE;
            }
            else if (enemiesInBattle.Count < 1)
            {
                battleStates = PerformAction.WIN;
            }
            else
            {
                ClearAttackPanel();
                heroInput = HeroGUI.ACTIVATE;
            }
            break;

        case (PerformAction.WIN):
            Debug.Log("You have won the battle!");
            for (int i = 0; i < playersInBattle.Count; i++)
            {
                playersInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
            }
            winPanel.SetActive(true);
            break;

        case (PerformAction.LOSE):
            Debug.Log("You have died.");
            break;
        }

        switch (heroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (heroesToManage.Count > 0)
            {
                heroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                heroChoice = new TurnHandler();
                actionPanel.SetActive(true);
                CreateAttackButtons();
                heroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):
            //idle
            break;

        case (HeroGUI.DONE):
            heroInputDone();
            break;
        }
    }
    // Update is called once per frame
    void Update()
    {
        switch (battleStates)
        {
        case (PerformAction.WAIT):
            if (PerformList.Count > 0)
            {
                battleStates = PerformAction.TAKEACTION;
            }
            if (HerosInBattle.Count < 1 || EnemysInBattle.Count < 1)
            {
                battleStates = PerformAction.CHECKALIVE;
            }
            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = GameObject.Find(PerformList [0].Attacker);

            if (PerformList[0].Type == "Hero")
            {
                if (EnemysInBattle.Count != 0)
                {
                    HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>();
                    hsm.EnemyToAttack = PerformList[0].AttackersTarget;
                    hsm.currentState  = HeroStateMachine.TurnState.ACTION;
                }
            }
            if (PerformList [0].Type == "Enemy")
            {
                Debug.Log(PerformList[0].Attacker);
                EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine> ();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (HerosInBattle.Count == 0 || esm.EnemyStats.curHP <= 0)
                    {
                        break;
                    }
                    else if (PerformList[0].AttackersTarget == HerosInBattle[i])
                    {
                        esm.HeroToAttack = PerformList[0].AttackersTarget;
                        esm.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        esm.HeroToAttack = PerformList[0].AttackersTarget;
                        esm.currentState = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }
            battleStates = PerformAction.PERFORMACTION;
            break;

        case (PerformAction.PERFORMACTION):

            break;

        case (PerformAction.CHECKALIVE):
            if (HerosInBattle.Count < 1)
            {
                battleStates = PerformAction.LOSE;
                // lose game
            }
            else if (EnemysInBattle.Count < 1)
            {
                battleStates = PerformAction.WIN;
                // win game
            }
            else
            {
                clearAttackPanel();
                HeroInput = HeroGUI.ACTIVATE;
                //call function
            }
            break;

        case (PerformAction.LOSE):
        {
            if (Input.GetMouseButtonDown(0) || Input.GetTouch(0).phase == TouchPhase.Began)
            {
                clicksCount++;
            }
            Debug.Log("You lost the Battle");
            //Defeat.SetActive(true);
            if (clicksCount == 1)
            {
                audioManager.GameOver();
                EndBattlePanel.transform.FindChild("Text").GetComponent <Text>().text = "You lost the Battle";
                EndBattlePanel.SetActive(true);
            }
            if (clicksCount == 2)
            {
                SceneManager.LoadScene(0);
            }
        }

        break;

        case (PerformAction.WIN):
        {
            if (Input.GetMouseButtonDown(0) || Input.GetTouch(0).phase == TouchPhase.Began)
            {
                clicksCount++;
            }
            Debug.Log("You won the Battle");
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
            }
            if (clicksCount == 1)
            {
                En.GetComponent <EnemyStateMachine>().EnemyStats.timesDefeated++;
                audioManager.GameWin();
                EndBattlePanel.transform.FindChild("Text").GetComponent <Text>().text = "You won the Battle\n" + "You earned:\n " + En.GetComponent <EnemyStateMachine>().EnemyStats.coinsToGive + " coins\n" + En.GetComponent <EnemyStateMachine>().EnemyStats.expToGive + " expierence";
                EndBattlePanel.SetActive(true);
            }

            if (!expadd && clicksCount == 2)
            {
                EndBattlePanel.transform.FindChild("Text").GetComponent <Text>().text = "Click again to end the battle\n";
                GameManager.instance.Player.GetComponent <Player>().coins            += En.GetComponent <EnemyStateMachine>().EnemyStats.coinsToGive;
                IncreaseExp.AddExperience(En.GetComponent <EnemyStateMachine>().EnemyStats.expToGive);
                expadd = true;
                GameObject.Find("GameManager(Clone)").GetComponent <GameManager>().saveData();
                //levelUpText(0);
            }
            if (clicksCount == 3)
            {
                SceneManager.LoadScene(0);
            }
        }
        break;
        }

        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (HeroesToManage.Count > 0)
            {
                HeroesToManage [0].transform.FindChild("Selector").gameObject.SetActive(true);
                HeroChoise = new HandleTurns();
                ActionPanel.SetActive(true);
                CreateAttackButtons();
                HeroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):

            break;

        case (HeroGUI.DONE):
            HeroInputDone();
            break;
        }
    }
 // Use this for initialization
 void Start()
 {
     _hero = FindObjectOfType<HeroStateMachine> ();
     _crystals = FindObjectsOfType<DomeCrystal>();
     _bubbles = FindObjectsOfType<LightBubble>();
 }
    // Update is called once per frame
    private void Update()
    {
        if (PerformList.Count == charactersCount)
        {
            ExecutePerformList = new List <HandleTurn>(PerformList);
            SortTurnOrder(ExecutePerformList);
            PerformList.Clear();
        }//*/

        switch (BattleStates)
        {
        case (PerformAction.WAIT):
        {
            // if at least one character has
            // pushed action data to turn list
            if (ExecutePerformList.Count > 0)
            {
                BattleStates = PerformAction.TAKEACTION;
                Debug.Log("TAKEACTION started");
            }
            break;
        }

        case (PerformAction.TAKEACTION):
        {
            GameObject performer = GameObject.Find(ExecutePerformList[0].Attacker);

            if (ExecutePerformList[0].Type == "Enemy")
            {
                EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine>();
                esm.HeroToAttack = ExecutePerformList[0].AttackersTarget;
                esm.CurrentState = EnemyStateMachine.TurnState.ACTION;
            }
            if (ExecutePerformList[0].Type == "Hero")
            {
                HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>();
                hsm.EnemyToAttack = ExecutePerformList[0].AttackersTarget;
                hsm.CurrentState  = HeroStateMachine.TurnState.ACTION;
            }

            BattleStates = PerformAction.PERFORMACTION;

            break;
        }

        case (PerformAction.PERFORMACTION):
        {
            // placeholder state while
            // characters perform action
            // Resets to WAIT
            // when action is completed
            break;
        }
        }   // switch (BattleStates)

        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
        {
            if (HerosToManage.Count > 0 && ExecutePerformList.Count == 0)
            {
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                heroChoice = new HandleTurn();
                AttackPanel.SetActive(true);
                HeroInput = HeroGUI.WAITING;
            }
            break;
        }

        case (HeroGUI.WAITING):
        {
            // idle state

            break;
        }

        case (HeroGUI.INPUT1):
        {
            // not used yet
            break;
        }

        case (HeroGUI.INPUT2):
        {
            // not used yet
            break;
        }

        case (HeroGUI.DONE):
        {
            HeroInputDone();
            break;
        }
        } // switch (HeroInput)
    }     // void Update()
Пример #15
0
    // Update is called once per frame
    void Update()
    {
        if (Gamemanager.instance.detectE == true)
        {
            enemysinBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy"));
            characterInput = characterGUI.activate;
            attackPanel.SetActive(false);
            EnemySelect.SetActive(false);
            SkillsPanel.SetActive(false);
            EnemyButtons();
            Gamemanager.instance.noEnemys = false;
            Gamemanager.instance.detectE  = false;
        }

        switch (battlestates)
        {
        case (performAction.wait):
            if (PerformList.Count > 0)
            {
                battlestates = performAction.takeaction;
            }
            break;

        case (performAction.takeaction):
            GameObject performer = GameObject.Find(PerformList [0].attacker);
            if (PerformList [0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine> ();
                for (int i = 0; i < charactersinBattle.Count; i++)
                {
                    if (PerformList [0].attackersTarget == charactersinBattle [i])
                    {
                        ESM.charactertoattack = PerformList [0].attackersTarget;
                        ESM.currentState      = EnemyStateMachine.TurnState.action;
                        break;
                    }
                    else
                    {
                        PerformList[0].attackersTarget = charactersinBattle[Random.Range(0, charactersinBattle.Count)];
                        ESM.charactertoattack          = PerformList [0].attackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.action;
                    }
                }
            }
            if (PerformList [0].Type == "Player c")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine> ();
                HSM.enemytoAttack = PerformList [0].attackersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.action;
            }
            battlestates = performAction.performaction;
            break;

        case (performAction.performaction):
            //idle
            break;

        case (performAction.checkAlive):
            if (charactersinBattle.Count < 1)
            {
                battlestates = performAction.lose;
                //lose
            }
            else if (enemysinBattle.Count < 1)
            {
                Gamemanager.instance.noEnemys = true;
                battlestates = performAction.win;
                //win
            }
            else
            {
                clearAttackPanel();
                characterInput = characterGUI.activate;
                battlestates   = performAction.wait;
            }
            break;

        case (performAction.lose):
        {
            Debug.Log("lose");
        }
        break;

        case (performAction.win):
        {
            Debug.Log("win");
            for (int i = 0; i < charactersinBattle.Count; i++)
            {
                charactersinBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.waiting;
            }
            battlestates = performAction.wait;
        }
        break;
        }
        switch (characterInput)
        {
        case (characterGUI.activate):
            if (charactersToManage.Count > 0)
            {
                characterChoise = new HandleTurn();

                attackPanel.SetActive(true);

                CreateAttackButtons();
                characterInput = characterGUI.waiting;
            }
            break;

        case (characterGUI.waiting):
            //Idle
            break;

        case (characterGUI.done):
            characterInputDone();
            break;
        }
    }
Пример #16
0
    // Update is called once per frame
    void Update()
    {
        switch (BattleStates)
        {
        case (PerformAction.Wait):
            if (PerformList.Count > 0)
            {
                BattleStates = PerformAction.TakeAction;
            }

            break;

        case (PerformAction.TakeAction):
            GameObject performer = GameObject.Find(PerformList[0].Attacker);
            if (PerformList[0].type == "enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                ESM.HeroToAttack = PerformList[0].AttackersTarget;
                ESM.CurrentState = EnemyStateMachine.Turnstate.Action;
            }

            if (PerformList[0].type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.EnemyToAttack = PerformList[0].AttackersTarget;
                HSM.CurrentState  = HeroStateMachine.Turnstate.Action;
            }

            BattleStates = PerformAction.PerformAction;


            break;

        case (PerformAction.PerformAction):

            break;
        }


        switch (HeroInput)
        {
        case (HeroGUI.Activate):
            if (HerosToManage.Count > 0)
            {
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoice = new HandleTurns();
                AttackPanel.SetActive(true);


                HeroInput = HeroGUI.Waiting;
            }


            break;

        case (HeroGUI.Waiting):


            break;

        case (HeroGUI.Done):

            HeroInputDone();
            break;
        }
    }
Пример #17
0
    // Update is called once per frame
    void Update()
    {
        switch (battleStates)
        {
        case (PerformAction.WAIT):
            if (PerformList.Count > 0)
            {
                battleStates = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = PerformList[0].AttackersGameObject;
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();

                ESM.Target       = PerformList[0].AttackersTarget;
                ESM.currentState = EnemyStateMachine.TurnState.ACTION;
            }

            if (PerformList[0].Type == "Hero")
            {
                HSM              = performer.GetComponent <HeroStateMachine>();
                HSM.Target       = PerformList[0].AttackersTarget;
                HSM.currentState = HeroStateMachine.TurnState.ACTION;
            }

            foreach (GameObject unit in EnemiesInBattle)
            {
                if (unit.tag != "DeadEnemy")
                {
                    unit.GetComponent <EnemyStateMachine>().ApplyDotDamage();
                }
            }

            foreach (GameObject unit in HeroesInBattle)
            {
                if (unit.tag != "DeadHero")
                {
                    unit.GetComponent <HeroStateMachine>().ApplyDotDamage();
                }
            }

            battleStates = PerformAction.PERFORMACTION;
            break;

        case (PerformAction.PERFORMACTION):
            //idle
            break;
        }

        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (HeroesToManage.Count > 0 && PerformList.Count == 0)
            {
                HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoice = new HandleTurn();

                ActionPanel.SetActive(true);

                //populate action buttons
                CreateActionButtons();

                HeroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):
            //idle
            break;

        case (HeroGUI.DONE):
            HeroInputDone();
            break;
        }

        if (EnemiesAlive == 0 && battleStarted == true && BattleOver == false)
        {
            GameObject.Find("WorldState").GetComponent <WorldState>().PlayVictoryMusic();
            EndingText.text = "Victory!";
            EndBattleButton.SetActive(true);
            ActionPanel.SetActive(false);
            TargetSelectPanel.SetActive(false);
            HSM = null;
            HeroesToManage.Clear();
            battleStates = PerformAction.WAIT;
            HeroInput    = HeroGUI.WAITING;
            performer    = null;
            //clean actionpanel
            foreach (GameObject ActionButton in ActionButtons)
            {
                Destroy(ActionButton);
            }
            ActionButtons.Clear();

            foreach (GameObject targetButton in TargetButtons)
            {
                Destroy(targetButton);
            }
            TargetButtons.Clear();

            GameObject.Find("WorldState").GetComponent <WorldState>().heroVictory = true;

            BattleOver = true;
        }

        if (HeroesAlive == 0 && battleStarted == true && BattleOver == false)
        {
            GameObject.Find("WorldState").GetComponent <WorldState>().PlayDefeatMusic();
            EndingText.text = "Defeat";
            EndBattleButton.SetActive(true);
            ActionPanel.SetActive(false);
            TargetSelectPanel.SetActive(false);
            HSM = null;
            HeroesToManage.Clear();
            battleStates = PerformAction.WAIT;
            HeroInput    = HeroGUI.WAITING;
            performer    = null;
            //clean actionpanel
            foreach (GameObject ActionButton in ActionButtons)
            {
                Destroy(ActionButton);
            }
            ActionButtons.Clear();

            foreach (GameObject targetButton in TargetButtons)
            {
                Destroy(targetButton);
            }
            TargetButtons.Clear();

            GameObject.Find("WorldState").GetComponent <WorldState>().heroVictory = false;
            BattleOver = true;
        }

        if (CharacterBarsCreated == true)
        {
            UpdateCharacterBars();
        }
    }
    void FixedUpdate()
    {
        switch (battleStates)
        {
        case (PerformAction.Wait):
            if (PerformList.Count > 0)
            {
                battleStates = PerformAction.TakeAction;
            }
            break;

        case (PerformAction.TakeAction):
            GameObject performer = GameObject.Find(PerformList[0].Attacker);
            if (PerformList[0].Type == "Enemy")
            {
                StartCoroutine(AiWait());

                /* EnemyStateMachine ESM = performer.GetComponent<EnemyStateMachine>();
                 * ESM.HeroToAttack = PerformList[0].AttackersTarget;
                 * ESM.currentState = EnemyStateMachine.TurnState.Action;*/
            }
            if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.EnemyToAttack = PerformList[0].AttackersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.Action;
            }
            battleStates = PerformAction.PerformAction;
            break;

        case (PerformAction.PerformAction):

            break;

        case (PerformAction.Checkalive):
            if (HeroesInBattle.Count < 1)
            {
                battleStates = PerformAction.Lose;
            }

            else if (EnemiesInBattle.Count < 1)
            {
                battleStates = PerformAction.Win;
            }
            else
            {
                clearActionPanel();
                HeroInput = HeroGui.Activate;
            }
            break;

        case (PerformAction.Win):
        {
            Time.timeScale = 1f;
            if (!victoryBool)
            {
                Instantiate(VictoryTextPrefab);
                goBackButton.SetActive(true);
                victoryBool = true;
                Debug.Log("victoryBool = " + victoryBool);
            }

            Debug.Log("You win");
            for (int i = 0; i < HeroesInBattle.Count; i++)
            {
                HeroesInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.Waiting;
                //int tempshit = i + 1;
                //string heroValue = "Hero" + tempshit.ToString() + "HP";
                //Debug.Log (heroValue);
                //float hpTemp = PlayerPrefs.GetFloat (heroValue);
                //float hpTemp = HeroesInBattle[i].GetComponent<BaseHero>().curHP;
                //PlayerPrefs.SetFloat (heroValue, hpTemp);
            }
        }
        break;

        case (PerformAction.Lose):
        {
            Time.timeScale = 1f;
            if (!loseBool)
            {
                Instantiate(LoseTextPrefab);
                goBackButton.SetActive(true);
                loseBool = true;
            }
            Debug.Log("You lose");
        }
        break;
        }

        switch (HeroInput)
        {
        case (HeroGui.Activate):
            if (HeroesToManage.Count > 0)
            {
                //Time.timeScale = 0.3f;
                HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoise = new HandleTurn();
                ActionPanel.SetActive(true);
                //populate buttons
                CreateAttackButtons();
                HeroInput = HeroGui.Waiting;
            }
            break;

        case (HeroGui.Waiting):

            break;

        case (HeroGui.Done):
            HeroInputDone();
            break;
        }
    }
    // Update is called once per frame
    void Update()
    {
        switch (battleStates)
        {
        case (PerformAction.WAIT):
            if (PerformList.Count > 0)
            {
                battleStates = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = PerformList[0].AttackersGameObject;
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (PerformList[0].AttackersTarget == HerosInBattle[i])
                    {
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }
            if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.EnemyToAttack = PerformList[0].AttackersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.ACTION;
            }
            battleStates = PerformAction.PERFORMACTION;
            break;

        case (PerformAction.PERFORMACTION):
            //idle
            break;

        case (PerformAction.CHECKALIVE):
            if (HerosInBattle.Count < 1)
            {
                battleStates = PerformAction.LOSE;
                //lose game
            }
            else if (gameManager.enemiesToBattle.Count < 1)
            {
                battleStates = PerformAction.WIN;     //win game
            }
            else
            {
                //call function
                clearAttackPanel();
                HeroInput = HeroGUI.ACTIVATE;
            }
            break;

        case (PerformAction.LOSE):
        {
            SceneManager.LoadScene(1);
        }
        break;

        case (PerformAction.WIN):
        {
            SceneManager.LoadScene(2);
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
            }
        }
        break;
        }

        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (HerosToManage.Count > 0)
            {
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                //create new handleturn instance
                HeroChoice = new HandleTurn();

                AttackPanel.SetActive(true);
                //populate action buttons
                CreateAttackButtons();

                HeroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):

            break;

        case (HeroGUI.DONE):
            HeroInputDone();
            break;
        }
    }
Пример #20
0
    // Update is called once per frame
    void Update()
    {
        switch (BattleStates)
        {
        case (PerformAction.Wait):
            if (PerformList.Count > 0)
            {
                BattleStates = PerformAction.TakeAction;
            }
            break;

        case (PerformAction.TakeAction):
            GameObject performer = GameObject.Find(PerformList[0].Attacker);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (PerformList[0].AttackersTarget == HerosInBattle[i])
                    {
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.Action;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.Action;
                    }
                }
            }
            if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.EnemyToAttack = PerformList[0].AttackersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.Action;
            }
            BattleStates = PerformAction.PerformAction;
            break;

        case (PerformAction.PerformAction):
            //idle
            break;

        case (PerformAction.CheckAlive):
            if (HerosInBattle.Count < 1)
            {
                BattleStates = PerformAction.Lose;
                //lose the battle
            }
            else if (EnemysInBattle.Count < 1)
            {
                BattleStates = PerformAction.Win;
                //win the battle
            }
            else
            {
                ClearAttackPanel();
                //call function
                HeroInput = HeroGUI.Activate;
            }
            break;

        case (PerformAction.Lose):
        {
            Debug.Log("KAYBETTİN");
        }
        break;

        case (PerformAction.Win):
        {
            Debug.Log("KAZANDIN");
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.Waiting;
            }
            GameManager.instance.LoadSceneAfterBattle();
            GameManager.instance.gameStates = GameManager.GameStates.World_State;
            GameManager.instance.enemysToBattle.Clear();
        }
        break;
        }
        switch (HeroInput)
        {
        case (HeroGUI.Activate):
            if (HerosToManage.Count > 0)
            {
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                //create new handleturn instance
                HeroChoise = new HandleTurn();

                AttackPanel.SetActive(true);
                //populate action buttons
                CreateAttackButtons();
                HeroInput = HeroGUI.Waiting;
            }
            break;

        case (HeroGUI.Waiting):

            break;

        case (HeroGUI.Done):
            HeroInputDone();
            break;
        }
    }
    // Update is called once per frame
    void Update()
    {
        switch (battleStates)
        {
        case (PerformAction.WAIT):
        {
            if (PerformList.Count > 0)
            {
                battleStates = PerformAction.TAKEACTION;
            }

            break;
        }

        case (PerformAction.TAKEACTION):
        {
            GameObject performer = GameObject.Find(PerformList[0].Attacker);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (PerformList[0].AttackersTarget == HerosInBattle[i])
                    {
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }
            if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.EnemyToAttack = PerformList[0].AttackersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.ACTION;
            }
            battleStates = PerformAction.PERFORMACTION;
            break;
        }

        case (PerformAction.PERFORMACTION):
        {
            break;
        }

        case (PerformAction.CHECKALIVE):
        {
            if (HerosInBattle.Count < 1)
            {
                battleStates = PerformAction.LOSE;
                //lose game
            }
            else if (EnemysInBattle.Count < 1)
            {
                battleStates = PerformAction.WIN;
                //win game
            }
            else
            {
                ClearAttackPanel();
                HeroInput = HeroGUI.ACTIVATE;
            }

            break;
        }

        case (PerformAction.WIN):
        {
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
            }

            break;
        }

        case (PerformAction.LOSE):
        {
            break;
        }
        }

        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
        {
            HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
            HeroChoice = new HandleTurn();
            AttackPanel.SetActive(true);
            CreateAttackButtons();
            HeroInput = HeroGUI.WAITING;

            break;
        }

        case (HeroGUI.WAITING):
        {
            break;
        }

        case (HeroGUI.DONE):
        {
            HeroInputDone();

            break;
        }
        }
    }
Пример #22
0
    // Update is called once per frame
    void Update()
    {
        switch (battleState)
        {
        case PerformAction.WAIT:
            if (performList.Count > 0)
            {
                battleState = PerformAction.TAKEACTION;
            }
            break;

        case PerformAction.TAKEACTION:
            GameObject performer = GameObject.Find(performList[0].attacker);
            if (performList[0].type == "Enemy")
            {
                EnemyStateMachine enemySM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < heroesInBattle.Count; i++)
                {
                    if (performList[0].targetGameObject == heroesInBattle[i])
                    {
                        enemySM.actionTarget = performList[0].targetGameObject;
                        enemySM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        performList[0].targetGameObject = heroesInBattle[Random.Range(0, heroesInBattle.Count)];
                        enemySM.actionTarget            = performList[0].targetGameObject;
                        enemySM.currentState            = EnemyStateMachine.TurnState.ACTION;
                    }
                }
                battleState = PerformAction.PERFORMACTION;
            }
            if (performList[0].type == "Hero")
            {
                HeroStateMachine heroSM = performer.GetComponent <HeroStateMachine>();
                heroSM.actionTarget = performList[0].targetGameObject;
                if (heroSM.currentState != HeroStateMachine.TurnState.DEAD)
                {
                    heroSM.currentState = HeroStateMachine.TurnState.ACTION;
                    battleState         = PerformAction.PERFORMACTION;
                }
                else
                {
                    performList.Remove(performList[0]);
                    battleState = PerformAction.CHECKALIVE;
                }
            }
            break;

        case PerformAction.PERFORMACTION:
            //idle
            break;

        case PerformAction.CHECKALIVE:
            if (heroesInBattle.Count < 1)
            {
                battleState = PerformAction.LOSE;
            }
            else if (enemiesInBattle.Count < 1)
            {
                battleState = PerformAction.WIN;
            }
            else
            {
                ClearAttackPanel();
                heroInput = HeroGUI.ACTIVATE;
            }
            break;

        case PerformAction.WIN:
            for (int i = 0; i < heroesInBattle.Count; i++)
            {
                heroesInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
            }

            resultScreen.GetComponentInChildren <Text>().text = "YOU WIN";
            resultScreen.SetActive(true);

            StartCoroutine(WinBattle());
            break;

        case PerformAction.LOSE:
            resultScreen.GetComponentInChildren <Text>().text = "YOU LOSE";
            resultScreen.SetActive(true);

            StartCoroutine(LoseBattle());
            break;
        }

        switch (heroInput)
        {
        case HeroGUI.ACTIVATE:
            if (heroesToManage.Count > 0)
            {
                heroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                heroChoice = new HandleTurn();

                actionPanel.SetActive(true);
                backPanel.SetActive(false);
                CreateAttackButtons();

                heroInput = HeroGUI.WAITING;
            }
            break;

        case HeroGUI.WAITING:
            //idle
            break;

        case HeroGUI.DONE:
            HeroInputDone();
            break;
        }
    }
Пример #23
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(battleStates);
        switch (battleStates)
        {
        case (PerformAction.WAIT):
            if (performList.Count > 0)
            {
                battleStates = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            //get attacker and the name of the attacker
            GameObject performer = performList[0].attacksGameObject; //target list

            if (performList[0].type == "Enemy")                      //who is going to this animation
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                //checking is currently attacked hero is in battle
                for (int i = 0; i < heroesInBattle.Count; i++)
                {
                    //checking attacker target same with hero in battle
                    if (performList[0].attackersTarget == heroesInBattle[i])
                    {
                        ESM.heroToAttack = performList[0].attackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        //prevent attack on dead hero
                        performList[0].attackersTarget = heroesInBattle[UnityEngine.Random.Range(0, heroesInBattle.Count)];
                        ESM.heroToAttack = performList[0].attackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }

            if (performList[0].type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.enemyToAttack = performList[0].attackersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.ACTION;
            }

            battleStates = PerformAction.PERFORMACTION;

            break;

        case (PerformAction.PERFORMACTION):
            //idle
            break;

        case (PerformAction.CHECKLIFE):
            if (heroesInBattle.Count < 1)
            {
                //lose the battle
                battleStates = PerformAction.LOSE;
            }
            else if (enemyInBattle.Count < 1)
            {
                //win the battle
                battleStates = PerformAction.WIN;
            }
            else
            {
                ClearAttackButton();
                heroInput = HeroGUI.ACTIVATE;
            }
            break;

        case (PerformAction.WIN):
            for (int i = 0; i < heroesInBattle.Count; i++)
            {
                heroesInBattle[i].GetComponent <HeroStateMachine>().currentState =
                    HeroStateMachine.TurnState.WAITING;
            }

            GameManager.gameInstance.LoadSceneAfterBattle();
            GameManager.gameInstance.gameState = GameManager.GameStates.WORLD_STATE;
            GameManager.gameInstance.enemiesToBattle.Clear();
            break;

        case (PerformAction.LOSE):

            break;
        }

        //hero panel input
        switch (heroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (heroesToManage.Count > 0)
            {
                heroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                heroChoise = new HandleTurn();



                attackPanel.SetActive(true);
                CreateButton();

                heroInput = HeroGUI.WAITING;    //set to waiting after activa
            }
            break;

        case (HeroGUI.WAITING):

            break;

        case (HeroGUI.DONE):
            HeroInputDone();
            break;
        }
    }
Пример #24
0
    // Update is called once per frame
    private void Update()
    {
        if (PerformersList.Count == charactersCount)
        {
            ExecutePerformersList = new List <HandleTurn>(PerformersList);
            SortTurnOrder(ExecutePerformersList);
            PerformersList.Clear();
        }//*/

        switch (BattleState)
        {
        case (ActionState.WAIT):
        {
            winLoseCheck();

            // if at least one character has
            // pushed action data to turn list
            if (ExecutePerformersList.Count > 0)
            {
                BattleState = ActionState.TAKEACTION;
                Debug.Log("TAKEACTION Started");
            }
            break;
        }

        case (ActionState.TAKEACTION):
        {
            GameObject performer = GameObject.Find(ExecutePerformersList[0].AttackersName);

            if (ExecutePerformersList[0].Type == "Enemy")
            {
                EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine>();

                // Check if target is still alive
                if (HeroesInBattle.Count > 0)
                {
                    esm.CheckTargetDead(ExecutePerformersList[0]);
                }

                // Set Enemy's current target
                esm.HeroToAttack = ExecutePerformersList[0].AttackersTarget;

                // Attack Target
                esm.CurrentState = EnemyStateMachine.TurnState.ACTION;
            }
            if (ExecutePerformersList[0].Type == "Hero")
            {
                HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>();

                hsm.Action = ExecutePerformersList[0].Action;

                //if (EnemiesInBattle.Count > 0 && hsm.EnemyToAttack != null) { hsm.CheckTargetDead(ExecutePerformersList[0]); }

                if (hsm.Action != ActionType.GUARD)
                {
                    hsm.EnemyToAttack = ExecutePerformersList[0].AttackersTarget;
                }                                                                                                               // review this code when more actions become developed

                hsm.CurrentState = HeroStateMachine.TurnState.ACTION;
            }

            BattleState = ActionState.PERFORMACTION;

            break;
        }

        case (ActionState.PERFORMACTION):
        {
            // placeholder state while
            // characters perform action
            // Resets to WAIT
            // when action is completed
            break;
        }
        }   // switch (BattleState)

        switch (PlayerInput)
        {
        case (HeroGUI.ACTIVATE):
        {
            if (HeroesToManage.Count > 0 && ExecutePerformersList.Count == 0)
            {
                HeroesToManage.Sort(SortHeroesByTurnPriority);
                HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                herosChoice = new HandleTurn();
                AttackPanel.SetActive(true);
                PlayerInput = HeroGUI.WAITING;
            }
            break;
        }

        case (HeroGUI.WAITING):
        {
            // idle state

            break;
        }

        case (HeroGUI.INPUT1):
        {
            // not used yet
            break;
        }

        case (HeroGUI.INPUT2):
        {
            // not used yet
            break;
        }

        case (HeroGUI.DONE):
        {
            HeroInputDone();
            break;
        }
        } // switch (HeroInput)
    }     // void Update()
    // Update is called once per frame
    void Update()
    {
        switch (battleStates)
        {
        case (PerformAction.WAIT):
            if (PerformList.Count > 0)
            {
                battleStates = PerformAction.TAKEACTION;
            }

            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = GameObject.Find(PerformList[0].AttackersGameObject.name);
            //Debug.Log(GameObject.Find(PerformList[0].AttackersGameObject.name));
            if (PerformList[0].Type == "Enemy")
            {
                //Debug.Log(performer);
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();

                //Check hero is dead
                for (int i = 0; i < HeroesInGame.Count; i++)  // we don't need a for loop because we have just 1 hero.
                {
                    //if attackers target is hero and not dead go on.
                    if (PerformList[0].AttackersTarget == HeroesInGame[i])
                    {
                        ESM.heroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    //if the attackers target is hero and dead select another hero and go on
                    //this is not necessary too.
                    else
                    {
                        PerformList[0].AttackersTarget = HeroesInGame[Random.Range(0, HeroesInGame.Count)];
                        ESM.heroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                    }
                }

                ESM.heroToAttack = PerformList[0].AttackersTarget;
                ESM.currentState = EnemyStateMachine.TurnState.ACTION;
            }
            randomEnemyAttack = Random.Range(0, 2);
            //Debug.Log(randomEnemyAttack);
            if (PerformList[0].Type == "Hero")
            {
                // Debug.Log("Hero is ready");
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.EnemyToAttack     = PerformList[0].AttackersTarget;
                HSM.EnemyToAttackCube = PerformList[0].AttackersTargetCube;
                HSM.currentState      = HeroStateMachine.TurnState.ACTION;
            }
            if (PerformList[0].Type == "Enemy")
            {
                if (randomEnemyAttack == 0)
                {
                    enemyisSpell = true;
                }
                else
                {
                    enemyisSpell = false;
                }
            }
            battleStates = PerformAction.PERFORMACTION;

            break;

        case (PerformAction.PERFORMACTION):

            break;

        case (PerformAction.CHECKALIVE):
            if (HeroesInGame.Count < 1)
            {
                battleStates = PerformAction.LOSE;
                //Lose the battle
            }
            else if (EnemiesInGame.Count < 1)
            {
                battleStates = PerformAction.WIN;
                //Win the battle
            }
            else
            {
                clearAttackPanel();
                HeroInput = HeroGUI.ACTIVATE;
            }
            break;

        case (PerformAction.LOSE):
            Debug.Log("You LOSE the battle");

            SceneManager.LoadScene(youlose);
            break;

        case (PerformAction.WIN):
            Debug.Log("You win the battle");
            for (int i = 0; i < HeroesInGame.Count; i++)
            {
                HeroesInGame[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
            }
            SceneManager.LoadScene(youwin);
            break;
        }

        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (HeroesToManage.Count > 0)
            {
                HeroChoice = new HandleTurns();

                ActionPanel.SetActive(true);
                CreateAttackButtons();
                HeroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):
            //idle
            break;

        case (HeroGUI.DONE):
            HeroInputDone();
            break;
        }
    }
Пример #26
0
    // Update is called once per frame
    void Update()
    {
        switch (battlestates)
        {
        case (PerformAction.Wait):
            if (PerformList.Count > 0)
            {
                battlestates = PerformAction.TakeAction;
            }



            break;

        case (PerformAction.TakeAction):
            GameObject performer = GameObject.Find(PerformList[0].Attacker);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (PerformList[0].AttackersTarget == HerosInBattle[i])
                    {
                        ESM.heroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.Action;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        ESM.heroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.Action;
                    }
                }
            }



            if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.EnemyToAttack = PerformList[0].AttackersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.Action;
            }

            battlestates = PerformAction.PerformAction;
            break;

        case (PerformAction.PerformAction):
            //idle
            break;

        case (PerformAction.CheckAlive):
            if (HerosInBattle.Count < 1)
            {
                battlestates = PerformAction.Lose;
                //lose the battle
            }
            else if (EnemiesInBattle.Count < 1)
            {
                battlestates = PerformAction.Win;
                //win the battle
                //gain experience
                //gain money
            }
            else
            {
                //call function
                ClearAttackPanel();
                HeroInput = HeroGui.Activate;
            }
            break;

        case (PerformAction.Win):
        {
            Debug.Log("You won the battle!");
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.Waiting;
            }
        }
        break;

        case (PerformAction.Lose):
        {
            Debug.Log("You lost the battle!");
        }
        break;
        }

        switch (HeroInput)
        {
        case (HeroGui.Activate):
            if (HeroesToManage.Count > 0)
            {
                HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoice = new HandleTurn();

                AttackPanel.SetActive(true);

                //populate action buttons
                CreateAttackButtons();

                HeroInput = HeroGui.Waiting;
            }

            break;

        case (HeroGui.Waiting):

            break;

        case (HeroGui.Input1):

            break;

        case (HeroGui.Input2):

            break;

        case (HeroGui.Done):
            HeroInputDone();
            break;
        }
    }
Пример #27
0
    // Update is called once per frame
    void Update()
    {
        switch (m_battleStates)
        {
        case (PerformAction.WAIT):
            //
            if (m_performList.Count > 0)
            {
                m_battleStates = PerformAction.TAKEACTION;
            }

            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = GameObject.Find(m_performList[0].Attacker);
            //
            if (m_performList[0].Type == "Enemy")
            {
                EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < m_heroes.Count; i++)
                {
                    if (m_performList[0].Target == m_heroes[i])
                    {
                        esm.m_heroTarget   = m_performList[0].Target;
                        esm.m_currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }

                    else
                    {
                        int j = Random.Range(0, m_heroes.Count);
                        m_performList[0].Target = m_heroes[j];
                        esm.m_heroTarget        = m_performList[0].Target;
                        esm.m_currentState      = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }

            //
            if (m_performList[0].Type == "Hero")
            {
                HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>();
                hsm.m_enemyTarget  = m_performList[0].Target;
                hsm.m_currentState = HeroStateMachine.TurnState.ACTION;
            }

            m_battleStates = PerformAction.PERFORMACTION;

            break;

        case (PerformAction.PERFORMACTION):
            // Idle
            break;

        case (PerformAction.CHECKALIVE):
            // Lose battle
            if (m_heroToManage.Count < 1)
            {
                m_battleStates = PerformAction.LOSE;
            }
            // Win battle
            else if (m_enemies.Count < 1)
            {
                m_battleStates = PerformAction.WIN;
            }

            else
            {
                clearAttackPanel();
                m_heroInput = HeroGUI.ACTIVATE;
            }
            break;

        case (PerformAction.WIN):
            Debug.Log("You Win!");
            break;

        case (PerformAction.LOSE):
            Debug.Log("You Lose!");
            break;
        }

        switch (m_heroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (m_heroToManage.Count > 0)
            {
                m_herosChoice = new HandleTurn();

                m_actionPanel.SetActive(true);
                createAttackButtons();

                m_heroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):

            break;

        case (HeroGUI.DONE):
            heroInputDone();

            for (int i = 0; i < m_heroes.Count; i++)
            {
                m_heroes[i].GetComponent <HeroStateMachine>().m_currentState = HeroStateMachine.TurnState.WAITING;
            }
            break;
        }

        m_heroHPs[0] = m_heroes[0].GetComponent <HeroStateMachine>().m_hero.m_currentHP;
        m_heroHPs[1] = m_heroes[1].GetComponent <HeroStateMachine>().m_hero.m_currentHP;
        m_heroHPs[2] = m_heroes[2].GetComponent <HeroStateMachine>().m_hero.m_currentHP;
    }
Пример #28
0
    void Update()
    {
        switch (battleState)
        {
        case (PerformAction.WAIT):
            if (PerformList.Count > 0)
            {
                battleState = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            //Grabbing the performer that should currently be attacking
            GameObject performer = GameObject.Find(PerformList [0].Attacker);
            if (PerformList [0].Type == "Enemy")
            {
                //Getting the state machine from the enemy that is currently attacking
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine> ();

                //Checks if the hero they are attacking is still alive
                for (int i = 0; i < HeroesInBattle.Count; i++)
                {
                    if (PerformList [0].AttackersTarget == HeroesInBattle [i])
                    {
                        //Setting the hero to attack based on the handleturn object that was sent over to the performlist
                        ESM.heroToAttack = PerformList [0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        //Makes enemy attack a new targer if old target is dead
                        PerformList[0].AttackersTarget = HeroesInBattle[Random.Range(0, HeroesInBattle.Count)];

                        ESM.heroToAttack = PerformList [0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }
            if (PerformList [0].Type == "Hero")
            {
                //Getting the state machine from the hero that is currently attacking
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();    //WE'RE ALL IN THIS TOGETHER

                //Setting the enemy to attack based on the handleturn object that was sent over to the performlist
                HSM.enemyToAttack = PerformList[0].AttackersTarget;

                HSM.currentState = HeroStateMachine.TurnState.ACTION;
            }

            battleState = PerformAction.PERFORMACTION;

            break;

        case (PerformAction.PERFORMACTION):
            //idle
            break;

        //visual studio crapped out on me so monogames if f#$king with all the spacing when putting in new code....
        case (PerformAction.CHECKALIVE):        //This handles win and lose changes and dead hero cleanup

            if (HeroesInBattle.Count < 1)
            {
                //lose battle
                battleState = PerformAction.LOSE;
            }
            else if (EnemiesInBattle.Count < 1)
            {
                //win battle
                battleState = PerformAction.WIN;
            }
            else
            {
                //call function
                ClearActionPanel();
                heroInput = HeroGUI.ACTIVATE;
            }

            break;

        case (PerformAction.WIN):
            Debug.Log("You win");
            for (int i = 0; i < HeroesInBattle.Count; i++)
            {
                HeroesInBattle [i].GetComponent <HeroStateMachine> ().currentState = HeroStateMachine.TurnState.WAITING;
            }
            break;

        case (PerformAction.LOSE):
            Debug.Log("You lose");
            break;
        }

        switch (heroInput)
        {
        case (HeroGUI.ACTIVATE):

            //Checks to see if there are any heroes to manage
            if (heroesToManage.Count > 0)
            {
                heroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                //vreates new handleturn instance
                heroChoice = new HandleTurn();

                actionPanel.SetActive(true);

                //populates action buttons
                CreateAttackButtons();

                heroInput = HeroGUI.WAITING;
            }

            break;

        case (HeroGUI.WAITING):
            //idle state
            break;

        case (HeroGUI.DONE):

            HeroInputDone();

            break;
        }
    }
    void Update()
    {
        switch(battleStates)
        {
            case (PerformAction.Wait):
                if(PerformList.Count > 0)
                {
                    battleStates = PerformAction.TakeAction;
                }
                break;

            case (PerformAction.TakeAction):
                GameObject performer = GameObject.Find(PerformList[0].Attacker);
                if(PerformList[0].Type == "Enemy")
                {
                    StartCoroutine(AiWait());
                   /* EnemyStateMachine ESM = performer.GetComponent<EnemyStateMachine>();
                    ESM.HeroToAttack = PerformList[0].AttackersTarget;
                    ESM.currentState = EnemyStateMachine.TurnState.Action;*/
                }
                if (PerformList[0].Type == "Hero")
                {
                    HeroStateMachine HSM = performer.GetComponent<HeroStateMachine>();
                    HSM.EnemyToAttack = PerformList[0].AttackersTarget;
                    HSM.currentState = HeroStateMachine.TurnState.Action;
                }
                battleStates = PerformAction.PerformAction;
                break;

            case (PerformAction.PerformAction):

                break;
            case (PerformAction.Checkalive):
                if(HeroesInBattle.Count < 1)
                {
                    battleStates = PerformAction.Lose;
                }

                else if(EnemiesInBattle.Count < 1)
                {
                    battleStates = PerformAction.Win;
                }
                else
                {
                    clearActionPanel();
                    HeroInput = HeroGui.Activate;
                }
                break;

            case (PerformAction.Win):
                {
                    if(!victoryBool)
                    {
                        Instantiate(VictoryTextPrefab);
                        victoryBool = true;
                    }

                    Debug.Log("You win");
                    for(int i = 0; i< HeroesInBattle.Count; i++)
                    {
                        HeroesInBattle[i].GetComponent<HeroStateMachine>().currentState = HeroStateMachine.TurnState.Waiting;
                    }
                }
                break;

            case (PerformAction.Lose):
                {
                    if(!loseBool)
                    {
                        Instantiate(LoseTextPrefab);
                        loseBool = true;
                    }
                    Debug.Log("You lose");
                }
                break;
        }

        switch(HeroInput)
        {
            case (HeroGui.Activate):
                if(HeroesToManage.Count > 0)
                {
                    HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                    HeroChoise = new HandleTurn();
                    ActionPanel.SetActive(true);
                    //populate buttons
                    CreateAttackButtons();
                    HeroInput = HeroGui.Waiting;
                }
                break;

            case (HeroGui.Waiting):

                break;

            case (HeroGui.Done):
                HeroInputDone();
                break;

        }
    }
Пример #30
0
    // Update is called once per frame
    void Update()
    {
        switch (battleState)
        {
        case (performAction.WAIT):
            if (list.Count > 0)
            {
                battleState = performAction.TAKEACTION;
            }
            break;

        case (performAction.TAKEACTION):
            Debug.Log(list[0].Attacker);
            GameObject performer = GameObject.Find(list[0].Attacker);
            Debug.Log(performer);
            if (list[0].Type == "Enemy")
            {
                EnemyStateMachine esm = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < heroes.Count; i++)
                {
                    if (list[0].attackersTarget == heroes[i])
                    {
                        esm.hero         = list[0].attackersTarget;
                        esm.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }     /*else
                           * {
                           * list[0].attackersTarget = heroes[Random.Range(0, heroes.Count)];
                           * }*/
                }
            }
            if (list[0].Type == "Hero")
            {
                HeroStateMachine hsm = performer.GetComponent <HeroStateMachine>();
                hsm.enemyToAttack = list[0].attackersTarget;
                hsm.currentState  = HeroStateMachine.TurnState.ACTION;
            }

            battleState = performAction.PERFORMACTION;
            break;

        case (performAction.CHECKALIVE):
            if (heroes.Count == 0)
            {
                //lose game
                Debug.Log("Lost");
                battleState = performAction.LOSE;
            }
            else if (enemies.Count == 0)
            {
                //win battle
                Debug.Log("Win");
                for (int i = 0; i < heroes.Count; i++)
                {
                    heroes[i].GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.WAITING;
                }
                battleState = performAction.WIN;
            }
            else
            {
                //call function
                //ActionList.SetActive(false);
                gameManager.GetComponent <GameStates>().List.SetActive(false);
                heroInput = heroGUI.ACTIVATE;
            }
            break;

        case (performAction.PERFORMACTION):

            break;

        case (performAction.LOSE):

            break;

        case (performAction.WIN):
            Destroy(GameObject.FindGameObjectWithTag("Dead enemy"));
            Destroy(GameObject.Find("BattleManager(Clone)"));
            gameManager.GetComponent <GameStates>().state = GameStates.GameState.WORLDSTATE;
            break;
        }

        switch (heroInput)
        {
        case (heroGUI.ACTIVATE):
            if (heroesToManage.Count > 0)
            {
                //heroesToManage[0]
                heroChoice = new HandleTurn();
                //ActionList.SetActive(true);
                gameManager.GetComponent <GameStates>().List.SetActive(true);
                heroInput = heroGUI.WAITING;
            }

            break;

        case (heroGUI.WAITING):
            break;

        case (heroGUI.DONE):
            heroInputDone();
            break;
        }
    }
Пример #31
0
        static void Main(string[] args)
        {
            Console.WriteLine("状态模式:");

            Context context = new Context(new StateA());

            context.Request();
            context.Request();
            context.Request();
            context.Request();

            #region 角色系统
            //Role role = new Role(new Primary(), 0.0f);
            //role.IsVictory = true;
            //role.Play();
            //role.IsVictory = true;
            //role.Play();
            //role.IsVictory = true;
            //role.Play();
            //role.IsVictory = true;
            //role.Play();
            //role.IsVictory = true;
            //role.Play();
            //role.IsVictory = true;
            //role.Play();
            //role.IsVictory = false;
            //role.Play();
            //role.IsVictory = false;
            //role.Play();
            //role.IsVictory = false;
            //role.Play();
            //role.IsVictory = false;
            //role.Play();
            //role.IsVictory = false;
            //role.Play();
            //role.IsVictory = false;
            //role.Play();
            //role.IsVictory = false;
            //role.Play();
            //role.IsVictory = false;
            //role.Play();
            //role.IsVictory = false;
            //role.Play();
            //role.IsVictory = false;
            //role.Play();
            #endregion

            #region  输门
            //TransmissionGate transGate = new TransmissionGate(new Closed());
            //transGate.Complete();
            //transGate.Click();
            //transGate.TimeOut();
            //transGate.Click();
            //transGate.Complete();
            //transGate.TimeOut();
            //transGate.Click();
            //transGate.Complete();
            //transGate.TimeOut();
            //transGate.Click();
            //transGate.Complete();
            //transGate.Click();
            //transGate.Click();
            //transGate.Complete();
            #endregion

            Idle   idle   = new Idle();
            Walk   walk   = new Walk();
            Jump   jump   = new Jump();
            Attack attack = new Attack();

            idle.AddTransition(new JyTransition(idle, walk, 'w'));
            idle.AddTransition(new JyTransition(idle, jump, 'j'));
            idle.AddTransition(new JyTransition(idle, attack, 'k'));

            walk.AddTransition(new JyTransition(walk, idle, 's'));
            walk.AddTransition(new JyTransition(walk, jump, 'j'));
            walk.AddTransition(new JyTransition(walk, attack, 'k'));

            jump.AddTransition(new JyTransition(jump, idle, 's'));
            jump.AddTransition(new JyTransition(jump, walk, 'w'));
            jump.AddTransition(new JyTransition(jump, attack, 'k'));

            attack.AddTransition(new JyTransition(attack, idle, 's'));
            attack.AddTransition(new JyTransition(attack, walk, 'w'));
            attack.AddTransition(new JyTransition(attack, jump, 'j'));

            HeroStateMachine heroStateMachine = new HeroStateMachine(idle);
            heroStateMachine.AddState(walk);
            heroStateMachine.AddState(jump);
            heroStateMachine.AddState(attack);

            ConsoleKeyInfo ConsoleKeyInfo = new ConsoleKeyInfo();
            while (ConsoleKeyInfo.Key != ConsoleKey.Escape)
            {
                ConsoleKeyInfo = Console.ReadKey();
                Console.WriteLine(ConsoleKeyInfo.Key.ToString());
                heroStateMachine.Word = ConsoleKeyInfo.KeyChar;
                heroStateMachine.OnStay();
            }
        }
Пример #32
0
    // Update is called once per frame
    void Update()
    {
        endCombatCheck = true;
        foreach (GameObject enemy in Enemies)
        {
            if (enemy.GetComponent <EnemyStateMachine>().currentState != EnemyStateMachine.TurnState.DEAD)
            {
                endCombatCheck = false;
            }
        }
        if (endCombatCheck)
        {
            endCombatWin();
        }
        endCombatCheck = true;
        foreach (GameObject hero in Heros)
        {
            if (hero.GetComponent <HeroStateMachine>().currentState != HeroStateMachine.TurnState.DEAD)
            {
                endCombatCheck = false;
            }
        }
        if (endCombatCheck)
        {
            endCombatLoss();
        }
        switch (battleState)
        {
        case (PerformAction.WAIT):
            if (PerformList.Count > 0)
            {
                battleState = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = GameObject.Find(PerformList[0].AttackerName);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM;
                try
                {
                    ESM = performer.GetComponent <EnemyStateMachine>();
                } catch
                {
                    PerformList.RemoveAt(0);
                    battleState = PerformAction.WAIT;
                    break;
                }
                ESM.heroToAttack = PerformList[0].Defender;
                ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                battleState      = PerformAction.PERFORMACTION;
            }
            else if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM;
                try
                {
                    HSM = performer.GetComponent <HeroStateMachine>();
                }
                catch
                {
                    PerformList.RemoveAt(0);
                    battleState = PerformAction.WAIT;
                    break;
                }
                HSM.enemyToAttack = PerformList[0].Defender;
                HSM.currentState  = HeroStateMachine.TurnState.ACTION;
                battleState       = PerformAction.PERFORMACTION;
            }
            break;

        case (PerformAction.PERFORMACTION):
            GameObject person = GameObject.Find(PerformList[0].AttackerName);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = person.GetComponent <EnemyStateMachine>();
                if (ESM.currentState == EnemyStateMachine.TurnState.DEAD)
                {
                    PerformList.RemoveAt(0);
                    battleState = PerformAction.WAIT;
                }
            }
            else if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM = person.GetComponent <HeroStateMachine>();
                if (HSM.currentState == HeroStateMachine.TurnState.DEAD)
                {
                    PerformList.RemoveAt(0);
                    battleState = PerformAction.WAIT;
                }
            }
            break;
        }
        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            pause = false;
            if (HerosToManage.Count > 0)
            {
                pause = true;
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroTurn = new BattleTurn();

                attackPanel.SetActive(true);
                HeroInput = HeroGUI.WAITING;
            }
            break;

        case (HeroGUI.WAITING):
            break;

        case (HeroGUI.DONE):
            HeroInputDone();
            break;
        }
    }