Beispiel #1
0
    void Update()
    {
        switch (currentState)
        {
        case (TurnState.PROCESSING):
            UpgradeProgressBar();
            break;

        case (TurnState.CHOOSEACTION):
            ChooseAction();
            currentState = TurnState.WAITING;
            break;

        case (TurnState.WAITING):
            break;



        case (TurnState.ACTION):
            StartCoroutine(TimeForAction());
            break;

        case (TurnState.DEAD):
            if (!alive)
            {
                return;
            }
            else
            {
                //change tag of enemy
                this.gameObject.tag = "DeadEnemy";
                //not attackable by heroes
                BSM.EnemysInBattle.Remove(this.gameObject);
                //disable select
                Selector.SetActive(false);
                if (BSM.EnemysInBattle.Count > 0)
                {
                    for (int i = 0; i < BSM.PerformList.Count; i++)
                    {
                        if (i != 0)
                        {
                            if (BSM.PerformList[i].AttackersGameObject == this.gameObject)
                            {
                                BSM.PerformList.Remove(BSM.PerformList[i]);
                            }
                            if (BSM.PerformList[i].AttackersTarget == this.gameObject)
                            {
                                BSM.PerformList[i].AttackersTarget = BSM.EnemysInBattle[Random.Range(0, BSM.EnemysInBattle.Count)];
                            }
                        }
                    }
                }
                this.gameObject.GetComponent <MeshRenderer>().material.color = new Color32(105, 105, 105, 255);
                alive = false;
                BSM.EnemyButtons();
                BSM.battleStates = BattleStateMachine.PerformAction.CHECKALIVE;
            }
            break;
        }
    }
Beispiel #2
0
    void Update()
    {
        switch (currentState)
        {
        case (TurnState.PROCESSING):
            UpgradeProgressBar();
            break;

        case (TurnState.CHOOSEACTION):
            ChooseAction();
            currentState = TurnState.WAITING;
            break;

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

        case (TurnState.ACTION):
            StartCoroutine(TimeForAction());
            break;

        case (TurnState.DEAD):
            if (!IsAlive)
            {
                return;
            }
            else
            {
                this.gameObject.tag = "DeadEnemy";
                BSM.EnemiesInBattle.Remove(this.gameObject);
                Selector.SetActive(false);
                if (BSM.EnemiesInBattle.Count > 0)
                {
                    for (int i = 0; i < BSM.PreformList.Count; i++)
                    {
                        if (BSM.PreformList[i].AttackersGameObject == this.gameObject)
                        {
                            BSM.PreformList.Remove(BSM.PreformList[i]);
                        }
                        else if (BSM.PreformList[i].AttackersTarget == this.gameObject)
                        {
                            BSM.PreformList[i].AttackersTarget = BSM.EnemiesInBattle[Random.Range(0, BSM.EnemiesInBattle.Count)];
                        }
                    }
                }
                this.gameObject.GetComponent <MeshRenderer>().material.color = new Color32(105, 105, 105, 255);
                IsAlive = false;
                // reset enemy buttons
                BSM.EnemyButtons();
                // check Alive
                BSM.currentAction = BattleStateMachine.PreformAction.CHECKALIVE;
            }
            break;
        }
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
        case (TurnState.PROCESSING):
            FillProgressBar();
            break;

        case (TurnState.READY):
            ChooseAction();
            currentState = TurnState.WAITING;
            break;

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

        case (TurnState.ACTION):
            StartCoroutine(timeForAction());
            break;

        case (TurnState.DEAD):
            if (!alive)
            {
                return;
            }
            else
            {
                //tag as dead
                this.gameObject.tag = "DeadEnemy";
                //no longer attackable
                BSM.enemiesInBattle.Remove(this.gameObject);
                //disable selector
                selector.SetActive(false);
                for (int i = 0; i < BSM.performList.Count; i++)
                {
                    if (BSM.performList[i].attackerGameObject == this.gameObject)
                    {
                        BSM.performList.Remove(BSM.performList[i]);
                    }
                }
                //animate death?
                this.gameObject.GetComponent <SpriteRenderer>().enabled = false;
                alive = false;
                //reset enemy select buttons
                BSM.EnemyButtons();
                //check if battle is over
                BSM.battleStates = BattleStateMachine.PerformAction.CHECKALIVE;
            }
            break;
        }
    }
