コード例 #1
0
    // creo una funzione void che chiamo choseAction
    void choseAction()
    {
        //assegno un nuovo HandleTurn a myAttack
        HandleTurn myAttack = new HandleTurn();

        //imposto il nome dell'attaccante come il nome del nemico
        myAttack.Attacker = enemy.Thename;
        // cambio il type di myAttack a enemy
        myAttack.Type = "Enemy";
        //assegno questo GameObject a AttacksGameObject
        myAttack.AttacksGameObject = this.gameObject;
        // randomizzo il player da attaccare
        myAttack.AttacksTarget = Bsm.HerosInGame[Random.Range(0, Bsm.HerosInGame.Count)];
        //randomizzo il tipo di attacco dalla lista
        int num = Random.Range(0, enemy.attacks.Count);

        //assengo l'attacco appena randomizzato a chosenAttack
        myAttack.chosenAttack = enemy.attacks[num];
        // faccio un debug.log che controlla quale attacco e stato eseguito
        Debug.Log(this.gameObject.name + " has chosen " + myAttack.chosenAttack.attackName +
                  " and do " + myAttack.chosenAttack.attackDamage + " damage");
        Bsm.collectAction(myAttack);
    }
コード例 #2
0
ファイル: BattleController.cs プロジェクト: charlink1/iwmr
    void Update()
    {
        HandleMainStateMachine();

        switch (HeroInput)
        {
        case HeroGUI.ACTIVATE:
            if (HeroesToManage.Count > 0)
            {
                Animator anim = HeroesToManage[0].GetComponent <CharacterStateMachine>().textAnimator;
                if (!anim.GetBool("colorChange"))
                {
                    anim.SetBool("colorChange", true);
                }

                heroChoice = new HandleTurn();
                actionPanel.SetActive(true);
                playerCommandsPanelSound.Play();
                CreateAttackButtons();
                HeroInput = HeroGUI.WAITING;
            }
            break;

        case HeroGUI.WAITING:
            break;

        case HeroGUI.INPUT1:
            break;

        case HeroGUI.INPUT2:
            break;

        case HeroGUI.DONE:
            HeroInputDone();
            break;
        }
    }
コード例 #3
0
 //
 public void collectActions(HandleTurn input)
 {
     m_performList.Add(input);
 }
コード例 #4
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;
        }
    }
コード例 #5
0
 public void ClearCurrentAction()
 {
     currentAction = null;
 }
コード例 #6
0
 public void collectActions(HandleTurn turn)
 {
     list.Add(turn);
 }
コード例 #7
0
 //creo una  funzione void collectAction che chiederà un HandleTurn
 public void collectAction(HandleTurn input)
 {
     // aggiungo input alla performList
     performList.Add(input);
 }
コード例 #8
0
    public void ExecuteTurn()
    {
        //if we have nothing left exit, otherwise continue combos etc
        if (actions.Count == 0)
        {
            ResetAttack();
            //BC.MonsterIsAnimating = false; //this is called at the animation IEnumarators instead at the last frame
            DoneComboing = true;             //used to determine if we have completed all our actions
            return;
        }

        //check if an animation is occuring if so then return
        if (BC.MonsterIsAnimating)
        {
            return;
        }

        previousAction = actions[0];
        currentAction  = previousAction;
        targets        = currentAction.targets;
        //this will pause time for us so other monsters dont increment
        BC.MonsterIsAnimating = true;

        if (currentAction.targetArea == TargetArea.SINGLE)
        {
            StartCoroutine(BC.BeginAttack(currentAction.owner, currentAction.targets[0], 0.5f));
        }
        else
        {
            //AoE attacks wont animate in this case this is required
            BC.MonsterIsAnimating = false;
        }

        //Apply effects to player
        if (currentAction.drawType != DrawType.NONE)
        {
            //CheckDraw();
        }

        //Apply effect to targets
        foreach (GameObject target in targets)
        {
            // Attack Canceling?
            if (currentAction.isCanceling)
            {
                MonsterController targetsMonsterController = target.GetComponent <MonsterController>();
                //we have to make sure the target has an action queued up otherwise just do damage as normal
                if (targetsMonsterController.actions.Count >= 1)
                {
                    targetsMonsterController.RemoveActionAtIndex(0);
                    BC.SpawnBattleTextAboveWithString(target, "Attack Canceled!");
                }
            }

            // Stunning?
            // if we stun enemy add us as the owner otherwise increase the number
            if (currentAction.stunNumberOfTurns > 0)
            {
                Stun stun = target.GetComponent <Stun>();

                if (stun == null)
                {
                    target.AddComponent <Stun>();
                    stun       = target.GetComponent <Stun>();
                    stun.Owner = this.gameObject;
                }
                else
                {
                    Debug.Log("Stuns found adding " + currentAction.stunNumberOfTurns);
                    stun.AddTurns(currentAction.stunNumberOfTurns);
                }
            }

            //Are we increasing this monsters current armor?
            if (currentAction.block > 0)
            {
                ApplyBlock();
            }

            //Display only if damage was > 0
            if (currentAction.damage != 0)
            {
                target.GetComponent <MonsterController>().Damage(currentAction.damage);
                // moved text generation to Damage to control what is outputted
                //BC.SpawnBattleTextAbove(target, previousAction.damage);
            }
        }

        actions.RemoveAt(0);
        currentAction.Clear();
        ExecuteTurn();
    }
