private void FillLetters(string word) { Rectangle safeArea = new Rectangle( this.Window.ClientBounds.Width / 2 - playerSquare.Width, this.Window.ClientBounds.Height / 2 - playerSquare.Height, playerSquare.Width * 2, playerSquare.Height * 2); string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; List <Vector2> locations = new List <Vector2>(); for (int x = 25; x < this.Window.ClientBounds.Width - 50; x += 50) { for (int y = 25; y < this.Window.ClientBounds.Height - 50; y += 50) { Rectangle locationRect = new Rectangle( x, y, (int)letterFont.MeasureString("W").X, (int)letterFont.MeasureString("W").Y); if (!safeArea.Intersects(locationRect)) { locations.Add(new Vector2(x, y)); } } } letters.Clear(); for (int x = 0; x < 20; x++) { GameLetter thisLetter = new GameLetter(); if (x < word.Length) { thisLetter.Letter = word.Substring(x, 1); } else { thisLetter.Letter = alphabet.Substring( rand.Next(0, 26), 1); } int location = rand.Next(0, locations.Count); thisLetter.Position = locations[location]; thisLetter.WasHit = false; locations.RemoveAt(location); letters.Add(thisLetter); } }
private bool FindWinningTile(Board board, IEnumerable <byte> avalableTiles, GameLetter playerLetter) { foreach (byte TileToCheck in avalableTiles) { if (board.DoesPlayerWins((byte)(TileToCheck - 1), playerLetter)) { _tile = TileToCheck; return(true); } } return(false); }
public bool DoesPlayerWins(byte tile, GameLetter playerLetter) { // check all cobinations for winning foreach (byte[] Combination in WinCombinations[tile]) { // If Has player letter in both win combinations positions then player wins if ((GetTileValue(Combination[0]) == playerLetter) && (GetTileValue(Combination[1]) == playerLetter)) { return(true); } } return(false); }
private void FillLetters(string word) { Rectangle safeArea = new Rectangle( this.Window.ClientBounds.Width / 2 - playerSquare.Width, this.Window.ClientBounds.Height / 2 - playerSquare.Height, playerSquare.Width * 2, playerSquare.Height * 2); string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; List<Vector2> locations = new List<Vector2>(); for (int x = 25; x < this.Window.ClientBounds.Width - 50; x += 50) { for (int y = 25; y < this.Window.ClientBounds.Height - 50; y += 50) { Rectangle locationRect = new Rectangle( x, y, (int)letterFont.MeasureString("W").X, (int)letterFont.MeasureString("W").Y); if (!safeArea.Intersects(locationRect)) locations.Add(new Vector2(x, y)); } } letters.Clear(); for (int x = 0; x < 20; x++) { GameLetter thisLetter = new GameLetter(); if (x < word.Length) thisLetter.Letter = word.Substring(x, 1); else thisLetter.Letter = alphabet.Substring( rand.Next(0, 26), 1); int location = rand.Next(0, locations.Count); thisLetter.Position = locations[location]; thisLetter.WasHit = false; locations.RemoveAt(location); letters.Add(thisLetter); } }
public ComputerPlayer(Board board, string name, GameLetter playerLetter) : base(board, name, playerLetter) { }
public void SetTileValue(byte tile, GameLetter value) { Tiles[tile] = value; }
public Player(Board board, String name, GameLetter playerLetter) { _board = board; Name = name; PlayerLetter = playerLetter; }
public HumanPlayer(Board board, string name, GameLetter playerLetter) : base(board, name, playerLetter) { }