Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyGame.Player"/> class. Adds all 21 blocks to the players blockset
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="color">Color.</param>
        public Player(string name, Color color)
        {
            _name      = name;
            _color     = color;
            _playerSet = new BlockSet();
            _move      = 1;

            Block b1  = new Block_L(_color, 25, 425, 20, 3, 1);
            Block b2  = new Block_L(_color, 95, 425, 20, 4, 2);
            Block b3  = new Block_L(_color, 165, 425, 20, 5, 3);
            Block b4  = new Block_T(_color, 235, 425, 20, 4, 4);
            Block b5  = new Block_T(_color, 305, 425, 20, 5, 5);
            Block b6  = new Block_TSymmetric(_color, 375, 425, 20, 5, 6);
            Block b7  = new Block_Line(_color, 445, 425, 20, 1, 7);
            Block b8  = new Block_Line(_color, 515, 425, 20, 2, 8);
            Block b9  = new Block_Line(_color, 585, 425, 20, 3, 9);
            Block b10 = new Block_Line(_color, 655, 425, 20, 4, 10);
            Block b11 = new Block_Line(_color, 725, 425, 20, 5, 11);
            Block b12 = new Block_NoRotation(_color, 25, 515, 20, 4, 12);
            Block b13 = new Block_NoRotation(_color, 95, 515, 20, 5, 13);
            Block b14 = new Block_Z(_color, 165, 515, 20, 4, 14);
            Block b15 = new Block_Z(_color, 235, 515, 20, 5, 15);
            Block b16 = new Block_C(_color, 305, 515, 20, 5, 16);
            Block b17 = new Block_LSymmetric(_color, 375, 515, 20, 5, 17);
            Block b18 = new Block_M(_color, 445, 515, 20, 5, 18);
            Block b19 = new Block_ZSymmetric(_color, 515, 515, 20, 5, 19);
            Block b20 = new Block_N1(_color, 585, 515, 20, 5, 20);
            Block b21 = new Block_N2(_color, 655, 515, 20, 5, 21);

            _playerSet.AddBlock(b1);
            _playerSet.AddBlock(b2);
            _playerSet.AddBlock(b3);
            _playerSet.AddBlock(b4);
            _playerSet.AddBlock(b5);
            _playerSet.AddBlock(b6);
            _playerSet.AddBlock(b7);
            _playerSet.AddBlock(b8);
            _playerSet.AddBlock(b9);
            _playerSet.AddBlock(b10);
            _playerSet.AddBlock(b11);
            _playerSet.AddBlock(b12);
            _playerSet.AddBlock(b13);
            _playerSet.AddBlock(b14);
            _playerSet.AddBlock(b15);
            _playerSet.AddBlock(b16);
            _playerSet.AddBlock(b17);
            _playerSet.AddBlock(b18);
            _playerSet.AddBlock(b19);
            _playerSet.AddBlock(b20);
            _playerSet.AddBlock(b21);
        }
        /// <summary>
        /// Player Selects the Block
        /// </summary>
        /// <param name="player">Player.</param>
        public override void SelectBlock(Player player)
        {
            _BlokusBoard.BackgroundBox();
            _BlokusBoard.DrawPlayerDetails();
            _BlokusBoard.DrawShapeBox();
            _BlokusBoard.SingleBlockBox();
            _BlokusBoard.DrawBoard();
            player.PlayerSet.Draw();
            _BlokusBoard.GameInstructionDisplay(1);
            turnDisplay();
            Point2D rand = new Point2D();

            if (SwinGame.KeyTyped(KeyCode.vk_e))
            {
                _end = true;
                Play();
            }
            if (_p.Move != 1 && chosenblock == false)
            {
                if (player.PlayerSet.Blocks.Count == 0)
                {
                    _end = true;
                    Play();
                }
                else
                {
                    randomselection = choose.Next(player.PlayerSet.Blocks.Count);
                    rand            = player.PlayerSet.ReturnNum(_p.PlayerSet.GetBlockId(player.PlayerSet.Blocks [randomselection]));
                    if ((player.PlayerSet.Blocks [randomselection] is Block_NoRotation && player.PlayerSet.Blocks [randomselection].Size == 5) || (player.PlayerSet.Blocks [randomselection] is Block_M))
                    {
                        rand.X += 20;
                    }
                    player.PlayerSet.SelectBlockAt(rand);
                    chosenblock = true;
                    player.PlayerSet.DrawChosen();
                }
            }
            else
            {
                player.PlayerSet.DrawChosen();
            }

            if (_p.Move > 1)
            {
                foreach (Block b in player.PlayerSet.Blocks)
                {
                    if (player.PlayerSet.Blocks.IndexOf(b) == randomselection)
                    {
                        b.Draw();
                    }
                }
            }
            if (SwinGame.MouseClicked(MouseButton.LeftButton))
            {
                if (_p.Move == 1 && chosenblock == false)
                {
                    player.PlayerSet.SelectBlockAt(SwinGame.MousePosition());
                }
                foreach (Block b in player.PlayerSet.Blocks)
                {
                    if (b.Used == false)
                    {
                        if (b is Block_Line)
                        {
                            _temp    = new Block_Line(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_Line(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_Z)
                        {
                            _temp    = new Block_Z(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_Z(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_NoRotation)
                        {
                            _temp    = new Block_NoRotation(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_NoRotation(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_L)
                        {
                            _temp    = new Block_L(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_L(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_LSymmetric)
                        {
                            _temp    = new Block_LSymmetric(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_LSymmetric(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_M)
                        {
                            _temp    = new Block_M(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_M(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_T)
                        {
                            _temp    = new Block_T(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_T(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_C)
                        {
                            _temp    = new Block_C(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_C(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_TSymmetric)
                        {
                            _temp    = new Block_TSymmetric(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_TSymmetric(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_ZSymmetric)
                        {
                            _temp    = new Block_ZSymmetric(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_ZSymmetric(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_N1)
                        {
                            _temp    = new Block_N1(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_N1(Color.Black, 0, 0, 0, 0, 0);
                        }
                        else if (b is Block_N2)
                        {
                            _temp    = new Block_N2(Color.Black, 0, 0, 0, 0, 0);
                            _display = new Block_N2(Color.Black, 0, 0, 0, 0, 0);
                        }
                        _temp.X         = 200;
                        _temp.Y         = 190;
                        _temp.Length    = b.Length;
                        _temp.Size      = b.Size;
                        _temp.Color     = b.Color;
                        _temp.Number    = b.Number;
                        _display.Length = b.Length;
                        _display.Size   = b.Size;
                        _display.Color  = b.Color;
                        _play           = true;
                    }
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Player Selects the Block
 /// </summary>
 /// <param name="player">Player.</param>
 public override void SelectBlock(Player player)
 {
     _BlokusBoard.BackgroundBox();
     _BlokusBoard.DrawPlayerDetails();
     _BlokusBoard.DrawShapeBox();
     _BlokusBoard.SingleBlockBox();
     _BlokusBoard.DrawBoard();
     player.PlayerSet.Draw();
     _BlokusBoard.GameInstructionDisplay(0);
     turnDisplay();
     if (SwinGame.KeyTyped(KeyCode.vk_e))
     {
         _end = true;
         Play();
     }
     if (SwinGame.MouseClicked(MouseButton.LeftButton))
     {
         player.PlayerSet.SelectBlockAt(SwinGame.MousePosition());
         foreach (Block b in player.PlayerSet.Blocks)
         {
             if (b.Used == false)
             {
                 if (b is Block_Line)
                 {
                     _temp    = new Block_Line(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_Line(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_Z)
                 {
                     _temp    = new Block_Z(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_Z(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_NoRotation)
                 {
                     _temp    = new Block_NoRotation(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_NoRotation(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_L)
                 {
                     _temp    = new Block_L(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_L(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_LSymmetric)
                 {
                     _temp    = new Block_LSymmetric(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_LSymmetric(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_T)
                 {
                     _temp    = new Block_T(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_T(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_C)
                 {
                     _temp    = new Block_C(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_C(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_TSymmetric)
                 {
                     _temp    = new Block_TSymmetric(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_TSymmetric(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_M)
                 {
                     _temp    = new Block_M(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_M(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_ZSymmetric)
                 {
                     _temp    = new Block_ZSymmetric(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_ZSymmetric(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_N1)
                 {
                     _temp    = new Block_N1(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_N1(Color.Black, 0, 0, 0, 0, 0);
                 }
                 else if (b is Block_N2)
                 {
                     _temp    = new Block_N2(Color.Black, 0, 0, 0, 0, 0);
                     _display = new Block_N2(Color.Black, 0, 0, 0, 0, 0);
                 }
                 _temp.X         = 200;
                 _temp.Y         = 190;
                 _temp.Length    = b.Length;
                 _temp.Size      = b.Size;
                 _temp.Color     = b.Color;
                 _temp.Number    = b.Number;
                 _display.Length = b.Length;
                 _display.Size   = b.Size;
                 _display.Color  = b.Color;
                 _play           = true;
             }
         }
     }
 }