コード例 #9
0
 public void CollectActions(HandleTurn input)
 {
     PerformList.Add(input);  // recorded actions chosen by enemy
 }
コード例 #10
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;
        }
    }
コード例 #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 = PerformList[0].AttackerGameObject;
            if (PerformList[0].type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                for (int i = 0; i < PlayerInBattle.Count; i++)
                {
                    if (PerformList[0].AttackerTarget == PlayerInBattle[i])
                    {
                        ESM.PlayerToAttack = PerformList[0].AttackerTarget;
                        ESM.currentState   = EntityStateMachine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        PerformList[0].AttackerTarget = PlayerInBattle[Random.Range(0, PlayerInBattle.Count)];
                        ESM.PlayerToAttack            = PerformList[0].AttackerTarget;
                        ESM.currentState = EntityStateMachine.TurnState.ACTION;
                    }
                }
            }
            if (PerformList[0].type == "Player")
            {
                PlayerStateMachine PSM = performer.GetComponent <PlayerStateMachine>();
                PSM.EnemyToAttack = PerformList[0].AttackerTarget;
                PSM.currentState  = EntityStateMachine.TurnState.ACTION;
            }
            battleStates = PerformAction.PERFORMACTION;
            break;

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

        case (PerformAction.CHECKALIVE):
            if (PlayerInBattle.Count < 1)
            {
                //Lose the battle
                battleStates = PerformAction.LOSE;
            }
            else if (EnemyInBattle.Count < 1)
            {
                //Win the battle
                battleStates = PerformAction.WIN;
            }
            else
            {
                clearAttackPanel();
                PlayerInput = PlayerGUI.ACTIVE;
            }
            break;

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

        case (PerformAction.WIN):
            Debug.Log("You won the battle");
            for (int i = 0; i < PlayerInBattle.Count; i++)
            {
                PlayerInBattle[i].GetComponent <PlayerStateMachine>().currentState = EntityStateMachine.TurnState.WAITING;
            }
            PlayerBattleStatus(false);
            GameManager.instance.LoadSceneAfterBattle();
            GameManager.instance.gameState = GameManager.GameStates.WORLD_STATE;
            GameManager.instance.enemiesToBattle.Clear();
            break;
        }
        switch (PlayerInput)
        {
        case (PlayerGUI.ACTIVE):
            if (HeroToManager.Count > 0)
            {
                HeroToManager[0].transform.Find("Selector").gameObject.SetActive(true);
                //create new handleturn instance
                HeroChoice = new HandleTurn();
                ActionPanel.SetActive(true);
                //populate action buttons
                CreateAttackButtons();
                //switch to WAITING
                PlayerInput = PlayerGUI.WAITING;
            }
            break;

        case (PlayerGUI.WAITING):
            break;

        case (PlayerGUI.DONE):
            HeroInputDone();
            break;
        }
    }
コード例 #12
0
 public void CollectAction(HandleTurn input)
 {
     //thu thap cac hanh dong can thuc hien va cho vao list
     PerformList.Add(input);
 }
コード例 #13
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;
        }
    }
