Beispiel #1
0
 public void Deserialize(NetDataReader reader)
 {
     serverUnixTime   = reader.GetLong();
     serverTime       = reader.GetLong();
     sendPackCount    = reader.GetULong();
     receivePackCount = reader.GetULong();
 }
Beispiel #2
0
        public UpdateVariableData(NetDataReader reader, NetPeer sender) : base(sender)
        {
            variabeleDataType = (VariableDataType)reader.GetShort();
            variableName      = reader.GetString();
            objectID          = reader.GetLong();
            switch (variabeleDataType)
            {
            case VariableDataType.Bool:
                this.variableDataBool = reader.GetBool();
                break;

            case VariableDataType.Float:
                this.variableDataFloat = reader.GetFloat();
                break;

            case VariableDataType.Long:
                this.variableDataLong = reader.GetLong();
                break;

            case VariableDataType.String:
                this.variableDataString = reader.GetString();
                break;

            case VariableDataType.Vector2:
                this.variableDataVector2 = reader.GetVector2();
                break;
            }
        }
 public override void Deserialize(NetDataReader reader)
 {
     base.Deserialize(reader);
     Forward.x = reader.GetLong();
     //  Forward.y = reader.GetLong();
     Forward.z = reader.GetLong();
 }
Beispiel #4
0
        public static Snapshot Deserialize(NetDataReader reader)
        {
            Snapshot snapshot = new Snapshot();

            snapshot.Timestamp           = reader.GetLong();
            snapshot.LastAckedClientMove = reader.GetLong();
            int cCount = reader.GetInt();
            int pCount = reader.GetInt();

            for (var i = 0; i < cCount; i++)
            {
                Creature c = new Creature();
                c.Id     = reader.GetInt();
                c.X      = reader.GetInt();
                c.Y      = reader.GetInt();
                c.Status = (CreatureStatus)reader.GetByte();
                snapshot.Creatures.Add(c.Id, c);
            }
            for (var i = 0; i < pCount; i++)
            {
                Player p = new Player(reader.GetInt());
                p.X         = reader.GetInt();
                p.Y         = reader.GetInt();
                p.Health    = reader.GetInt();
                p.MaxHealth = reader.GetInt();
                p.Charge    = reader.GetInt();
                p.MaxCharge = reader.GetInt();
                snapshot.Players.Add(p.Id, p);
            }
            return(snapshot);
        }
Beispiel #5
0
        public override void OnMessage(NetPeer peer, NetDataReader reader)
        {
            var npcId    = reader.GetLong();
            var bulletId = reader.GetLong();

            Messenger.Broadcast <long, long>(EventNames.EvOpenFire, npcId, bulletId);
        }
 public override void Deserialize(NetDataReader reader)
 {
     base.Deserialize(reader);
     NpcId = reader.GetInt();
     PosiX = reader.GetLong();
     PosiZ = reader.GetLong();
 }
Beispiel #7
0
 public SpawnData(NetDataReader reader, NetPeer sender) : base(sender)
 {
     spawnType = (ObjectType)reader.GetShort();
     owner     = reader.GetLong();
     objectID  = reader.GetLong();
     position  = reader.GetVector3();
     rotation  = reader.GetVector3();
     scale     = reader.GetVector3();
 }
        public static NO_MallItem GetMallItem(this NetDataReader reader)
        {
            int   mallItemId     = reader.GetInt();
            short itemId         = reader.GetShort();
            long  virtualCyPrice = reader.GetLong();
            long  chargeCyPrice  = reader.GetLong();

            return(new NO_MallItem(mallItemId, itemId, virtualCyPrice, chargeCyPrice));
        }
        public override void OnMessage(NetPeer peer, NetDataReader reader)
        {
            base.OnMessage(peer, reader);
            var bulletId = reader.GetLong();
            var npcId = reader.GetLong();

            base.IntactTransterMessage(peer, reader, true);
            Log.Info("Bullet:>" + bulletId + " npcId:>" + npcId);
        }
        public static NO_MarketItem GetMarketItem(this NetDataReader reader)
        {
            long  realId         = reader.GetLong();
            short itemId         = reader.GetShort();
            short onSaleNum      = reader.GetShort();
            long  virtualCyPrice = reader.GetLong();
            long  chargeCyPrice  = reader.GetLong();

            return(new NO_MarketItem(realId, itemId, onSaleNum, virtualCyPrice, chargeCyPrice));
        }
 public override void Deserialize(NetDataReader reader)
 {
     assetId   = reader.GetString();
     objectId  = reader.GetUInt();
     connectId = reader.GetLong();
     position  = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
 }
