Example #1
0
    public void ReceivePacket(byte[] packet)
    {
        string pkStr = Encoding.UTF8.GetString(packet);

        string[] split   = pkStr.Split(",");
        int      snapNum = Convert.ToInt32(split[0]);

        _game.World.ServerSnapNum = snapNum;

        for (int i = 1; i < split.Length; i++)
        {
            ENTITYTYPE type = (ENTITYTYPE)Convert.ToInt32(split[i++]);
            switch (type)
            {
            case ENTITYTYPE.PLAYER:
                ProcessPlayerPacket(split, ref i);
                break;

            case ENTITYTYPE.PROJECTILE:
                ProcessProjectilePacket(split, ref i);
                break;
            }
        }
        _game.World.LocalSnapNum = _game.World.LocalSnapNum < _game.World.ServerSnapNum ? _game.World.ServerSnapNum : _game.World.LocalSnapNum;
    }
Example #2
0
 public void SyncWorldReceive(int serverSnapNum, ENTITYTYPE entType, int id, int team, int playerClass, int moveType)
 {
     _game.World.ServerSnapNum = serverSnapNum;
     switch (entType)
     {
     case ENTITYTYPE.PLAYER:
         if (id == GetTree().GetNetworkUniqueId())
         {
             _game.World.StartWorld();
             _id = id;
             AddPlayer(id, true);
             _active = true;
         }
         else
         {
             AddPlayer(id, false);
         }
         ReceivePlayerInfo(id, team, playerClass, moveType);
         break;
     }
 }