コード例 #14
0
    void Update()
    {
        switch (battleState) // SWITCHING BATTLE STATE
        {
        case PerformAction.WAIT:
            if (PerformList.Count > 0)
            {
                battleState = PerformAction.TAKEACTION;
            }

            break;

        case PerformAction.TAKEACTION:
            if (PerformList.Count == 0)
            {
                battleState = PerformAction.CHECKSTATUS;
            }
            GameObject performer = (PerformList[0].AttackersObject);     // grabs the performer at top of performlist
            print("The Performer at space 0 is " + performer.gameObject);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyState ES = performer.GetComponent <EnemyState>();
                ES.HeroToAttack = PerformList[0].AttackersTarget;
                ES.currentState = EnemyState.TurnState.ACTION;
            }
            if (PerformList[0].Type == "Hero")
            {
                HeroState HS = performer.GetComponent <HeroState>();
                HS.EnemyToAttack = PerformList[0].AttackersTarget;
                HS.currentState  = HeroState.TurnState.ACTION;
            }

            battleState = PerformAction.PERFORMACTION;
            break;

        case PerformAction.PERFORMACTION:

            break;

        case PerformAction.CHECKSTATUS:
            if (HerosInBattle.Count == 0)
            {
                battleState = PerformAction.LOSE;
            }

            else if (EnemiesInBattle.Count == 0)
            {
                battleState = PerformAction.WIN;
            }

            else
            {
                battleState = PerformAction.WAIT;
                HeroInput   = HeroGUI.ACTIVATE;
            }
            break;

        case PerformAction.WIN:
            print("Battle Won!");
            PerformList.Clear();
            HeroInput = HeroGUI.WAITING;
            foreach (GameObject hero in HerosInBattle)
            {
                HeroState HS = hero.GetComponent <HeroState>();
                HS.currentState  = HeroState.TurnState.WAITING;
                HS.EnemyToAttack = null;
                HS.selector.SetActive(false);
            }
            actionPanel.SetActive(false);
            targetPanel.SetActive(false);
            battleAudioSource.Stop();
            battleAudioSource.loop = false;
            battleAudioSource.clip = battleWinSound;
            battleAudioSource.Play();

            StartCoroutine(WinBattle());

            break;

        case PerformAction.LOSE:
            battleAudioSource.Stop();
            battleAudioSource.clip = battleLoseSound;
            battleAudioSource.loop = false;
            battleAudioSource.Play();
            StartCoroutine(LoseBattle());
            break;
        }

        switch (HeroInput)
        {
        case HeroGUI.ACTIVATE:
            if (HerosToManage.Count > 0)
            {
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoice = new HandleTurn();
                ClearAttackPanel();
                EnemyButtons();
                actionPanel.SetActive(true);
                HeroInput = HeroGUI.WAITING;
            }
            break;

        case HeroGUI.DONE:
            HeroInputDone();
            break;

        case HeroGUI.INPUT1:

            break;

        case HeroGUI.INPUT2:

            break;

        case HeroGUI.WAITING:

            break;
        }
    }
コード例 #15
0
 public void CollectActions(HandleTurn input) // Passes Input from Enemy and Hero into the Perform List
 {
     PerformList.Add(input);
 }
コード例 #16
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;
        }
    }
コード例 #17
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;
    }
コード例 #18
0
    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")
            {
                EnemyStateMaschine ESM = performer.GetComponent <EnemyStateMaschine>();
                for (int i = 0; i < HerosInBattle.Count; i++)
                {
                    if (performList[0].AttackerTarget == HerosInBattle[i])
                    {
                        ESM.HeroToAttack = performList[0].AttackerTarget;
                        ESM.currnetState = EnemyStateMaschine.TurnState.ACTION;
                        break;
                    }
                    else
                    {
                        performList[0].AttackerTarget = HerosInBattle[Random.Range(0, HerosInBattle.Count)];
                        ESM.HeroToAttack = performList[0].AttackerTarget;
                        ESM.currnetState = EnemyStateMaschine.TurnState.ACTION;
                    }
                }
                ESM.HeroToAttack = performList[0].AttackerTarget;
                ESM.currnetState = EnemyStateMaschine.TurnState.ACTION;
            }

            if (performList[0].Type == "Hero")
            {
                Debug.Log("Hero is hero to perform");
                HeroStateMaschine HSM = performer.GetComponent <HeroStateMaschine>();
                HSM.EnemyToAttack = performList[0].AttackerTarget;
                HSM.currnetState  = HeroStateMaschine.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 (EnemyInBattle.Count < 1)
            {
                battleStates = PerformAction.WIN;
                //win game
            }
            else
            {
                //call funcion
                clearAttackPanel();
                HeroInput = HeroGuI.ACTIVATE;
            }
            break;

        case (PerformAction.LOSE):
        {
            Debug.Log("You Lost the Battle");
        }
        break;

        case (PerformAction.WIN):
        {
            Debug.Log("You Win the Battle");
            for (int i = 0; i < HerosInBattle.Count; i++)
            {
                HerosInBattle[i].GetComponent <HeroStateMaschine>().currnetState = HeroStateMaschine.TurnState.WAITING;
            }
        }
        break;
        }

        switch (HeroInput)
        {
        case (HeroGuI.ACTIVATE):
            if (HerosToManage.Count > 0)
            {
                //選択したheroにselector表示
                HerosToManage[0].transform.Find("Selector").gameObject.SetActive(true);
                HeroChoise = new HandleTurn();

                //GUIActive
                AttackPanel.SetActive(true);

                CreateAttackButton();
                HeroInput = HeroGuI.WAITING;
            }
            break;

        case (HeroGuI.WAITING):
            //待機
            break;

        case (HeroGuI.DONE):
            HeroInputDone();
            break;
        }
    }