Beispiel #4
0
    public void Die()
    {
        gameObject.tag = "DeadEnemy";
        BSM.enemiesInBattle.Remove(gameObject);
        selector.SetActive(false);

        if (BSM.enemiesInBattle.Count < 0)
        {
            for (int i = 0; i < BSM.actionsInTurn.Count; i++)
            {
                if (BSM.actionsInTurn[i].attackerGameObject == this)
                {
                    BSM.actionsInTurn.Remove(BSM.actionsInTurn[i]);
                }

                foreach (GameObject target in BSM.actionsInTurn[i].targets)
                {
                    if (target == gameObject)
                    {
                        BSM.actionsInTurn[i].targets.Remove(gameObject);
                        if (BSM.actionsInTurn[i].targets.Count <= 0)
                        {
                            BSM.actionsInTurn[i].targets = new List <GameObject>
                            {
                                BSM.enemiesInBattle[Random.Range(0, BSM.enemiesInBattle.Count)]
                            };
                        }
                    }
                }
            }
        }

        gameObject.GetComponent <MeshRenderer>().material.color = Color.black;
        isAlive = false;
        BSM.EnemyButtons();
        BSM.battleState = BattleStateMachine.PerformAction.CHECK_ALIVE;
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
        case (TurnState.Processing):
            UpgradeProgressBar();
            break;

        case (TurnState.ChoseAction):
            chooseAction();
            currentState = TurnState.Waiting;
            break;

        case (TurnState.Waiting):
            //idle state
            break;

        case (TurnState.Action):
            StartCoroutine(TimeForAction());
            break;

        case (TurnState.Dead):
            if (!alive)
            {
                return;
            }
            else
            {
                //change the tag of the enemy
                this.gameObject.tag = "DeadEnemy";
                //not attackable by heroes
                BSM.EnemysInBattle.Remove(this.gameObject);
                //disable the selector
                Selector.SetActive(false);
                //remove all inputs enemyattacks
                if (BSM.EnemysInBattle.Count > 0)
                {
                    for (int i = 0; i < BSM.PerformList.Count; i++)
                    {
                        if (BSM.PerformList[i].AttackersGameObject == this.gameObject)
                        {
                            BSM.PerformList.Remove(BSM.PerformList[i]);
                        }
                        if (BSM.PerformList[i].AttackersTarget == this.gameObject)
                        {
                            BSM.PerformList[i].AttackersTarget = BSM.EnemysInBattle[Random.Range(0, BSM.EnemysInBattle.Count)];
                        }
                    }
                }
                //change the color to gray / play dead animation
                this.gameObject.GetComponent <MeshRenderer>().material.color = new Color32(105, 105, 105, 255);
                //set alive false
                alive = false;
                //reset enemy buttons
                BSM.EnemyButtons();
                //check alive
                BSM.BattleStates = BattleStateMachine.PerformAction.CheckAlive;
            }
            break;
        }
        void UpgradeProgressBar()
        {
            cur_cooldown = cur_cooldown + Time.deltaTime;

            if (cur_cooldown >= max_cooldown)
            {
                currentState = TurnState.ChoseAction;
            }
        }
    }