Beispiel #12
0
    public void OnNetworkReceive(NetPeer peer, NetDataReader reader)
    {
        if (reader.RawData == null)
        {
            return;
        }

        Debug.Log("Client: " + reader.RawData.Length);

        if (reader.RawData.Length >= 4)
        {
            NetworkTags netTag = (NetworkTags)reader.GetInt();

            if (netTag == NetworkTags.PlayerPositionsArray)
            {
                int lengthArray = (reader.RawData.Length - 4) / (sizeof(long) + sizeof(float) * 3);
                Debug.Log("Positions array data num: " + lengthArray);

                for (int i = 0; i < lengthArray; i++)
                {
                    long playerId = reader.GetLong();

                    if (!netDictionary.ContainsKey(playerId))
                    {
                        netDictionary.Add(playerId, new NetPlayer());
                    }

                    netDictionary[playerId].X = reader.GetFloat();
                    netDictionary[playerId].Y = reader.GetFloat();
                    netDictionary[playerId].Z = reader.GetFloat();
                }
            }
        }
    }
        public void Execute(NetDataReader reader, int netId)
        {
            long  realId = reader.GetLong();
            short num    = reader.GetShort();

            GL_Item.s_instance.CommandDropItemOntoGround(netId, realId, num);
        }
        public void Execute(NetDataReader reader, int netId)
        {
            long  realId = reader.GetLong();
            short num    = reader.GetShort();

            GL_Item.s_instance.CommandApplySellItemInBag(netId, realId, num);
        }
        public override void OnMessage(NetPeer peer, NetDataReader reader)
        {
            var count = reader.GetInt();

            for (int i = 0; i < count; i++)
            {
                var npcid    = reader.GetLong();
                var npcType  = (NpcType)reader.GetUShort();
                var position = reader.GetVector3();
                var rotation = reader.GetQuaternion();

                NPCView npcView = null;
                switch (npcType)
                {
                case NpcType.Player:
                    npcView = npcMgr.CreateNpc <TankView>();
                    break;

                case NpcType.Monster:
                    npcView = npcMgr.CreateNpc <AnimalView>();
                    break;
                }
                if (npcView != null)
                {
                    npcView.Initialize(npcid);
                    npcView.InitInterpolateFields(position, rotation);
                }
                Debugger.LogWarning("OnResNpcs--->>>" + npcid + " " + npcType + " " + position);
            }
        }
