// 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.WolfToAttack = PerformList[0].AttackersTarget;
                ESM.currentState = EnemyStateMachine.TurnState.ACTION;
            }
            if (PerformList[0].Type == "wolf")
            {
                WolfStateMachine HSM = performer.GetComponent <WolfStateMachine>();
                HSM.EnemyToAttack = PerformList[0].AttackersTarget;
                HSM.currentState  = WolfStateMachine.TurnState.ACTION;
            }
            battleStates = PerformAction.PERFORMACTION;
            break;

        case (PerformAction.PERFORMACTION):
            //idle
            break;
        }
        switch (WolfInput)
        {
        case (WolfGUI.ACTIVATE):
        {
            if (WolvesToManage.Count > 0)
            {
                WolvesToManage[0].transform.FindChild("selector").gameObject.SetActive(true);         //Indicator appears in-game
                WolfChoice = new HandleTurns();

                AttackPanel.SetActive(true);         //Right grey attack panel appears
                WolfInput = WolfGUI.WAITING;         //Idle state for Wolf Input
            }
            break;
        }

        case (WolfGUI.WAITING):
        {
            //idling
            break;
        }

        case (WolfGUI.DONE):
        {
            WolfInputDone();
            break;
        }
        }
    }
Esempio n. 2
0
    void ChooseAction()
    {
        HandleTurns myAttack = new HandleTurns();

        myAttack.Attacker         = Player2.EnemyName;
        myAttack.AttackGameObject = this.gameObject;
        myAttack.AttackersTarget  = bsm.P1[(Random.Range(0, bsm.P1.Count))];
        bsm.CollectActions(myAttack);
    }
    void ChooseAction()
    {
        HandleTurns handleTurns = new HandleTurns();

        handleTurns.attacker           = unitName;
        handleTurns.attackerGameObject = this.gameObject;
        handleTurns.targetGameObject   = battleStateMachine.heroesInBattle[Random.Range(0, battleStateMachine.heroesInBattle.Count)];
        battleStateMachine.CollectActions(handleTurns);
    }
Esempio n. 4
0
    void ChooseAction()
    {
        HandleTurns myAttack = new HandleTurns();

        myAttack.Attacker         = Player1.CharacterName;
        myAttack.Type             = "Player";
        myAttack.AttackGameObject = this.gameObject;
        myAttack.AttackersTarget  = bsm.P2[Random.Range(0, bsm.P2.Count)];
        bsm.CollectActions(myAttack);
    }
Esempio n. 5
0
    void ChooseAction()
    {
        HandleTurns myAttack = new HandleTurns();

        myAttack.Attacker         = enemy.name;
        myAttack.type             = "enemy";
        myAttack.AttackGameObject = this.gameObject;
        myAttack.AttackersTarget  = BSM.HerosInBattle[Random.Range(0, BSM.HerosInBattle.Count)];
        BSM.CollectActions(myAttack);
    }
    void ChooseAction()
    {
        HandleTurns myAttack = new HandleTurns();

        myAttack.Attacker           = enemy.theName;
        myAttack.Type               = "enemy";
        myAttack.AttackerGameObject = this.gameObject;
        //CHANGE THIS FOR DYANMIC AI (BASED ON LOWEST HP, HEALER, THREAT, ETC.)
        myAttack.AttackersTarget = BSM.WolvesInBattle[Random.Range(0, BSM.WolvesInBattle.Count)];


        BSM.CollectActions(myAttack);
    }
 /// <summary>
 /// Lets the enemy choose a skill and a target to use on.
 /// </summary>
 private void ChooseAction()
 {
     if (bsm.herosInBattle.Count > 0)
     {
         HandleTurns chosenAction = new HandleTurns();
         chosenAction.type                = "Enemy";
         chosenAction.attacker            = baseClass.name_;
         chosenAction.attackersGameobject = this.gameObject;
         chosenAction.attackersTarget     = bsm.herosInBattle[Random.Range(0, bsm.herosInBattle.Count)];
         chosenAction.chosenAttack        = baseClass.attacks[Random.Range(0, baseClass.attacks.Count)];
         bsm.CollectActions(chosenAction);
     }
 }
Esempio n. 8
0
    void ChooseAction()
    {
        HandleTurns myAttack = new HandleTurns();

        myAttack.Attacker            = enemy.thename;
        myAttack.Type                = "Enemy";
        myAttack.AttackersGameObject = this.gameObject;
        myAttack.AttackersTarget     = BSM.ProtagsInBattle[Random.Range(0, BSM.ProtagsInBattle.Count)];
        int rand = Random.Range(0, enemy.MeleeAttacks.Count);

        myAttack.ChooseAttack = enemy.MeleeAttacks[rand];


        BSM.CollectAction(myAttack);
    }