コード例 #19
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()
コード例 #20
0
    // 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()
コード例 #21
0
    // Update is called once per frame
    void Update()
    {
        GameResult();
        //how the battle is progressed each turn
        //Debug.Log ("currentState: "+ currentState);
        switch (currentState)
        {
        case (turnState.START):
            PerformList  = new List <HandleTurn> ();
            playerChoice = new HandleTurn();
            currentState = turnState.PLAYERCHOICE;
            break;

        case (turnState.PLAYERCHOICE):
            if (playerInput == PlayerGUI.DONE)
            {
                currentState = turnState.ENEMYCHOICE;
            }
            break;

        case (turnState.ENEMYCHOICE):
            switch (playerChoice.skill)
            {
            case HandleTurn.skills.DoubleAttack:
                if (PerformList.Count == PlayerInBattle.Count + 1)
                {
                    currentState = turnState.ACTION;
                }

                break;

            case HandleTurn.skills.Attack:
                if (PerformList.Count == PlayerInBattle.Count)
                {
                    currentState = turnState.ACTION;
                }

                break;

            case HandleTurn.skills.AttackAll:
                if (PerformList.Count == PlayerInBattle.Count + 2)
                {
                    currentState = turnState.ACTION;
                }

                break;

            case HandleTurn.skills.Recover:
                //if (PerformList.Count == PlayerInBattle.Count -1)
                //{
                currentState = turnState.ACTION;
                //}
                break;

            case HandleTurn.skills.DeniService:
                currentState = turnState.ACTION;

                break;

            case HandleTurn.skills.ExtraTurn:
                if (PerformList.Count == PlayerInBattle.Count + 1)
                {
                    currentState = turnState.ACTION;
                }

                break;

            case HandleTurn.skills.MinRisk:
                if (PerformList.Count == PlayerInBattle.Count)
                {
                    currentState = turnState.ACTION;
                }
                break;

            case HandleTurn.skills.Sleep:
                if (PerformList.Count == PlayerInBattle.Count - 1)
                {
                    currentState = turnState.ACTION;
                }

                break;

            case HandleTurn.skills.SplashAttack:
                if (PerformList.Count == PlayerInBattle.Count + 1)
                {
                    currentState = turnState.ACTION;
                }

                break;

            case HandleTurn.skills.Wall:
                if (PerformList.Count == PlayerInBattle.Count)
                {
                    currentState = turnState.ACTION;
                }

                break;
            }

            break;

        case (turnState.ACTION):
            //put in the logic here
            skillused();
            // Replace with transition animation
            currentState = turnState.START;
            break;
        }


        //how the player turn is progressed
        //Debug.Log ("playerInput: "+ playerInput);
        switch (playerInput)
        {
        case (PlayerGUI.ACTIVATE):
            playerInput = PlayerGUI.INPUT;
            break;

        case (PlayerGUI.INPUT):
            if (playerChoice.AttackTarget != null)
            {
                playerInput = PlayerGUI.DONE;
            }
            break;

        case (PlayerGUI.DONE):
            if (currentState == turnState.PLAYERCHOICE)
            {
                playerInput = PlayerGUI.ACTIVATE;
            }
            break;
        }
    }