Beispiel #6
0
    void Update()
    {
        if (bm.GetComponent <BattleStateMachine>().loseBool)
        {
            anim.SetBool("Victory", true);
        }
        //Debug.Log(currentState);
        switch (currentState)
        {
        case (TurnState.Processing):
            UpdateProgress();
            break;

        case (TurnState.ChooseAction):
            ChooseAction();

            currentState = TurnState.Waiting;
            break;

        case (TurnState.Waiting):

            break;

        case (TurnState.Action):

            StartCoroutine(TimeForAction());
            break;

        case (TurnState.Dead):
            if (!alive)
            {
                return;
            }
            else
            {
                //change tag
                this.gameObject.tag = "DeadEnemy";
                //not attackable by enemy
                BSM.EnemiesInBattle.Remove(this.gameObject);
                //not manageable
                BSM.EnemiesInBattle.Remove(this.gameObject);
                //deactivate the selector
                Selector2.SetActive(false);
                if (BSM.EnemiesInBattle.Count > 0)
                {
                    //remove item from performlist
                    for (int i = 0; i < BSM.PerformList.Count; i++)
                    {
                        if (i != 0)
                        {
                            if (BSM.PerformList[i].AttackersGameObject == this.gameObject)
                            {
                                BSM.PerformList.Remove(BSM.PerformList[i]);
                            }
                            if (BSM.PerformList[i].AttackersTarget == this.gameObject)
                            {
                                BSM.PerformList[i].AttackersTarget = BSM.EnemiesInBattle[Random.Range(0, BSM.EnemiesInBattle.Count - 1)];
                            }
                        }
                    }
                }
                //change color  / play animation
                audioData.Play(0);
                anim.SetTrigger("isDead");

                //set alive false
                alive = false;
                //reset enemybuttons
                BSM.EnemyButtons();
                //check alive
                BSM.battleStates = BattleStateMachine.PerformAction.Checkalive;
                break;
            }
        }
    }
    void Update()
    {
        if (!alive)
        {
            currentState = TurnState.DEAD;
        }
        switch (currentState)
        {
        case TurnState.PROCESSING:
            UpdateProgressBar();
            break;

        case TurnState.CHOOSEACTION:
            ChooseAction();
            currentState = TurnState.WAITING;
            break;

        case TurnState.WAITING:

            break;

        case TurnState.ACTION:
            StartCoroutine(TimeForAction());
            break;

        case TurnState.DEAD:
            if (!alive)
            {
                break;
            }
            else
            {
                //change tag to dead
                this.gameObject.tag = "DeadEnemy";
                //disable the selector
                selector.SetActive(false);
                //cannot be targeted
                battleSM.enemiesInBattle.Remove(this.gameObject);

                //remove all inputs by this enemy
                if (this.battleSM.enemiesInBattle.Count > 0)
                {
                    for (int i = 0; i < battleSM.performList.Count; i++)
                    {
                        if (i > 0)
                        {
                            if (battleSM.performList[i].attackerGameObject == this.gameObject)
                            {
                                battleSM.performList.Remove(battleSM.performList[i]);
                            }
                            if (battleSM.performList[i].targetGameObject == this.gameObject)
                            {
                                battleSM.performList[i].targetGameObject = battleSM.enemiesInBattle[Random.Range(0, this.battleSM.enemiesInBattle.Count)];
                            }
                        }
                    }
                }
                //change the color to gray / play dead animation
                this.gameObject.GetComponent <MeshRenderer>().material.color = new Color32(0, 0, 0, 25);
                Vector3 deadPosition = new Vector3(startPosition.x - 2f, startPosition.y, startPosition.z);
                transform.position = deadPosition;

                //reset enemy buttons
                battleSM.EnemyButtons();
                //check alive
                battleSM.battleState = BattleStateMachine.PerformAction.CHECKALIVE;
                //set alive to be false
                alive = false;
            }
            break;

        default:
            break;
        }
    }
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(currentState);
        switch (currentState)
        {
        case (TurnState.Processing):
            UpgradeProgressbar();
            break;


        case (TurnState.ChooseAction):
            if (BSM.HerosInBattle.Count > 0)
            {
                ChooseAction();
            }
            currentState = TurnState.Waiting;
            break;

        case (TurnState.Waiting):
            //idle state
            break;

        case (TurnState.Action):
            StartCoroutine(TimeForAction());
            break;

        case (TurnState.Dead):
            if (!alive)
            {
                return;
            }
            else
            {
                //change tag of enemy
                this.gameObject.tag = "DeadEnemy";
                //not attackable by heroes
                BSM.EnemiesInBattle.Remove(this.gameObject);
                //disable the selector
                Selector.SetActive(false);
                //remove all inputs heroattacks
                if (BSM.EnemiesInBattle.Count > 0)
                {
                    for (int i = 0; i < BSM.PerformList.Count; i++)
                    {
                        if (BSM.PerformList[i].AttackersGameObject == this.gameObject)
                        {
                            BSM.PerformList.Remove(BSM.PerformList[i]);
                        }
                        if (BSM.PerformList[i].AttackersTarget == this.gameObject)
                        {
                            BSM.PerformList[i].AttackersTarget = BSM.EnemiesInBattle[Random.Range(0, BSM.EnemiesInBattle.Count)];
                        }
                    }
                }
                //change the color to gray / fade out
                //this.gameObject.GetComponent<SpriteRenderer>().material.color = new Color32(105, 105, 105, 255);
                Destroy(this.gameObject);

                alive = false;
                //reset enemybutton
                BSM.EnemyButtons();
                //Announce enemy defeated
                Debug.Log("");
                //check alive
                BSM.battlestates = BattleStateMachine.PerformAction.CheckAlive;
            }
            break;
        }
    }
