Exemplo n.º 1
0
    private void gameOver()
    {
        int winner; //1 if player 1 wins, 0 if player 2 wins

        if (player1Score > player2Score)
        {
            winner = 1;
        }
        else
        {
            winner = 0;
        }

        if (winner == 1)
        {
            WinnerLabel.GetComponent <TextMeshProUGUI>().text = "PLAYER1 WINS!!!";
        }

        Player1Label.GetComponent <TextMeshProUGUI>().text = "Player1";
        Score2Label.GetComponent <TextMeshProUGUI>().text  = player2Score.ToString();
        Score1Label.GetComponent <TextMeshProUGUI>().text  = player1Score.ToString();

        if (ApplicationModel.gameType == "cpuVSplayer")
        {
            Player2Label.GetComponent <TextMeshProUGUI>().text = "CPU";

            if (winner == 0)
            {
                WinnerLabel.GetComponent <TextMeshProUGUI>().text = "GAME OVER";
            }
        }
        else if (ApplicationModel.gameType == "playerVSplayer")
        {
            Player2Label.GetComponent <TextMeshProUGUI>().text = "Player2";

            if (winner == 0)
            {
                WinnerLabel.GetComponent <TextMeshProUGUI>().text = "PLAYER2 WINS!!!";
            }
        }

        gameOverPanel.SetActive(true);

        if (ApplicationModel.resumedGame)
        {
            ApplicationModel.lastGameType    = null;
            ApplicationModel.lastGameMode    = null;
            ApplicationModel.lastAIdificulty = 0;
            ApplicationModel.lastGoals       = 0;
            ApplicationModel.resumedGame     = false;
            ApplicationModel.score1          = 0;
            ApplicationModel.score2          = 0;
        }
    }
Exemplo n.º 2
0
        public Form2(int numofplayers, Form initiator, Monster m)
        {
            InitializeComponent();
            //this.TopMost = true;
            //this.WindowState = FormWindowState.Maximized;
            playerarray   = new Player[numofplayers];
            monster       = m;
            initiatorform = initiator;
            if (numofplayers > 4)
            {
                this.Close();
            }
            for (int i = 0; i < numofplayers; i++)
            {
                playerarray[i] = new Player();
                switch (i)
                {
                case 0:
                    playerarray[i].label = Player1Label;
                    Player1Label.Show();
                    playerarray[i].playing   = true;
                    playerarray[i].rectangle = new Rectangle(Player1Label.Location, Player1Label.Size);
                    break;

                case 1:
                    playerarray[i].label = Player2Label;
                    Player2Label.Show();
                    playerarray[i].playing   = true;
                    playerarray[i].rectangle = new Rectangle(Player2Label.Location, Player2Label.Size);
                    break;

                case 2:
                    playerarray[i].label = Player3Label;
                    Player3Label.Show();
                    playerarray[i].playing   = true;
                    playerarray[i].rectangle = new Rectangle(Player3Label.Location, Player3Label.Size);
                    break;

                case 3:
                    playerarray[i].label = Player4Label;
                    Player4Label.Show();
                    playerarray[i].playing   = true;
                    playerarray[i].rectangle = new Rectangle(Player4Label.Location, Player4Label.Size);
                    break;
                }
                playerarray[i].nonitcolor = playerarray[i].label.BackColor;
            }
            if (monster.type != Monster.Monster_Type.Posessor)
            {
                MonsterLabel.Size        = new System.Drawing.Size(monster.size * 2, monster.size * 2);
                monster.monsterLabel     = MonsterLabel;
                monster.monsterRectangle = new Rectangle(MonsterLabel.Location, MonsterLabel.Size);
            }
            else
            {
                MonsterLabel.Hide();
                possessed.rectangle = new Rectangle(-200, -200, 1, 1);
                possessed.label     = new Label();
            }
            Random rnd = new Random();

            if (monster.type != Monster.Monster_Type.Posessor & monster.type != Monster.Monster_Type.Hook)
            {
                it = playerarray[rnd.Next(0, numofplayers)];
                // it.label.BackColor = Color.Red;
                it.it = true;
                it.label.BorderStyle = BorderStyle.Fixed3D;
            }
            ControlBox.Focus();
            Player_Reset(4);
            MonsterLabel.Location             = new Point((this.Size.Width - 27) / 2, (this.Size.Height - 50) / 2);
            monster.start_Position            = MonsterLabel.Location;
            monster.monsterRectangle.Location = MonsterLabel.Location;
        }