Esempio n. 9
0
    void ChooseAction()
    {
        HandleTurns myAttack = new HandleTurns();

        myAttack.Attacker            = "Enemy"; // vietoj "Enemy" buvo  EnemyStats.theName; ti jei kokių problemų kils bandykit atkeist
        myAttack.Type                = "Enemy";
        myAttack.AttackersGameObject = this.gameObject;
        myAttack.AttackersTarget     = BSM.HerosInBattle[Random.Range(0, BSM.HerosInBattle.Count)];

        int num = Random.Range(0, EnemyStats.attacks.Count);

        myAttack.choosenAttack = EnemyStats.attacks[num];
        Debug.Log(this.gameObject.name + " has choosen" + myAttack.choosenAttack.attackName + " and do " + myAttack.choosenAttack.attackDamage + " damage!");
        BSM.CollectActions(myAttack);
    }
Esempio n. 10
0
    void ChooseAction()
    {
        HandleTurns myAttack = new HandleTurns();

        myAttack.Attacker            = enemy.theName;
        myAttack.Type                = "Enemy";
        myAttack.AttackingGameObject = this.gameObject;
        myAttack.AttackersTarget     = BSM.HerosInBattle[0];

        int num = Random.Range(0, enemy.attacks.Count);

        myAttack.choosenAttack = enemy.attacks[num];
        // Debug.Log(this.gameObject.name + "has choosen " + myAttack.choosenAttack.attackName + "and does " + myAttack.choosenAttack.attackDamage + "Damage!");

        BSM.CollectActions(myAttack);
    }
Esempio n. 11
0
    void chooseAction()
    {
        HandleTurns thisAttack = new HandleTurns();

        thisAttack.attacker     = enemy.theName;
        thisAttack.type         = "Enemy";
        thisAttack.attackerGO   = this.gameObject;
        thisAttack.attackTarget = BSM.PlayerCharacters[Random.Range(0, BSM.PlayerCharacters.Count)];
        //choose attack randomly from list
        int num = Random.Range(0, enemy.attacks.Count);

        thisAttack.chosenAttack = enemy.attacks[num];
        Debug.Log(this.gameObject.name + " has chosen: " + thisAttack.chosenAttack.attackName + " and does " + thisAttack.chosenAttack.attackDmg + " damage");



        BSM.CollectActions(thisAttack);
    }
