Ejemplo n.º 1
0
        /*
         *	Helper to move computer-controlled units. Called in endTurn().
         */
        IEnumerator MoveEnemies(AIBase ai)
        {
            Debug.Log("We made it");
            //While enemiesMoving is true player is unable to move.
            //Wait for turnDelay seconds, defaults to .1 (100 ms).
            yield return(new WaitForSeconds(turnDelay));

            //If there are no enemies spawned (IE in first level):
            if (ai.Count == 0)
            {
                //Wait for turnDelay seconds between moves, replaces delay caused by enemies moving when there are none.
                yield return(new WaitForSeconds(turnDelay));
            }

            //Loop through List of Enemy objects.
            foreach (AIAction act in ai.acts)
            {
                Debug.Log(string.Format("Position {0},{1} To {2},{3}", act.obj.currentPos.x, act.obj.currentPos.y, act.pos.x, act.pos.y));
                if (act.action == AIAction.Actions.Move)
                {
                    act.obj.MoveEnemy((int)act.pos.x, (int)act.pos.y);
                }
                if (act.action == AIAction.Actions.Attack)
                {
                    Debug.Log("ATTACK ENEMY");

                    act.obj.attack((int)act.pos.x, (int)act.pos.y);
                }
                act.obj.resetValidTiles();
                yield return(new WaitForSeconds(act.obj.moveTime));
            }
            Debug.Log(string.Format("End Turn"));

            endTurn();
        }
Ejemplo n.º 2
0
        /*
         *	Initializes the game.
         */
        void InitGame()
        {
            //While doingSetup is true the player can't move, prevent player from moving while title card is up.
            doingSetup = true;

            //Get a reference to our image LevelImage by finding it by name.
            levelImage = GameObject.Find("LevelImage");

            //Get a reference to our text LevelText's text component by finding it by name and calling GetComponent.
            levelText = GameObject.Find("LevelText").GetComponent <Text>();

            gameoverText = GameObject.Find("GameOver");
            gameoverText.SetActive(false);

            Debug.Log("AIs are " + BoardManager.AIBlue + " (blue), " + BoardManager.AIRed + " (red)");

            if (BoardManager.AIBlue != "none")
            {
                blueAI = ListAI.AIPrograms[BoardManager.AIBlue];
            }
            if (BoardManager.AIRed != "none")
            {
                redAI = ListAI.AIPrograms[BoardManager.AIRed];
            }

            //Set levelImage to active blocking player's view of the game board during setup.
            doingSetup = false;

            //Call the HideLevelImage function with a delay in seconds of levelStartDelay.
            Invoke("HideLevelImage", levelStartDelay);

            // clear all previous units
            blueComp.Clear();
            redComp.Clear();
            bluePlayer.Clear();
            redPlayer.Clear();

            // Call the SetupScene function of the BoardManager script, pass it current level number.
            boardScript.SetupScene(mode);
        }
Ejemplo n.º 3
0
        /*
         *	Helper to move computer-controlled units. Called in endTurn().
         */
        IEnumerator MoveEnemies(AIBase ai)
        {
            Debug.Log("We made it");
            //While enemiesMoving is true player is unable to move.
            //Wait for turnDelay seconds, defaults to .1 (100 ms).
            yield return new WaitForSeconds(turnDelay);
                //If there are no enemies spawned (IE in first level):
                if (ai.Count == 0)
                {
                    //Wait for turnDelay seconds between moves, replaces delay caused by enemies moving when there are none.
                    yield return new WaitForSeconds(turnDelay);
                }

                //Loop through List of AIActions
                foreach(AIAction act in ai.acts)
                {

                    Debug.Log(string.Format("Position {0},{1} To {2},{3}", act.obj.currentPos.x, act.obj.currentPos.y, act.pos.x, act.pos.y));
                    //If it is an move than make the unit move
                    if(act.action==AIAction.Actions.Move)
                        act.obj.MoveEnemy((int)act.pos.x, (int)act.pos.y);
                    //If it is a move make it attack
                    if (act.action == AIAction.Actions.Attack) {
                        Debug.Log("ATTACK ENEMY");

                        act.obj.attack((int)act.pos.x, (int)act.pos.y);
                    }
                    //Reset valid tiles to prevent graphical problems.
                    act.obj.resetValidTiles();
                    yield return new WaitForSeconds(act.obj.moveTime);
                }
            Debug.Log(string.Format("End Turn"));

            endTurn();
        }
Ejemplo n.º 4
0
        /*
         *	Initializes the game.
         */
        void InitGame()
        {
            //While doingSetup is true the player can't move, prevent player from moving while title card is up.
            doingSetup = true;

            //Get a reference to our image LevelImage by finding it by name.
            levelImage = GameObject.Find("LevelImage");

            //Get a reference to our text LevelText's text component by finding it by name and calling GetComponent.
            levelText = GameObject.Find("LevelText").GetComponent<Text>();

            gameoverText = GameObject.Find("GameOver");
            gameoverText.SetActive(false);

            Debug.Log("AIs are " + BoardManager.AIBlue + " (blue), " + BoardManager.AIRed + " (red)");

            if (BoardManager.AIBlue != "none")
                blueAI = ListAI.AIPrograms[BoardManager.AIBlue];
            if (BoardManager.AIRed != "none")
                redAI = ListAI.AIPrograms[BoardManager.AIRed];

            //Set levelImage to active blocking player's view of the game board during setup.
            doingSetup = false;

            //Call the HideLevelImage function with a delay in seconds of levelStartDelay.
            Invoke("HideLevelImage", levelStartDelay);

            // clear all previous units
            blueComp.Clear();
            redComp.Clear();
            bluePlayer.Clear();
            redPlayer.Clear();

            // Call the SetupScene function of the BoardManager script, pass it current level number.
            boardScript.SetupScene(mode);
        }