Пример #1
0
 public BlackPc(Player pl, Vector3 pos)
     : base(pl, pos)
 {
     color = new Vector3(0.2f);
     possMoves = new Vector[] { new Vector(-1, 1), new Vector(1, 1) };
     possAttacks = new Vector[] { new Vector(-2, 2), new Vector(2, 2) };
 }
Пример #2
0
        public King(Player pl, Vector3 pos)
            : base(pl, pos)
        {
            possAttacks = new Vector[24];
            possMoves = new Vector[28];

            int m = 0;
            int i = 7;
            while (m < 28 && i > 0)
            {
                if (i != 1 && m < 24)
                {
                    possAttacks[m] = new Vector(-i, -i);
                    possAttacks[m + 1] = new Vector(i, i);
                    possAttacks[m + 2] = new Vector(-i, i);
                    possAttacks[m + 3] = new Vector(i, -i);
                }

                possMoves[m] = new Vector(-i, -i);
                possMoves[m + 1] = new Vector(i, i);
                possMoves[m + 2] = new Vector(-i, i);
                possMoves[m + 3] = new Vector(i, -i);

                m = m + 4;
                i--;
            }
        }
Пример #3
0
 public WhitePc(Player pl, Vector3 pos)
     : base(pl, pos)
 {
     color = new Vector3(1, 1, 0.9f);
     possMoves = new Vector[] { new Vector(-1, -1), new Vector(1, -1) };
     possAttacks = new Vector[] { new Vector(-2, -2), new Vector(2, -2) };
 }
Пример #4
0
 public Piece(Player pl, Vector3 pos)
 {
     owner = pl;
     currentPos = pos;
     reachedHalfWay = false;
     moving = false;
     alpha = 1.0f;
 }
Пример #5
0
        public GamePlay()
        {
            Player p1 = new Player(p1Settings, 0);
            Player p2 = new Player(p2Settings, 1);
            p1.next = p2;
            p2.next = p1;
            currPl = p1;

            board = new Board();

            cam = p1.cam.clone();
        }
Пример #6
0
        public bool giveStartingChips(Player p)
        {
            try
            {
                //Uncomment line below to create an error just to test error handling
                //p.Chips.Add(new Chip(""));

                for (int i = 0; i < mNumberOfChipsToStartWith; i++)
                {
                    p.Chips = p.Chips == null ? new List<Chip>() : p.Chips;

                    Chip newChip = new Chip(Guid.NewGuid().ToString());
                    newChip.Color = p.ChipColor;
                    p.Chips.Add(newChip);
                }
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("Error giving starting chips to player!  Details: {0}", ex.Message));
            }
        }
Пример #7
0
 public bool isHis(Player p)
 {
     return p == owner;
 }
Пример #8
0
 public BlackK(Player pl, Vector3 pos)
     : base(pl, pos)
 {
     color = new Vector3(0.2f);
 }
Пример #9
0
        public override void Update(GameTime gameTime)
        {
            cam.updateGoTo(1.6f);

            board.Update();

            if (isGameOver())
                return;

            if (board.attackAgain != null)
                currPl.src = board.attackAgain;
            currPl.getInput();
            if (currPl.src != null)
            {
                board.getPc(currPl.src).selected = true;
                if (currPl.dest != null)
                {
                    board.applyAction(currPl.src, currPl.dest);
                    currPl.src = null;
                    currPl.dest = null;
                    if (isGameOver())
                        return;
                    if (board.attackAgain == null)
                    {
                        currPl = currPl.next;
                        if (!(currPl is AI1))
                            cam.goTo = currPl.cam;
                    }
                }
            }
        }
Пример #10
0
        private void assignPlayerChipsToBoard(Player p)
        {
            int c = 0;
            bool noMorechipsLeft = false;

            //iterate through the positions on the board
            for (int i = 0; i < mRows; i++)
            {

                for (int j = 0; j < mColumns; j++)
                {
                    //If no more chips left, exit this loop
                    if (noMorechipsLeft)
                        return;
                    if (p.Seat == Seat.Top)
                    {
                        switch (i)
                        {
                            //Case 0 is going to be our first row 0.
                            case 0:
                                if (j % 2 == 0)
                                {
                                    BoardSpace spaceInQuestion = game.getSpaceByCoordinates(j, i);
                                    if (spaceInQuestion != null)
                                    {
                                        spaceInQuestion.ChipInContainer = p.Chips[c];
                                        c++;

                                        //If the current counter is greater than what we have total, no more chips!  (since it's 0 based, I subtract 1)
                                        if (c - (p.Chips.Count - 1) >= 0)
                                            noMorechipsLeft = true;
                                    }
                                }
                                break;

                            //Case 1 is going to be our second row 1.
                            case 1:
                                if (j % 2 == 1)
                                {
                                    BoardSpace spaceInQuestion = game.getSpaceByCoordinates(j, i);
                                    if (spaceInQuestion != null)
                                    {
                                        spaceInQuestion.ChipInContainer = p.Chips[c];
                                        c++;

                                        //If the current counter is greater than what we have total, no more chips!
                                        if (c - (p.Chips.Count) >= 0)
                                            noMorechipsLeft = true;
                                    }
                                }
                                break;
                        }
                    }
                    else if (p.Seat == Seat.Bottom)
                    {
                        switch (i)
                        {
                            case 6:
                                if (j % 2 == 0)
                                {
                                    BoardSpace spaceInQuestion = game.getSpaceByCoordinates(j, i);
                                    if (spaceInQuestion != null)
                                    {
                                        spaceInQuestion.ChipInContainer = p.Chips[c];
                                        c++;

                                        //If the current counter is greater than what we have total, no more chips!  (since it's 0 based, I subtract 1)
                                        if (c - (p.Chips.Count - 1) >= 0)
                                            noMorechipsLeft = true;
                                    }
                                }
                                break;

                            case 7:
                                if (j % 2 == 1)
                                {
                                    BoardSpace spaceInQuestion = game.getSpaceByCoordinates(j, i);
                                    if (spaceInQuestion != null)
                                    {
                                        spaceInQuestion.ChipInContainer = p.Chips[c];
                                        c++;

                                        //If the current counter is greater than what we have total, no more chips!
                                        if (c - (p.Chips.Count) >= 0)
                                            noMorechipsLeft = true;
                                    }
                                }
                                break;
                        }
                    }

                }
            }
        }
Пример #11
0
        public void initGame()
        {
            try
            {
                //Create a new game object
                game = new Game();

                //Create me as the player
                Player player = new Player("Jessica", ChipColor.Red, Seat.Top);

                //Create the computer player.
                Player computer = new Player("Easy Computer", ChipColor.Black, Seat.Bottom);

                //Make sure to create the players list if it's null
                game.Players = game.Players == null ? new List<Player>() : game.Players;

                //Add the player to the master list
                game.Players.Add(player);

                //Add the computer to the master list
                game.Players.Add(computer);

                loadBoard();
                loadChipsForPlayers();
                assignAllChipsToBoard();

                drawChips();
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("{0}", ex.Message));
            }
        }