Esempio n. 12
0
    void ChooseAction()
    {
        HandleTurns myAttack = new HandleTurns();

        myAttack.Attacker            = enemy.theName;
        myAttack.Type                = "Enemy";
        myAttack.AttackersGameObject = this.gameObject;
        myAttack.AttackersTarget     = BSM.HeroesInGame[Random.Range(0, BSM.HeroesInGame.Count)];

        int attackNumber = Random.Range(0, enemy.attacks.Count);

        myAttack.choosenAttack = enemy.attacks[attackNumber];

        /*
         * Debug.Log(this.gameObject.name + " has choosen " +
         *  myAttack.choosenAttack.attackName + " and do " + myAttack.choosenAttack.attackDamage +
         *  " and costs " + myAttack.choosenAttack.manaCost);
         */
        BSM.CollectActions(myAttack);
    }
    // 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;
        }
    }
 public void CollectActions(HandleTurns input)
 {
     PerformList.Add(input);
 }
    // Update is called once per frame
    void Update()
    {
        switch (battlestate)
        {
        case (PerformAction.WAIT):
            if (TurnList.Count > 0)
            {
                battlestate = PerformAction.TAKEACTION;
            }
            break;

        case (PerformAction.TAKEACTION):
            GameObject performer = GameObject.Find(TurnList[0].attacker);
            //handles enemies
            if (TurnList[0].type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < PlayerCharacters.Count; i++)
                {
                    if (TurnList[0].attackTarget == PlayerCharacters[i])
                    {
                        ESM.targetPlayer = TurnList[0].attackTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        TurnList[0].attackTarget = PlayerCharacters[Random.Range(0, PlayerCharacters.Count)];
                        ESM.targetPlayer         = TurnList[0].attackTarget;
                        ESM.currentState         = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }
            //handles heroes
            if (TurnList[0].type == "Player")
            {
                PlayerStateMachine PSM = performer.GetComponent <PlayerStateMachine>();
                PSM.targetEnemy  = TurnList[0].attackTarget;
                PSM.currentState = PlayerStateMachine.TurnState.ACTION;
            }

            battlestate = PerformAction.PERFORMACTION;
            break;

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

        case (PerformAction.CHECKALIVE):
            //check if lost
            if (PlayerCharacters.Count < 1)
            {
                battlestate = PerformAction.LOSE;
            }
            //check if won
            else if (EnemyCharacters.Count < 1)
            {
                battlestate = PerformAction.WIN;
            }
            //move to next state
            else
            {
                //call function
                clearAttackPanel();
                playerInput = PlayerGUI.ACTIVATE;
            }
            break;

        case (PerformAction.WIN):
            Debug.Log("you win");
            for (int i = 0; i < PlayerCharacters.Count; i++)
            {
                PlayerCharacters[i].GetComponent <PlayerStateMachine>().currentState = PlayerStateMachine.TurnState.WAITING;
            }
            //return player ot previous scene
            Gmanager.instance.LoadAfterBattle();
            // SceneManager.LoadScene("win");
            Gmanager.instance.gamestate = Gmanager.gameStates.WORLD_STATE;
            Gmanager.instance.enemiesToBattle.Clear();
            break;

        case (PerformAction.LOSE):
            Debug.Log("you lose");
            // SceneManager.LoadScene("lose");
            break;
        }


        switch (playerInput)
        {
        case (PlayerGUI.ACTIVATE):
            if (PlayerManagement.Count > 0)
            {
                PlayerManagement[0].transform.Find("selector").gameObject.SetActive(true);
                playerChoice = new HandleTurns();
                //show panel
                attackPanel.SetActive(true);
                //createbuttons
                createAttackButtons();
                playerInput = PlayerGUI.WAITING;
            }
            break;

        case (PlayerGUI.WAITING):

            break;

        case (PlayerGUI.DONE):
            playerInputDone();
            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].AttakersTarget == HerosInBattle[i])
                    {
                        ESM.HeroToAttack = PerformList[0].AttakersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttakersTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        ESM.HeroToAttack = PerformList[0].AttakersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }
            if (PerformList[0].Type == "Hero")
            {
                HeroStateMachine HSM = performer.GetComponent <HeroStateMachine>();
                HSM.EnemyToAttack = PerformList[0].AttakersTarget;
                HSM.currentState  = HeroStateMachine.TurnState.ACTION;
            }
            battleStates = PerformAction.PERFORMACTION;
            break;

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

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

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

        case (PerformAction.WIN):
        {
            Debug.Log("You win the battle!");
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMachine>().currentState            = HeroStateMachine.TurnState.WAITING;
                GameManager.instance.party[i].GetComponent <HeroStateMachine>().hero.curHP = HerosInBattle[i].GetComponent <HeroStateMachine>().hero.curHP;
                GameManager.instance.party[i].curHP = HerosInBattle[i].GetComponent <HeroStateMachine>().hero.curHP;

                GameManager.instance.party[i].GetComponent <HeroStateMachine>().hero.curMP = HerosInBattle[i].GetComponent <HeroStateMachine>().hero.curMP;
                GameManager.instance.party[i].curMP = HerosInBattle[i].GetComponent <HeroStateMachine>().hero.curMP;
            }
            GameManager.instance.LoadSceneAfterBattle();
            GameManager.instance.gameState = GameManager.GameStates.WORLD_STATE;
            GameManager.instance.enemiesToBattle.Clear();
        }
        break;
        }

        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (HerosToManage.Count > 0)
            {
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoice = new HandleTurns();
                AttackPanel.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;
        }
    }