Beispiel #9
0
    // Update is called once per frame
    void Update()
    {
        //Testing state switches
        //Debug.Log(currentState);
        switch (currentState)
        {
        case (TurnState.PROCESSING):
            UpdateProgressBar();
            break;

        case (TurnState.CHOOSEACTION):
            ChooseAction();
            currentState = TurnState.WAITING;
            break;

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

        case (TurnState.ACTION):
            StartCoroutine(TimeForAction());
            break;

        case (TurnState.DEAD):

            if (!alive)
            {
                return;
            }
            else
            {
                //change tag of enemy
                this.gameObject.tag = "DeadEnemy";
                //not attackable by heroes
                BSM.EnemiesInBattle.Remove(this.gameObject);
                //dissable selector
                selector.SetActive(false);
                //remove all input from this enemy from perform list
                if (BSM.EnemiesInBattle.Count > 0)
                {
                    for (int i = 0; i < BSM.PerformList.Count; i++)
                    {
                        if (BSM.PerformList [i].AttackersGameObject == this.gameObject)
                        {
                            BSM.PerformList.Remove(BSM.PerformList [i]);
                        }
                        //changes heroes target to a random enemy if the enemy it previously selected died
                        if (BSM.PerformList [i].AttackersTarget == this.gameObject)
                        {
                            BSM.PerformList [i].AttackersTarget = BSM.EnemiesInBattle [Random.Range(0, BSM.EnemiesInBattle.Count)];
                        }
                    }
                }
                //change color/death animations
                this.gameObject.GetComponent <MeshRenderer>().material.color = new Color32(105, 105, 105, 255);
                //set alive to be false
                alive = false;
                //reset enemy buttons
                BSM.EnemyButtons();
                //check alive
                BSM.battleState = BattleStateMachine.PerformAction.CHECKALIVE;
            }



            break;
        }
    }
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
        case (TurnState.PROCESSING):
        {
            UpgradeProgressBar();

            break;
        }

        case (TurnState.CHOOSEACTION):
        {
            ChooseAction();
            currentState = TurnState.WAITING;

            break;
        }

        case (TurnState.WAITING):
        {
            //idle

            break;
        }

        case (TurnState.ACTION):
        {
            StartCoroutine(TimeForAction());

            break;
        }

        case (TurnState.DEAD):
        {
            if (!alive)
            {
                return;
            }
            else
            {
                //change tag
                this.gameObject.tag = "DeadEnemy";
                //not attackable
                BSM.EnemysInBattle.Remove(this.gameObject);
                //disable selector
                Selector.SetActive(false);
                //remove all inputs heroattks
                if (BSM.EnemysInBattle.Count > 0)
                {
                    for (int i = 0; i < BSM.PerformList.Count; i++)
                    {
                        if (BSM.PerformList[i].AttackersGameObject == this.gameObject)
                        {
                            BSM.PerformList.Remove(BSM.PerformList[i]);
                        }

                        if (BSM.PerformList[i].AttackersTarget == this.gameObject)
                        {
                            BSM.PerformList[i].AttackersTarget = BSM.EnemysInBattle[Random.Range(0, BSM.EnemysInBattle.Count)];
                        }
                    }
                }

                //chagnge color/play dead animations i guess
                this.gameObject.GetComponent <SpriteRenderer>().color = new Color32(105, 105, 105, 255);
                //set alive
                alive = false;
                //reset enemybuttons
                BSM.EnemyButtons();
                //check if battle is won/lost already
                BSM.battleStates = BattleStateMachine.PerformAction.CHECKALIVE;
            }

            break;
        }
        }
    }
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(currentState);
        switch (currentState)
        {
        case (TurnState.PROCESSING): //State for when the wait bar is filling
            UpdateProgressBar();     //Updates the Wait Time
            break;

        case (TurnState.CHOOSEACTION):        //State for Choosing an action for the enemy to perform
            ChooseAction();                   //Randomly choose an action
            currentState = TurnState.WAITING; //Sets the state to Waiting
            break;

        case (TurnState.ACTION):             //State for starting the chosen action
            StartCoroutine(TimeForBattle()); //Starts the selected action
            currentState = TurnState.WAITING;
            break;

        case (TurnState.DEAD):     //Dead State
            if (!isAlive)
            {
                return;
            }
            else
            {
                //Change Tag to Dead Enemy
                this.gameObject.tag = "Dead Enemy";
                //Make Not Attackable by Player Character
                bsm.enemiesInBattle.Remove(this.gameObject);
                //If Action was selected, Remove from Perform List
                if (bsm.enemiesInBattle.Count > 0)
                {
                    for (int i = 0; i < bsm.performList.Count; i++)
                    {
                        if (bsm.performList[i].attackerGameObject == this.gameObject)
                        {
                            bsm.performList.Remove(bsm.performList[i]);
                        }

                        if (bsm.performList[i].attackersTarget == this.gameObject)
                        {
                            bsm.performList[i].attackersTarget = bsm.enemiesInBattle[Random.Range(0, bsm.enemiesInBattle.Count)];
                        }
                    }
                }
                isAlive = false;
                //Reset Enemy Buttons
                bsm.EnemyButtons();
                //Check if the battle has been won
                bsm.battleState = BattleStateMachine.PerformAction.CHECKIFALIVE;
            }
            break;

        case (TurnState.WAITING):     //Waiting State
            break;

        default:
            break;
        }

        void UpdateProgressBar()                //Sets the time for the enemy to perform an attack
        {
            curWait = curWait + Time.deltaTime; //Increments the current wait over time
            if (curWait >= maxWait)
            {
                currentState = TurnState.CHOOSEACTION; //Sets the Enemy State to Choose Action once the Wait bar is full
            }
        }
    }
