Exemplo n.º 1
0
        /// <summary>
        /// Adds the client to the current game.
        /// </summary>
        public void AddClient(NetConnection connection, ChampionTypes champ)
        {
            ILogger.Log("New player added to the game.", LogPriority.High);

            ServerChampion champion = CreateChampion(champ);
            ServerClient   client   = new ServerClient(connection, champion);

            // Send to the client that asked to join, along with the info of the current players
            List <ServerClient> remoteClients = new List <ServerClient>();

            foreach (ServerClient remote in Clients.Values)
            {
                remoteClients.Add(remote);
            }
            SendCommand(connection,
                        ServerCommand.JoinedGame,
                        NetDeliveryMethod.ReliableUnordered,
                        (msg) => FillJoinedGameMessage(msg, client, remoteClients));

            // Send the new player event to other players
            foreach (NetConnection clientConn in Clients.Keys)
            {
                if (clientConn != connection)
                {
                    SendCommand(clientConn,
                                ServerCommand.NewRemotePlayer,
                                NetDeliveryMethod.ReliableUnordered,
                                (msg) => FillNewRemotePlayerMessage(msg, client));
                }
            }

            // Apply the changes to our game state
            Clients.Add(connection, client);
            Match.CurrentState.AddEntity(champion);
        }
Exemplo n.º 2
0
 public ServerClient(NetConnection conn, ServerChampion champion)
 {
     Connection               = conn;
     Champion                 = champion;
     ActionsPackage           = new List <PlayerAction>();
     LastAcknowledgedActionID = IDGenerator.NO_ID;
     AnimData                 = new ChampionAnimData();
     ChampStats               = new ChampionStats(100f); //TODO: depend on champion
 }