コード例 #22
0
    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;

        ItemPanel.transform.GetChild(0).transform.GetChild(1).gameObject.GetComponent <Text>().text = "x" + hpPotions;
        ItemPanel.transform.GetChild(1).transform.GetChild(1).gameObject.GetComponent <Text>().text = "x" + spPotions;
        switch (battleStates)
        {
        case PerformAction.WAIT:
            if (PerformList.Count > 0)
            {
                battleStates = PerformAction.ACTION;
            }
            break;

        case PerformAction.ACTION:
            GameObject performer = GameObject.Find(PerformList[0].attacker);
            if (PerformList[0].type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();

                ESM.PlayerToAttack = PerformList[0].TargetGO;
                ESM.currenState    = EnemyStateMachine.TurnState.ACTION;
            }
            if (PerformList[0].type == "Player")
            {
                PlayerStateMachine PSM = performer.GetComponent <PlayerStateMachine>();

                PSM.EnemyToAttack = PerformList[0].TargetGO;
                PSM.currentState  = PlayerStateMachine.TurnState.ACTION;
            }
            break;

        case PerformAction.PERFORM:

            break;
        }

        switch (playerInput)
        {
        case PlayerUI.ACTIVATE:
            if (CharsToManage.Count > 0)
            {
                PlayerStateMachine PSM = CharsToManage[0].GetComponent <PlayerStateMachine>();

                CharsToManage[0].transform.Find("pointer").gameObject.SetActive(true);
                PlayerChoice   = new HandleTurn();
                attributeTime  = false;
                hpTurn        += 1;
                defTurn       += 1;
                spdTurn       += 1;
                lukTurn       += 1;
                PSM.defending += 1;
                AttackPanel.SetActive(true);
                playerInput = PlayerUI.WAITING;
                eventSystem.SetSelectedGameObject(atkButton);

                if (spdTurn >= CharsInBattle.Count * CharsInBattle.Count)
                {
                    if (PSM.player.currSPD > PSM.player.maxSPD)
                    {
                        PSM.player.currSPD = PSM.player.maxSPD;
                    }
                }

                if (defTurn >= CharsInBattle.Count * CharsInBattle.Count)
                {
                    if (PSM.player.currDEF > PSM.player.maxDEF)
                    {
                        PSM.player.currDEF = PSM.player.maxDEF;
                    }
                }

                if (lukTurn >= CharsInBattle.Count * CharsInBattle.Count)
                {
                    if (PSM.player.currLUK > PSM.player.maxLUK)
                    {
                        PSM.player.currLUK = PSM.player.maxLUK;
                    }
                }
            }
            if (!stopLeveling)
            {
                if (EnemiesInBattle.Count <= 0)
                {
                    stopLeveling            = false;
                    PlayerUpdateProgressBar = false;
                    WinPanel.SetActive(true);
                    PlayWinMusic();
                    levelCharacter = 0;
                    ExpEarn();
                    stopLeveling = true;
                }
            }

            if (CharsInBattle.Count <= 0)
            {
                stopLeveling = false;
                LosePanel.SetActive(true);
                PlayerUpdateProgressBar = false;
                Lost();
                stopLeveling = true;
            }

            break;

        case PlayerUI.WAITING:
            if (EnemiesInBattle.Count <= 0)
            {
                playerInput = PlayerUI.DONE;
            }
            break;

        case PlayerUI.DONE:
            PlayerInputDone();
            break;

        default:
            break;
        }

        if (EnemySelectPanel.activeSelf)
        {
            if (Input.GetButtonDown("Cancel"))
            {
                EnemySelectPanel.SetActive(false);
                AttackPanel.SetActive(true);
                foreach (GameObject enemyButton in enemyButtons)
                {
                    Destroy(enemyButton);
                }
                foreach (GameObject specialButton in spButtons)
                {
                    Destroy(specialButton);
                }
                foreach (GameObject CostText in costTexts)
                {
                    Destroy(CostText);
                }
                foreach (GameObject attButton in spButtons)
                {
                    Destroy(attButton);
                }

                switch (EnemiesInBattle.Count)
                {
                case 1:
                    EnemiesInBattle[0].transform.Find("pointer").gameObject.SetActive(false);
                    eventSystem.SetSelectedGameObject(atkButton);
                    break;

                case 2:
                    EnemiesInBattle[0].transform.Find("pointer").gameObject.SetActive(false);
                    EnemiesInBattle[1].transform.Find("pointer").gameObject.SetActive(false);
                    eventSystem.SetSelectedGameObject(atkButton);
                    break;

                case 3:
                    EnemiesInBattle[0].transform.Find("pointer").gameObject.SetActive(false);
                    EnemiesInBattle[1].transform.Find("pointer").gameObject.SetActive(false);
                    EnemiesInBattle[2].transform.Find("pointer").gameObject.SetActive(false);
                    eventSystem.SetSelectedGameObject(atkButton);
                    break;
                }
            }
        }

        if (ItemPanel.activeSelf)
        {
            if (Input.GetButtonDown("Cancel"))
            {
                ItemPanel.SetActive(false);
                AttackPanel.SetActive(true);
                eventSystem.SetSelectedGameObject(atkButton);
            }
        }

        if (levelUp)
        {
            if (timer >= 3)
            {
                ExpEarn();
                LevelUp();
            }
        }
        else
        {
            if (returning)
            {
                if (timer >= 1)
                {
                    if (!stopShowing)
                    {
                        GameObject clone2 = Instantiate(popUp, popUp.transform.position, popUp.transform.rotation, GameObject.FindGameObjectWithTag("Canvas").transform);
                        clone2.GetComponent <Text>().text = "+" + spPup + " SP Potions";

                        Destroy(clone2, 1f);

                        stopShowing = true;
                    }
                }
                if (timer >= 3)
                {
                    SceneManager.LoadScene("Test");
                }
            }
        }

        if (lost)
        {
            if (timer >= 8)
            {
                SceneManager.LoadScene("GameOver");
            }
        }

        if (SpecialPanel.activeSelf)
        {
            if (Input.GetButtonDown("Cancel"))
            {
                SpecialPanel.SetActive(false);
                DescriptionPanel.SetActive(false);
                CostPanel.SetActive(false);
                AttackPanel.SetActive(true);

                foreach (GameObject specialButton in spButtons)
                {
                    Destroy(specialButton);
                }

                foreach (GameObject CostText in costTexts)
                {
                    Destroy(CostText);
                }

                foreach (GameObject attButton in spButtons)
                {
                    Destroy(attButton);
                }

                eventSystem.SetSelectedGameObject(atkButton);
            }
        }
    }