Beispiel #12
0
    // Update is called once per frame
    void Update()
    {
        switch (currentState)
        {
        case (TurnState.PROCESSING):

            UpgradeProgressBar();
            break;

        case (TurnState.CHOOSEACTION):
            ChooseAction();
            currentState = TurnState.WAITING;
            break;

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

        case (TurnState.ACTION):
            StartCoroutine(TimeForAction());
            break;

        case (TurnState.DEAD):
            //if its not alive return
            if (!alive)
            {
                return;
            }
            //if its still alive at dead state make it dead
            else
            {
                //change tag of enemy so it will be attackable
                this.gameObject.tag = "DeadEnemy";
                //not attackable by heroes
                BSM.EnemiesInGame.Remove(this.gameObject);

                if (BSM.EnemiesInGame.Count > 0)
                {
                    for (int i = 0; i < BSM.PerformList.Count; i++)
                    {
                        if (BSM.PerformList[i].AttackersGameObject == this.gameObject)
                        {
                            BSM.PerformList.Remove(BSM.PerformList[i]);
                        }
                        if (BSM.PerformList[i].AttackersTarget == this.gameObject)
                        {
                            BSM.PerformList[i].AttackersTarget = BSM.EnemiesInGame[Random.Range(0, BSM.EnemiesInGame.Count)];
                        }
                    }
                }

                animat.Play("Die");


                alive = false;
                BSM.EnemyButtons();     //reset enemy buttons

                //check alive
                BSM.battleStates = BattleStateMachine.PerformAction.CHECKALIVE;
            }
            break;
        }
    }