Esempio n. 18
0
    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")
            {
                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[0];
                        ESM.HeroToAttack = PerformList[0].AttackersTarget;
                        ESM.currentState = EnemyStateMachine.TurnState.ACTION;
                    }
                }
            }

            if (PerformList[0].Type == "Hero")
            {
                HerroStateMachine HSM = performer.GetComponent <HerroStateMachine>();

                for (int i = 0; i < EnemiesInBattle.Count; i++)

                {
                    if (PerformList[0].AttackersTarget == EnemiesInBattle[i])
                    {
                        HSM.enemyToAttack = PerformList[0].AttackersTarget;
                        HSM.currentState  = HerroStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackersTarget = EnemiesInBattle[Random.Range(0, EnemiesInBattle.Count)];
                        HSM.enemyToAttack = PerformList[0].AttackersTarget;
                        HSM.currentState  = HerroStateMachine.TurnState.ACTION;
                    }
                }
            }
            battleStates = PerformAction.PERFORMACTION;
            break;

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

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

        case (PerformAction.WIN):
        {
            Debug.Log("You win game");
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HerroStateMachine>().currentState = HerroStateMachine.TurnState.WAITING;
            }
            battleCanvas.SetActive(true);
            battleGround.SetActive(false);
            winLoseText.GetComponent <Text>().text = "YOU WIN!!";
            winLoseText.SetActive(true);
            HerosToManage.Clear();
        }
        break;

        case (PerformAction.LOSE):
        {
            Debug.Log("You lost game");
            battleCanvas.SetActive(true);
            battleGround.SetActive(false);
            winLoseText.GetComponent <Text>().text = "YOU LOST!!";
            winLoseText.SetActive(true);
            HerosToManage.Clear();
        }
        break;
        }
        switch (HeroInput)
        {
        case (HeroGUI.ACTIVATE):
            if (HerosToManage.Count > 0)
            {
                HeroChoice = new HandleTurns();

                HeroInput = HeroGUI.WAITING;
            }

            break;


        case (HeroGUI.WAITING):
            //idle
            HeroInput = HeroGUI.INPUT1;
            break;

        case (HeroGUI.INPUT1):
            Input1();
            break;

        case (HeroGUI.INPUT2):

            Input2();
            break;


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

            break;
        }
    }
    // Update is called once per frame
    void Update()
    {
        //if (JNRCharacterController.isInFight) {
        if (PlayerController.isInFight)
        {
            Debug.Log("buttonNumber: " + buttonNumber);
            //Debug.Log("actionbuttons: " + actionButtons.Count);
            if (setFirstEnemy)
            {
                if (UnitSelection.detectedEnemy.name == "Battle_Robot_1")
                {
                    fightWasBoss = true;
                }

                detectedTarget = enemiesInBattle[0];
                setFirstEnemy  = 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 it is an enemy
                if (performList[0].type == "Enemy")
                {
                    CharacterStateMaschine esm = performer.GetComponent <CharacterStateMaschine>();
                    for (int i = 0; i < herosInBattle.Count; i++)
                    {
                        if (performList[0].attackersTarget == herosInBattle[i])
                        {
                            esm.enemyToAttack = performList[0].attackersTarget;
                            esm.currentState  = CharacterStateMaschine.TurnState.action;
                            break;
                        }
                        else
                        {
                            performList[0].attackersTarget = herosInBattle[Random.Range(0, herosInBattle.Count)];
                            esm.enemyToAttack = performList[0].attackersTarget;
                            esm.currentState  = CharacterStateMaschine.TurnState.action;
                        }
                    }
                }
                // if it is a hero
                if (performList[0].type == "Hero")
                {
                    CharacterStateMaschine hsm = performer.GetComponent <CharacterStateMaschine>();
                    hsm.enemyToAttack = performList[0].attackersTarget;
                    hsm.currentState  = CharacterStateMaschine.TurnState.action;
                }
                battleStates = PerformAction.performAction;
                break;

            case (PerformAction.performAction):
                break;

            case (PerformAction.checkAlive):
                if (herosInBattle.Count < 1)
                {
                    // loose battle
                    battleStates = PerformAction.lost;
                }
                else if (enemiesInBattle.Count < 1)
                {
                    // win battle
                    battleStates = PerformAction.won;
                }
                else
                {
                    ClearAttackPanels();
                    heroInput = HeroGUI.activate;
                }
                break;

            case (PerformAction.won):
                ResetAfterBattle(true);
                break;

            case (PerformAction.lost):
                ResetAfterBattle(false);
                break;
            }
            switch (heroInput)
            {
            case (HeroGUI.activate):
                if (battleStates == PerformAction.won || battleStates == PerformAction.lost)
                {
                    break;
                }
                if (CharacterStateMaschine.herosTurnOver == herosInBattle.Count && Input.GetButton("Submit"))
                {
                    Debug.Log("It's not your turn!");
                    break;
                }
                if (herosToManage.Count > 0)
                {
                    herosToManage[0].GetComponent <CharacterStateMaschine>().ToggleVisibilityHeroStats(true);


                    herosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                    heroChoice = new HandleTurns();
                    if (Input.GetButton("Submit") || fightStartet)
                    {
                        //    if(!CharacterStateMaschine.isEnemiesTurn) {
                        fightStartet = false;
                        //attackPanel.SetActive(true);
                        if (createAttackPanelOnce)
                        {
                            attackPanel.SetActive(true);


                            CreateActionButton();
                            createAttackPanelOnce = false;


                            heroInput = HeroGUI.wait;
                        }
                        // heroInput = HeroGUI.wait;
                    }
                }



                /*
                 * if (Input.GetButton("Submit") && selectEnemy) {
                 *  BattleStateMachine.selectEnemy = false;
                 *  ActionToPerform(BattleStateMachine.selectedAttack);
                 * }*/



                break;

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

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



            //     SwitchActionButtons();
        }
    }
Esempio n. 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>();
                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;
        }
    }
Esempio n. 21
0
 //gets attacker and target details
 public void GetCurrentAction(HandleTurns input)
 {
     PerformList.Add(input);
 }
 public void CollectActions(HandleTurns input) //When a unit's StateMachine issues an input, add it to global list of queued actions
 {
     PerformList.Add(input);
 }
Esempio n. 23
0
    // 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 CollectActions(HandleTurns turns)
 {
     TurnList.Add(turns);
 }
Esempio n. 25
0
 public void CollectActions(HandleTurns input)
 {
     handleTurns.Add(input);
 }