Beispiel #1
0
        public void ProcessMove(int moveNum)
        {
            int whosTurn = TurnNum % 2;
            //Pull the tile that the player selected
            var tileToRemove = AvailableTiles.Single(t => t.TileID == moveNum);
            //Pull the current player
            var currentPlayer = Participants.Find(p => p.PlayerID == whosTurn);

            //"Give" the player possesion of the tile and remove it from available move options
            currentPlayer.HeldTiles.Add(tileToRemove);
            AvailableTiles.Remove(tileToRemove);

            //Update the most recent move so that a moe history could be recorded and increase the turn counter
            LastMove = "Player " + currentPlayer.PlayerMark + " put their mark on the " + tileToRemove.TileName + " tile!";
            TurnNum  = TurnNum + 1;

            if (currentPlayer.CheckForWin() == true)
            {
                InProgress = false;
                Winner     = currentPlayer;
            }

            //Check if there are no more available tiles. If there are no more tiles after not satisfying a win
            //condition, end the game and leave the winner null.
            else if (AvailableTiles.Count == 0)
            {
                InProgress = false;
            }
        }
Beispiel #2
0
        protected override void Create()
        {
            base.Create();

            int xStartLocation = ((int)Math.Ceiling((Settings.Width / 2f)) - 1) + crossXOffset;
            int yStartLocation = ((int)Math.Ceiling((Settings.Height / 2f)) - 1) + crossYOffset;
            int xLow           = xStartLocation - (int)Math.Ceiling((crossSize / 2f));
            int xHigh          = xStartLocation + (int)Math.Floor((crossSize / 2f));
            int yLow           = yStartLocation - (int)Math.Ceiling((crossSize / 2f));
            int yHigh          = yStartLocation + (int)Math.Floor((crossSize / 2f));

            foreach (Block block in _totalTiles)
            {
                if (block.Location.X > xLow && block.Location.X <= xHigh)
                {
                    if (!AvailableTiles.Contains(block))
                    {
                        AvailableTiles.Add(block);
                    }
                }
                else
                {
                    if (block.Location.Y > yLow && block.Location.Y <= yHigh)
                    {
                        if (!AvailableTiles.Contains(block))
                        {
                            AvailableTiles.Add(block);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        protected override void Create()
        {
            base.Create();
            int layerSize = Settings.Height / (layerCount * 2);

            for (int y = 0; y < Settings.Height; y++)
            {
                for (int x = 0; x < Settings.Width; x++)
                {
                }
            }
            if (!isVertical)
            {
                foreach (Block block in TotalTiles)
                {
                    for (int i = 0; i < layerCount; i++)
                    {
                        if (startsEmpty)
                        {
                            if (block.Location.Y >= (i * (2 * layerSize)) + layerSize && block.Location.Y < ((i * (2 * layerSize)) + layerSize) + layerSize)
                            {
                                AvailableTiles.Add(block);
                            }
                        }
                        else
                        {
                            if (block.Location.Y >= i * (2 * layerSize) && block.Location.Y < (i * (2 * layerSize)) + layerSize)
                            {
                                AvailableTiles.Add(block);
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (Block block in TotalTiles)
                {
                    for (int i = 0; i < layerCount; i++)
                    {
                        if (startsEmpty)
                        {
                            if (block.Location.X >= (i * (2 * layerSize)) + layerSize && block.Location.X < ((i * (2 * layerSize)) + layerSize) + layerSize)
                            {
                                AvailableTiles.Add(block);
                            }
                        }
                        else
                        {
                            if (block.Location.X >= i * (2 * layerSize) && block.Location.X < (i * (2 * layerSize)) + layerSize)
                            {
                                AvailableTiles.Add(block);
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public bool ValidMove(int tileNum)
        {
            //Check if the intended move is still available
            if (AvailableTiles.Any(p => p.TileID == tileNum) == false)
            {
                //The requested move is invalid, thus re-direct back to the view for
                //the player to make another move
                return(false);
            }

            else
            {
                return(true);
            }
        }
Beispiel #5
0
 public bool IsTileSelectionValid(byte tile)
 {
     return(AvailableTiles
            .Contains((byte)(tile + 1)));
 }