Example #1
0
        public override Player AddPlayer(WebSocket socket, string id)
        {
            var player = new PictionaryPlayer(socket, id);

            this.Players.Add(player);
            player.Game = this;
            return(player);
        }
Example #2
0
        public PictionaryGameState GetClientState(PictionaryPlayer player)
        {
            var playerList = new List <PictionaryPlayerClient>();

            foreach (PictionaryPlayer p in this.Players)
            {
                playerList.Add(p.GetClientRepresentation());
            }
            var state = new PictionaryGameState
            {
                PixelsHeight    = this.PixelsHeight,
                PixelsWidth     = this.PixelsWidth,
                CurrentPlayerID = this.CurrentPlayer.ID,
                Players         = playerList
            };

            return(state);
        }
Example #3
0
        public void HandleMessage(PictionaryPlayer player, GameMessage message)
        {
            switch (message.Type)
            {
            case "DrawStroke":
                var pixels = (PictionaryPixel[])message.Content;
                DrawStroke(player, pixels);
                break;

            case "Guess":
                var guess = (string)message.Content;
                if (guess == this.CurrentWord)
                {
                    var winnerMessage = new GameMessage("Winner", new { PlayerID = player.ID, Word = this.CurrentWord });
                    this.SendMessageToAll(winnerMessage);
                }
                break;
            }
        }
Example #4
0
 public void DrawStroke(PictionaryPlayer player, PictionaryPixel[] pixels)
 {
     SendPixelsToClients(pixels);
 }