Beispiel #16
0
 public void Deserialize(NetDataReader reader)
 {
     index      = reader.GetInt();
     logTime    = reader.GetLong();
     condition  = reader.GetString();
     stackTrace = reader.GetString();
     logType    = (LogType)reader.GetInt();
 }
        public static NO_Shortcut GetShortcut(this NetDataReader reader)
        {
            ShortcutType type      = (ShortcutType)reader.GetByte();
            byte         placement = reader.GetByte();
            long         data      = reader.GetLong();

            return(new NO_Shortcut(type, placement, data));
        }
 public void Deserialize(NetDataReader reader)
 {
     hashAssetId  = reader.GetInt();
     objectId     = reader.GetPackedUInt();
     connectionId = reader.GetLong();
     position     = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
     rotation     = Quaternion.Euler(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
 }
Beispiel #19
0
 public void ReadPayload(NetDataReader reader)
 {
     this.Path      = reader.GetString(100);
     this.Name      = reader.GetString(100);
     this.Directory = reader.GetBool();
     this.Size      = reader.GetLong();
     this.Modified  = reader.GetString(100);
 }
Beispiel #20
0
 public InputPacket(NetDataReader dataReader)
 {
     CharacterID         = dataReader.GetString();
     InputSequenceNumber = dataReader.GetLong();
     Horizontal          = dataReader.GetFloat();
     Vertical            = dataReader.GetFloat();
     Action = dataReader.GetBool();
 }
        public override void OnMessage(NetPeer peer, NetDataReader reader)
        {
            var npcid   = reader.GetLong();
            var npcView = npcMgr.GetNpc(npcid) as NPCView;

            if (npcView != null)
            {
                npcView.ReadDirtyFields(reader);
            }
        }
        public static NO_GroundItem GetGroundItem(this NetDataReader reader)
        {
            long    gndItemId = reader.GetLong();
            short   itemId    = reader.GetShort();
            short   num       = reader.GetShort();
            int     charId    = reader.GetInt();
            Vector2 pos       = reader.GetVector2();

            return(new NO_GroundItem(gndItemId, itemId, num, charId, pos));
        }
        public static NO_Item GetItem(this NetDataReader reader)
        {
            ItemPlace ip     = (ItemPlace)reader.GetByte();
            short     pos    = reader.GetShort();
            long      realId = reader.GetLong();
            short     itemId = reader.GetShort();
            short     num    = reader.GetShort();

            return(new NO_Item(ip, pos, realId, itemId, num));
        }
Beispiel #24
0
        public void Deserialize(NetDataReader reader)
        {
            id            = reader.GetString();
            type          = reader.GetString();
            growthTime    = reader.GetLong();
            plantableType = reader.GetString();
            timePlanted   = reader.GetLong();
            x             = reader.GetFloat();
            y             = reader.GetFloat();
            z             = reader.GetFloat();
            rot_x         = reader.GetFloat();
            rot_y         = reader.GetFloat();
            rot_z         = reader.GetFloat();
            rot_w         = reader.GetFloat();

            locked        = reader.GetBool();
            lockedBy      = reader.GetString();
            lockStartTime = reader.GetLong();
        }
        public object Deserialize(NetDataReader stream)
        {
            var objToSerialize = new SyncedTime();

            {
                objToSerialize.Time = stream.GetLong();
            }

            return(objToSerialize);
        }
        public override void OnMessage(NetPeer peer, NetDataReader reader)
        {
            var bulletId = reader.GetLong();    //子弹ID
            var targetId = reader.GetLong();    //对象ID
            ///销毁子弹
            var bullet = bulletMgr.GetView(bulletId);

            if (bullet != null)
            {
                bullet.OnBomb();
            }
            ///销毁NPC
            var npcView = npcMgr.GetNpc(targetId);

            if (npcView != null)
            {
                npcView.OnDispose();
            }
        }
        /// <summary>
        /// 玩家掉线
        /// </summary>
        public override void OnMessage(NetPeer peer, NetDataReader reader)
        {
            var npcid = reader.GetLong();

            var playerName = "Player_" + npcid;

            npcMgr.RemoveNpc <TankView>(npcid);

            //lockstepMgr.UpdateClientCount(npcid);
            Debugger.LogWarning("PlayerDisconnect--->>>" + playerName);
        }
Beispiel #28
0
 public StatePacket(NetDataReader dataReader)
 {
     this.CharacterID         = dataReader.GetString();
     this.InputSequenceNumber = dataReader.GetLong();
     this.X         = dataReader.GetFloat();
     this.Y         = dataReader.GetFloat();
     this.Rotation  = dataReader.GetFloat();
     this.Palette   = dataReader.GetInt();
     this.Animation = dataReader.GetInt();
     this.Timestamp = dataReader.GetInt();
 }
Beispiel #29
0
        public void WriteReadLong()
        {
            var ndw = new NetDataWriter();

            ndw.Put(64L);

            var ndr      = new NetDataReader(ndw.Data);
            var readLong = ndr.GetLong();

            Assert.AreEqual(readLong, 64L);
        }
Beispiel #30
0
 public override void Deserialize(NetDataReader reader)
 {
     type = NetPacketType.TurnData;
     base.Deserialize(reader);
     turn     = reader.GetLong();
     count    = reader.GetInt();
     commands = new List <Command>();
     for (int i = 0; i < count; i++)
     {
         Command cmd = CommandFactory.Create(reader);
         cmd.Source = sender;
         commands.Add(cmd);
     }
 }