Esempio n. 1
0
        public void CreateGame(int min, int max, string name)
        {
            //var parameters = new string[]{ min.ToString(), max.ToString(), name };

            CreateGameConv conv =
                ConversationFactory.Instance
                .CreateFromConversationType <CreateGameConv>
                    (server, null, CreateGamePostExecute, null); //using lambda operator to pass parameters as object

            conv._GameName   = name;
            conv._MinPlayers = min;
            conv._MaxPlayers = max;
            conv._Player     = Player;

            conv.Start();
        }
        private void CreateGameResponse(byte[] bytes, IPEndPoint refEp)
        {
            CreateGameConv conv = ConversationFactory.Instance
                                  .CreateFromMessage <CreateGameConv>(bytes, refEp, null, null, null);

            conv._GameId = ManageGameID();

            CreateGame result = Message.Decode <CreateGame>(bytes);

            Player player = result.PlayerId;

            player.SetIP(refEp);

            //add this game to the lobby list of games
            GamesOnLobby.HandleCreateGame(player, result.MinPlayers, result.MaxPlayers, result.GameName, conv._GameId);

            conv.Start();
        }