Beispiel #13
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log (currentState);
        switch (currentState)
        {
        case (TurnState.PROCESSING):
            UpgradeProgBar();
            break;

        case (TurnState.CHOOSEACTION):
            ChooseAction();
            currentState = TurnState.WAITING;
            break;

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

        case (TurnState.ACTION):
            StartCoroutine(TimeForAction());
            break;

        case (TurnState.DEAD):
            if (!alive)
            {
                return;
            }
            else
            {
                //change tag
                this.gameObject.tag = "DeadEnemy";
                //not attackable
                BSM.EnemiesInBattle.Remove(this.gameObject);
                // Disable selector
                Selector.SetActive(false);
                //remvoe all inputs
                if (BSM.EnemiesInBattle.Count > 0)
                {
                    for (int i = 0; i < BSM.PerformList.Count; i++)
                    {
                        if (BSM.PerformList[i].AttacksGameObject == this.gameObject)
                        {
                            BSM.PerformList.Remove(BSM.PerformList[i]);
                        }
                        if (BSM.PerformList[i].AttakersTarget == this.gameObject)
                        {
                            BSM.PerformList[i].AttakersTarget = BSM.EnemiesInBattle[Random.Range(0, BSM.EnemiesInBattle.Count)];
                        }
                    }
                }
                this.gameObject.GetComponent <MeshRenderer>().material.color = new Color32(105, 105, 105, 255);
                //set alive to be false
                alive = false;

                // Reset enemy buttons
                BSM.EnemyButtons();
                //check alive
                BSM.battleStates = BattleStateMachine.PerformAction.CHECK;
            }
            this.gameObject.SetActive(false);
            break;
        }
    }
    void Update()
    {
        switch (currentState)
        {
        case (TurnState.PROCESSING):
            UpgradeProgressBar();
            break;

        case (TurnState.CHOOSEACTION):
            ChooseAction();
            currentState = TurnState.WAITING;
            break;

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

        case (TurnState.ACTION):
            StartCoroutine(TimeForAction());
            break;

        case (TurnState.DEAD):
            if (!alive)
            {
                return;
            }
            else
            {
                //change tag of the enemy
                this.gameObject.tag = "DeadEnemy";
                //not attackable by heros
                BSM.gameManager.enemiesToBattle.Remove(this.gameObject);
                //disable the selector
                Selector.SetActive(false);
                //remove all inputs enemyattacks
                if (BSM.gameManager.enemiesToBattle.Count > 0)
                {
                    for (int i = 0; i < BSM.PerformList.Count; i++)
                    {
                        if (BSM.PerformList[i].AttackersTarget == this.gameObject)
                        {
                            BSM.PerformList[i].AttackersTarget = BSM.gameManager.enemiesToBattle[Random.Range(0, BSM.gameManager.enemiesToBattle.Count)];
                        }

                        if (BSM.PerformList[i].AttackersGameObject == this.gameObject)
                        {
                            BSM.PerformList.Remove(BSM.PerformList[i]);
                        }
                    }
                }

                //change the color to gray / play dead animation
                meshRenderer.material.color = new Color32(105, 105, 105, 255);
                //set alive to be false
                alive = false;
                //reset enemybuttons
                BSM.EnemyButtons();
                //check alive
                BSM.battleStates = BattleStateMachine.PerformAction.CHECKALIVE;
            }
            break;
        }
    }