public TileControl(TileDetails tileData) { this.InitializeComponent(); Letter = tileData.Letter; GridX = tileData.GridX; GridY = tileData.GridY; Layer = tileData.Layer; TileStatus = tileData.TileStatus; TileLetter.Text = Letter; }
public void ExchangeLetter(TileDetails letter) { string messageText = Serialiser.SerializeToXml<TileDetails>(letter); NetworkMessage message = new NetworkMessage() { RecipientsIP = IpAddress, MessagePacket = new NetworkMessagePacket() { Command = eProtocol.ExchangeLetter, MessageText = messageText } }; AddMessageToQueue(message); }
private void AddTileToBoard(TileDetails tileData) { TileControl tile = new TileControl(tileData); tile.Visibility = Windows.UI.Xaml.Visibility.Visible; tile.RenderTransform = new TranslateTransform(); tile.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left; tile.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top; m_tileCanvas.Children.Add(tile); tile.TileStatus = eTileState.JustPlayed; tile.ManipulationMode = ManipulationModes.None; m_justPlayedTiles.Add(tile); m_playedTiles.Add(tile); m_boardTiles[tile.GridX, tile.GridY] = tile; PlaceTileOnBoard(tile, tileData.GridX, tileData.GridY, ePlacementMode.PlacingOpponentTile); }
void LocalNetwork_OnLetterExchange(string playersIpAddress, TileDetails letter) { // Only handle the request if it is from a known player. if (GameSettings.Settings.PlayersJoined.ContainsKey(playersIpAddress)) { GameLetters newLetter = GetLetters(1); // Get one new letter from the bag. if (newLetter.Letters.Count > 0) { // Remove the returned letter from the players current letters. GameSettings.Settings.PlayersJoined[playersIpAddress].CurrentLetters.Letters.Remove(letter.Letter); // Add the new letter to the players current letters. GameSettings.Settings.PlayersJoined[playersIpAddress].CurrentLetters.Letters.AddRange(newLetter.Letters); // Add the returned latter to the letter bag. GameSettings.Settings.LetterBag.Add(letter.Letter); // Save the configuration in case we crash. GameSettings.SaveSettings(); // Send the new letter to the player. m_localNetwork.SendLetters(playersIpAddress, newLetter); } } }