Exemplo n.º 1
0
    // Update is called once per frame
    private void Update()
    {
        switch (battleState)
        {
        case PerformAction.Waiting:
            if (actions.Count > 0)
            {
                battleState = PerformAction.PrepareAction;
            }
            break;

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

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

            battleState = PerformAction.PerformAction;
            break;

        case PerformAction.PerformAction:
            // idle
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

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

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

        case HeroGui.Waiting:
            // idle;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
Exemplo n.º 2
0
 //////////////////////////////////////////
 // Attack input management             //
 ////////////////////////////////////////
 private void AttackInput()
 {
     CreateAttackButtons();
     actionPanel.SetActive(false);
     attackPanel.SetActive(true);
     heroInput = HeroGui.SelectItem;
 }
Exemplo n.º 3
0
 private void HeroInputDone()
 {
     performList.Add(_heroChoice);
     enemySelectPanel.SetActive(false);
     heroesToManage[0].transform.Find("Selector").gameObject.SetActive(false);
     heroesToManage.RemoveAt(0);
     heroInput = HeroGui.Activate;
 }
Exemplo n.º 4
0
 public void HeroInputDone()
 {
     PerformList.Add(TargetSelection);
     EnemySelectPanel.SetActive(false);
     HerosToManage[0].transform.FindChild("Selector").gameObject.SetActive(false);
     HerosToManage.RemoveAt(0);
     HeroInput = HeroGui.Activate;
 }
Exemplo n.º 5
0
 public void VoiceInput(HandleTurn turn)
 {
     performList.Add(turn);
     actionPanel.SetActive(false);
     attackPanel.SetActive(false);
     enemySelectPanel.SetActive(false);
     heroesToManage[0].transform.Find("Selector").gameObject.SetActive(false);
     heroesToManage.Remove(turn.AttackerGO);
     heroInput = HeroGui.Activate;
 }
Exemplo n.º 6
0
 //////////////////////////////////////////
 // Target input management             //
 ////////////////////////////////////////
 public void SelectTargetInput(BaseAttack attack)
 {
     _heroChoice.Attacker   = heroesToManage[0].name;
     _heroChoice.AttackerGO = heroesToManage[0];
     _heroChoice.Type       = "Hero";
     _heroChoice.Attack     = attack;
     CreateEnemyButtons();
     attackPanel.SetActive(false);
     enemySelectPanel.SetActive(true);
     heroInput = HeroGui.SelectTarget;
 }
Exemplo n.º 7
0
    void HeroInputDone()
    {
        PerformList.Add(HeroChoice);
        // clean the attackpanel
        ClearAttackPanel();
        EnemySelectPanel.SetActive(false);

        HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(false);
        HeroesToManage.RemoveAt(0);
        HeroInput = HeroGui.Activate;
    }
Exemplo n.º 8
0
    void Start()
    {
        battleState = PerformAction.Wait;
        EnemiesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy"));
        HerosInBattle.AddRange(GameObject.FindGameObjectsWithTag("Hero"));
        HeroInput = HeroGui.Activate;

        ShowAttackPanel.SetActive(false);
        AttackPanel.SetActive(false);
        EnemySelectPanel.SetActive(false);
        EnemyButtons();
    }
Exemplo n.º 9
0
    // Start is called before the first frame update
    private void Start()
    {
        battleState = PerformAction.Waiting;
        enemiesAlive.AddRange(GameObject.FindGameObjectsWithTag("Enemy"));
        heroesAlive.AddRange(GameObject.FindGameObjectsWithTag("Hero"));

        HeroInput = HeroGui.Activate;
        AttackPanel.SetActive(false);
        EnemySelectPanel.SetActive(false);

        CreateEnemyButtons();
    }
Exemplo n.º 10
0
    public void InputEnemy(GameObject enemySelected)
    {
        HeroStateMachine hsm = HeroSelected.GetComponent <HeroStateMachine>();

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

        heroesToManage.RemoveAt(0);

        EnemySelectPanel.SetActive(false);
        HeroInput = HeroGui.Activate;
    }
 void Start()
 {
     Debug.Log("victoryBool = " + victoryBool);
     battleStates = PerformAction.Wait;
     HeroesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Hero"));
     EnemiesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy"));
     HeroInput = HeroGui.Activate;
     HeroSelectPanel.SetActive(false);
     ActionPanel.SetActive(false);
     EnemySelectPanel.SetActive(false);
     MagicPanel.SetActive(false);
     EnemyButtons();
     HeroButtons();
 }
    void HeroInputDone()
    {
        PerformList.Add(HeroChoise);
        clearActionPanel();

        foreach(GameObject actBtn in actBtns)
        {
            Destroy(actBtn);
        }
        actBtns.Clear();

        HeroesToManage[0].transform.Find("Selector").gameObject.SetActive(false);
        HeroesToManage.RemoveAt(0);
        HeroInput = HeroGui.Activate;
    }
Exemplo n.º 13
0
    // Use this for initialization
    void Start()
    {
        battleState = PerformAction.Wait;
        heroesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Hero"));
        enemiesInBattle.AddRange(GameObject.FindGameObjectsWithTag("Enemy"));

        _heroNameText = heroName.transform.Find("Text").GetComponent <Text>();

        heroInput = HeroGui.Activate;

        turnActionPanel.SetActive(false);
        _turnActionText = turnActionPanel.transform.Find("TurnText").GetComponent <Text>();
        actionPanel.SetActive(false);
        attackPanel.SetActive(false);
        enemySelectPanel.SetActive(false);

        _enemiesSpacer = enemySelectPanel.transform;
        _actionSpacer  = actionPanel.transform;
        _attackSpacer  = attackPanel.transform;

        CreateActionButtons();
    }
    //hero selection
    public void Input5(GameObject choosenHero)
    {
        HeroChoise.AttackersTarget = choosenHero;

        HeroInput = HeroGui.Done;
    }
 //enemy selection
 public void Input2(GameObject choosenEnemy)
 {
     HeroChoise.AttackersTarget = choosenEnemy;
     HeroInput = HeroGui.Done;
 }
Exemplo n.º 16
0
    // Update is called once per frame
    void Update()
    {
        switch (battlestates)
        {
        case (PerformAction.Wait):
            if (PerformList.Count > 0)
            {
                battlestates = PerformAction.TakeAction;
            }



            break;

        case (PerformAction.TakeAction):
            GameObject performer = GameObject.Find(PerformList[0].Attacker);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStateMachine ESM = performer.GetComponent <EnemyStateMachine>();
                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;
        }
    }
Exemplo n.º 17
0
 public void Input2(GameObject chosenEnemy)//enemy selection
 {
     HeroChoice.AttackersTarget = chosenEnemy;
     HeroInput = HeroGui.Done;
 }
Exemplo n.º 18
0
    // Update is called once per frame
    void Update()
    {
        switch (battleState)
        {
        case (PerformAction.Wait):
            if (PerformList.Count > 0)
            {
                battleState = PerformAction.TakeAction;
            }
            break;

        case (PerformAction.TakeAction):
            GameObject performer = GameObject.Find(PerformList[0].Attacker);
            if (PerformList[0].Type == "Enemy")
            {
                EnemyStatesBattle Esm = performer.GetComponent <EnemyStatesBattle>();
                Esm.HeroToAttack = PerformList[0].AttackersTarget;
                displayAttack();
                Esm.currentState = EnemyStatesBattle.TurnState.Action;
            }

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

            battleState = PerformAction.PerformAction;
            break;

        case (PerformAction.PerformAction):

            break;
        }

        switch (HeroInput)
        {
        case (HeroGui.Activate):
            if (HerosToManage.Count > 0)
            {
                HerosToManage[0].transform.FindChild("Selector").gameObject.SetActive(true);
                TargetSelection = new HandleTurn();
                AttackPanel.SetActive(true);
                HeroInput = HeroGui.Wait;
            }
            break;

        case (HeroGui.Wait):

            break;

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

        case (HeroGui.Input1):

            break;

        case (HeroGui.Input2):

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

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

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

        case (PerformAction.PerformAction):

            break;

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

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

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

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

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

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

        case (HeroGui.Waiting):

            break;

        case (HeroGui.Done):
            HeroInputDone();
            break;
        }
    }
Exemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        switch (battleState)
        {
        case PerformAction.Wait:
            turnActionPanel.SetActive(false);
            ClearAttackPanel();
            battleState = PerformAction.HeroesTurn;
            break;

        case PerformAction.HeroesTurn:
            if (performList.Count == heroesInBattle.Count)
            {
                heroName.SetActive(false);
                battleState = PerformAction.EnemiesTurn;
            }
            break;

        case PerformAction.EnemiesTurn:
            if (performList.Count == heroesInBattle.Count + enemiesInBattle.Count)
            {
                battleState = PerformAction.TakeAction;
            }
            break;

        case PerformAction.TakeAction:
            var performance = performList[0];
            var performer   = performance.AttackerGO;

            var turnText = "";

            if (performList[0].Type == "Enemy")
            {
                var esm = performer.GetComponent <EnemyStateMachine>();
                // If the target is still in the battle, the enemy attacks it
                if (heroesInBattle.Count(hero => hero.gameObject == performance.AttackerTarget) > 0)
                {
                    esm.heroTarget   = performance.AttackerTarget;
                    esm.currentState = EnemyStateMachine.TurnState.Action;
                }
                // If the target is not in the battle anymore but there are still heroes, takes one randomly
                else if (heroesInBattle.Count > 0)
                {
                    esm.heroTarget   = heroesInBattle[Random.Range(0, heroesInBattle.Count)];
                    esm.currentState = EnemyStateMachine.TurnState.Action;
                }
                else
                {
                    break;
                }
                turnText = string.Format("{0} attaque {1} avec {2} !", performance.Attacker,
                                         performance.AttackerTarget.GetComponent <HeroStateMachine>().hero.Name,
                                         performance.Attack.attackName);
            }
            else if (performList[0].Type == "Hero")
            {
                var hsm = performer.GetComponent <HeroStateMachine>();
                hsm.enemyTarget  = performList[0].AttackerTarget;
                hsm.currentState = HeroStateMachine.TurnState.Action;
                turnText         = string.Format("{0} attaque {1} avec {2} !", performance.Attacker,
                                                 performance.AttackerTarget.GetComponent <EnemyStateMachine>().enemy.Name,
                                                 performance.Attack.attackName);
            }
            if (turnText != "")
            {
                _turnActionText.text = turnText;
                turnActionPanel.SetActive(true);
            }

            battleState = PerformAction.PerformAction;
            break;

        case PerformAction.PerformAction:
            break;

        case PerformAction.CheckAlive:
            if (heroesInBattle.Count < 1)
            {
                battleState = PerformAction.Lose;
            }
            else if (enemiesInBattle.Count < 1)
            {
                battleState = PerformAction.Win;
            }
            else
            {
                ClearAttackPanel();
                battleState = performList.Count <= 0 ? PerformAction.Wait : PerformAction.TakeAction;
            }
            break;

        case PerformAction.Win:
            _turnActionText.text = "C'est gagné, belle victoire !";
            turnActionPanel.SetActive(true);
            heroesInBattle.ForEach(
                hero => { hero.GetComponent <HeroStateMachine>().currentState = HeroStateMachine.TurnState.Waiting; });
            break;

        case PerformAction.Lose:
            _turnActionText.text = "C'est perdu, dommage.";
            turnActionPanel.SetActive(true);
            break;
        }

        switch (heroInput)
        {
        case HeroGui.Activate:
            if (heroesToManage.Count > 0)
            {
                GameObject hero = heroesToManage[0];
                hero.transform.Find("Selector").gameObject.SetActive(true);
                _heroChoice = new HandleTurn();

                actionPanel.SetActive(true);

                heroName.SetActive(true);
                turnActionPanel.SetActive(true);
                _heroNameText.text = _turnActionText.text = hero.GetComponent <HeroStateMachine>().hero.Name;

                heroInput = HeroGui.SelectAction;
            }
            break;

        case HeroGui.SelectAction:
            break;

        case HeroGui.SelectItem:
            break;

        case HeroGui.SelectTarget:
            break;

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

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

            case (PerformAction.PerformAction):

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

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

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

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

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

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

            case (HeroGui.Waiting):

                break;

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

        }
    }
Exemplo n.º 22
0
 public void EnemySelectInput(GameObject chosenEnemy)
 {
     _heroChoice.Attacker       = heroesToManage[0].GetComponent <HeroStateMachine>().hero.Name;
     _heroChoice.AttackerTarget = chosenEnemy;
     heroInput = HeroGui.Done;
 }