コード例 #23
0
    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;

        }
    }
コード例 #24
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;
        }
    }
コード例 #25
0
    // Sorts character objects by their priority (int)
    // PC: 0
    // Party characters: 2-5
    // Boss characters : +10
    // Standard enemies: +50
    private static int SortCharactersByPriority(HandleTurn h1, HandleTurn h2)
    {
        return(h1.Priority.CompareTo(h2.Priority));

        //return 0;
    }//*/
コード例 #26
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;
        }
    }
コード例 #27
0
    // Update is called once per frame
    void Update()
    {
        // controlle se isActive è uguale a true
        if (isactive)
        {
            // sommo il tempo al timer
            timer += Time.deltaTime;
            // controllo se il timer è maggiore di start timer
            if (timer >= startTimer)
            {
                //uso la funzione set active Per impostare testo a false
                testo.SetActive(false);
                //imposto il timer a 0
                timer = 0;
                //imposto isActive a false
                isactive = false;
            }
        }
        // creo uno switch fra battle state
        switch (BattleState)
        {
        //creo il primo caso
        case (PerformAction.Wait):
            //controllo se la performlist.conunt è maggiore di 0
            if (performList.Count > 0)
            {
                //cambio lo stato il take action
                BattleState = PerformAction.TakeAction;
            }

            break;

        //caso 2
        case (PerformAction.TakeAction):
            //assegno il performer all al primo numero degli attakers della performList
            GameObject performer = GameObject.Find(performList[0].Attacker);
            //controllo se il tipo della perform list è uguale a Enemy
            if (performList[0].Type == "Enemy")
            {
                //assegno a ESM il lo script EnemyStateMachine del performer
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                //per ogni eroe in gioco
                for (int i = 0; i < HerosInGame.Count; i++)
                {
                    //controllo quando l'eroe in gioco e attacksTarget combaciano
                    if (performList[0].AttacksTarget == HerosInGame[i])
                    {
                        // assegno a ESM.heroToAttack l'eroe giusto tramite il controllo di prima
                        ESM.heroToAttack = performList[0].AttacksTarget;
                        // cambio il currentState di ESM in action
                        ESM.CurrentState = EnemyStateMachine.TurnState.Action;
                        break;
                    }
                    else
                    {
                        //randomizzo il player da attaccare
                        performList[0].AttacksTarget = HerosInGame[Random.Range(0, HerosInGame.Count)];
                        // assegno a ESM.heroToAttack l'eroe randomizzato
                        ESM.heroToAttack = performList[0].AttacksTarget;
                        // cambio il currentState di ESM in action
                        ESM.CurrentState = EnemyStateMachine.TurnState.Action;
                    }
                }
            }
            // controllo se il tipo della perform list è uguale a Player
            if (performList[0].Type == "Player")
            {
                //assegno a HSM  lo script HeroStateM del performer
                HeroStateM HSM = performer.GetComponent <HeroStateM>();
                // assegno a HSM.enemyToAttack il nemico scelto
                HSM.enemyToAttack = performList[0].AttacksTarget;
                // cambio il currentState di HSM in action
                HSM.CurrentState = HeroStateM.TurnState.Action;
            }
            //cambio il BattleState a PerformAction
            BattleState = PerformAction.PerformAction;
            break;

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

        //caso4
        case (PerformAction.CheckAlive):
            //se gli eroi in game sono minori di 1
            if (HerosInGame.Count < 1)
            {
                // cambio il battle state a lose
                BattleState = PerformAction.Lose;
                //lose the battle
            }
            // se i nemici in gioco sono minori di 1
            else if (EnemyInGame.Count < 1)
            {
                // cambio il battle state a 1
                BattleState = PerformAction.Win;
                //win the battle
            }
            else
            {
                //chiamo la funzione clearAttackPanel
                clearAttackPanel();
                //cambio l'HeroInput in activate
                HeroInput = HeroGUI.Activate;
            }
            break;

        //caso5
        case (PerformAction.Lose):
        {
            //vado nella scena di gameOver
            SceneManager.LoadScene("GameOver");
        }
        break;

        //caso6
        case (PerformAction.Win):
        {
            //per ogni eroe in game
            for (int i = 0; i < HerosInGame.Count; i++)
            {
                //cambio lo stato in wating
                HerosInGame[i].GetComponent <HeroStateM>().CurrentState = HeroStateM.TurnState.Waiting;
            }
            //attivo il testo cura
            testoCura.SetActive(true);
            //sommo il timer al tempo
            timer += Time.deltaTime;
            //controllo se il timer è maggiore dello start timer e se isBoss e uguale a false
            if (timer >= startTimer && isBoss == false)
            {
                //disattivo il testo cura
                testoCura.SetActive(false);
                // imposto timer a 0
                timer = 0;
                //chiamo la funzione LoadSceneAfterBattle
                GameManager.instace.LoadSceneAfterBattle();
                //cambio il game state a WorldState
                GameManager.instace.gameState = GameManager.GameState.WorldState;
                //pulisco gli enemyToBattle
                GameManager.instace.EnemysToBattle.Clear();
            }
            //se isBoss e uguale a true
            else if (isBoss == true)
            {
                //cambio scena in vittoria
                SceneManager.LoadScene("Win");
            }
        }
        break;
        }

        // creo uno switch  per l'hero imput
        switch (HeroInput)
        {
        //caso1
        case (HeroGUI.Activate):
            //se hero to manage è maggiore di 0
            if (HeroToManage.Count > 0)
            {
                //cerco il selecter del heroToManage e lo attivo
                HeroToManage[0].transform.Find("Selecter").gameObject.SetActive(true);
                //assengo a HeroChoice un nuovo HandleTurn
                HeroChoice = new HandleTurn();
                //attivo l'AttackPanel
                AttackPanel.SetActive(true);
                //chiamo la funzione cretataAttackButtons
                createAttackButtons();
                //Cambio l'HeroInput a wating
                HeroInput = HeroGUI.Waiting;
            }
            break;

        //caso3
        case (HeroGUI.Waiting):
            //idle
            break;

        //caso4
        case (HeroGUI.Done):
            //chaimo la funzione HeroInputDone
            HeroInputDone();
            break;
        }
    }
コード例 #28
0
 public void CollectActionInformation(HandleTurn input) //require handleturn input
 {
     performList.Add(input);
 }
コード例 #29
0
 public void CollectActions(HandleTurn input)
 {
     PerformList.Add(input);
 }
コード例 #30
0
 public void CollectAction(HandleTurn action)
 {
     actions.Enqueue(action);
 }