Ejemplo n.º 1
0
        void SendMapData(int playerId, NetConnection conn)
        {
            List<PlayerInfo> players = DataManager.Instance.Players.Values.ToList();
            //TODO: check surroundings

            SROrderMessage msg = new SROrderMessage(OrderType.UpdateMapInfo, new Dictionary<ArgumentName, object>()
            {
                { ArgumentName.VisiblePlayers, players }
            });
            ServerHandler.Instance.SendMessageToPlayer(msg, conn);
        }
Ejemplo n.º 2
0
 public void Handle(SROrderMessage msg)
 {
     switch (msg.type)
     {
         case OrderType.UpdateMapInfo:
             UpdateMapInfo(msg.args);
             break;
         case OrderType.UpdateNPlayerInfo:
             UpdateNPlayerInfo(msg.args[ArgumentName.PlayerInfo] as PlayerInfo);
             break;
     }
 }
Ejemplo n.º 3
0
        public void SendServerList(NetConnection conn)
        {
            SROrderMessage msg = new SROrderMessage(OrderType.UpdateServerList);
            msg.args = new Dictionary<ArgumentName, object>()
                        {
                            {
                                ArgumentName.ServerList, new List<ServerInfo>() {
                                                         new ServerInfo("Normal", "localhost", 1234) }
                            }
                        };

            ServerHandler.Instance.SendMessageToPlayer(msg, conn);
        }
Ejemplo n.º 4
0
        void UpdatePlayerPosition(Dictionary<ArgumentName, object> args, NetConnection conn)
        {
            PlayerInfo info = args[ArgumentName.PlayerInfo] as PlayerInfo;

            SROrderMessage msg = new SROrderMessage(OrderType.UpdateNPlayerInfo);
            msg.args[ArgumentName.PlayerInfo] = info;

            //TODO: check surroundings
            List<NetConnection> conns = DataManager.Instance.Connections.Values.ToList();
            conns.Remove(conn);

            if (conns.Count > 0)
                ServerHandler.Instance.SendMessageToMany(msg, conns);
        }
Ejemplo n.º 5
0
 public void Handle(SROrderMessage msg)
 {
     switch (msg.type)
     {
         case OrderType.UpdateServerList:
             if (msg.args.ContainsKey(ArgumentName.ServerList))
                 UpdateServerList(msg.args[ArgumentName.ServerList] as List<ServerInfo>);
             break;
         case OrderType.SetPlayerInfo:
             if (msg.args.ContainsKey(ArgumentName.PlayerInfo))
                 SetPlayerInfo(msg.args[ArgumentName.PlayerInfo] as PlayerInfo);
             break;
     }
 }
Ejemplo n.º 6
0
        public void DoLogin(string username, string password, NetConnection conn)
        {
            //TODO: validate login
            Console.WriteLine("{0} - {1}", username, password);

            //TODO: get player information
            PlayerInfo info = new PlayerInfo();
            info.name = "Stryfe";
            info.x = 20;
            info.y = 15;
            info.id = debugId;

            debugId++;

            DataManager.Instance.UpdateConnection(info.id, conn);
            DataManager.Instance.UpdatePlayer(info.id, info);

            SROrderMessage msg = new SROrderMessage(OrderType.SetPlayerInfo, new Dictionary<ArgumentName, object>() { { ArgumentName.PlayerInfo, info } });
            ServerHandler.Instance.SendMessageToPlayer(msg, conn);
        }
Ejemplo n.º 7
0
 public void SendMessageToMany(SROrderMessage msg, List<NetConnection> conns)
 {
     server.SendMessage(CreateMessage(msg), conns, NetDeliveryMethod.ReliableOrdered, 0);
 }
Ejemplo n.º 8
0
 public void SendMessageToPlayer(SROrderMessage msg, NetConnection conn)
 {
     server.SendMessage(CreateMessage(msg), conn, NetDeliveryMethod.ReliableOrdered);
 }