示例#1
0
    /// <summary>
    /// define all the variables
    /// </summary>
    private void Start()
    {
        this.getInputCountry = int.MaxValue;
        this.currentPlayer   = 0;
        this.currentStage    = 3;

        this.forcesPanel = GameObject.Find("forcesPanel");
        //set the panels
        this.startPanel = GameObject.Find("StartPanel");
        if (this.startPanel != null)
        {
            this.startPanel.SetActive(false);
        }
        this.AttackPanel = GameObject.Find("AttackPanel");
        if (this.AttackPanel != null)
        {
            this.AttackPanel.SetActive(false);
        }
        this.ReiPanel = GameObject.Find("ReinforcementPanel");
        if (this.ReiPanel != null)
        {
            this.ReiPanel.SetActive(false);
        }
        this.MovePanel = GameObject.Find("MovingPanel");
        if (this.MovePanel != null)
        {
            this.MovePanel.SetActive(false);
        }
        this.WPanel = GameObject.Find("WinPanel");
        if (this.WPanel != null)
        {
            this.WPanel.SetActive(false);
        }
        this.st  = null;
        this.rei = null;
        this.sm  = null;
        this.at  = null;
        this.mo  = null;
        this.bot = null;
    }
示例#2
0
    /// <summary>
    /// in the end of turn move the the next player.
    /// if the next player is bot play the moves of the bots
    /// </summary>
    private void moveNextStage()
    {
        //hide text
        //hide text
        if (this.MovePanel.transform.Find("first") != null)
        {
            this.MovePanel.transform.Find("first").gameObject.SetActive(false);
        }
        if (this.MovePanel.transform.Find("SliderText") != null)
        {
            this.MovePanel.transform.Find("SliderText").gameObject.SetActive(false);
        }
        //hide slider
        if (this.MovePanel.transform.Find("Slider") != null)
        {
            this.MovePanel.transform.Find("Slider").gameObject.SetActive(false);
        }
        //hide button
        if (this.MovePanel.transform.Find("Button") != null)
        {
            this.MovePanel.transform.Find("Button").gameObject.SetActive(false);
        }
        //hide the move Panel
        if (this.MovePanel != null)
        {
            this.MovePanel.SetActive(false);
        }


        nextPlayer();
        bool flag_find_player = false;

        while (flag_find_player == false)
        {
            //player is not alive
            if (players[this.currentPlayer] == false)
            {
                //if its after the beggining
                if (this.counterStart > 0)
                {
                    this.counterStart--;
                }
                nextPlayer();
            }
            else
            {
                //player was elimnated
                if (lostCheck() == true)
                {
                    nextPlayer();
                }
                else
                {
                    //the player is bot

                    if (this.playerAi[this.currentPlayer] == true)
                    {
                        int won = 0;
                        //if its after the beggining and you should go straight to attack
                        if (this.counterStart > 0)
                        {
                            this.bot = new Ai(this.currentPlayer);
                            won      = this.bot.playATurn(true, this);
                            //bot from attack
                            this.counterStart--;
                        }
                        else
                        {
                            this.bot = new Ai(this.currentPlayer);
                            won      = this.bot.playATurn(false, this);
                            //bot from rein
                        }
                        //bot won
                        if (won == 1)
                        {
                            //show winner
                            if (this.WPanel != null)
                            {
                                this.WPanel.SetActive(true);
                            }
                            this.WPanel.transform.Find("winner").GetComponent <Text>().text = "the winner is " + whichPlayer();
                            flag_find_player = true;
                        }
                        else
                        {
                            nextPlayer();
                        }
                    }
                    //regular player
                    else
                    {
                        //if its after the beggining and you should go straight to attack
                        if (this.counterStart > 0)
                        {
                            //next stage
                            this.currentStage = 1;
                            this.at           = new Attack(this.currentPlayer, Global.map);
                            //show the attackPanel
                            if (this.AttackPanel != null)
                            {
                                this.AttackPanel.SetActive(true);
                            }

                            this.counterStart--;
                        }
                        else
                        {
                            //next stage
                            this.currentStage = 0;
                            this.counter      = 0;
                            this.rei          = new reinforcement(this.currentPlayer, Global.map);
                            //show the reinforcement Panel
                            if (this.ReiPanel != null)
                            {
                                this.ReiPanel.SetActive(true);
                            }
                        }
                        //player founded play it
                        flag_find_player = true;
                    }
                }
            }
        }
    }