Esempio n. 1
0
        public byte[] toBytes()
        {
            int total = this.getBytesSize();

            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, this.ownerRoleID, true, 0);
            ProtoUtil.StringMemberToBytes(data, 2, ref offset, this.ownerRoleName);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, this.autoID, true, 0);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, this.goodsPackID, true, 0);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, this.mapCode, true, 0);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, this.toX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, this.toY, true, 0);
            ProtoUtil.IntMemberToBytes(data, 8, ref offset, this.goodsID, true, 0);
            ProtoUtil.IntMemberToBytes(data, 9, ref offset, this.goodsNum, true, 0);
            ProtoUtil.LongMemberToBytes(data, 10, ref offset, this.productTicks, true, 0L);
            ProtoUtil.LongMemberToBytes(data, 11, ref offset, this.teamID, true, 0L);
            ProtoUtil.StringMemberToBytes(data, 12, ref offset, this.teamRoleIDs);
            ProtoUtil.IntMemberToBytes(data, 13, ref offset, this.lucky, true, 0);
            ProtoUtil.IntMemberToBytes(data, 14, ref offset, this.excellenceInfo, true, 0);
            ProtoUtil.IntMemberToBytes(data, 15, ref offset, this.appendPropLev, true, 0);
            ProtoUtil.IntMemberToBytes(data, 16, ref offset, this.forge_Level, true, 0);
            return(data);
        }
Esempio n. 2
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(this.RoleID, true, 1, true, 0);
            total += ProtoUtil.GetIntSize(this.Action, true, 2, true, 0);
            total += ProtoUtil.GetIntSize(this.MapCode, true, 3, true, 0);
            total += ProtoUtil.GetIntSize(this.ToMapX, true, 4, true, 0);
            total += ProtoUtil.GetIntSize(this.ToMapY, true, 5, true, 0);
            total += ProtoUtil.GetIntSize(this.ToDiection, true, 6, true, 0);
            total += ProtoUtil.GetIntSize(this.TryRun, true, 7, true, 0);
            total += ProtoUtil.GetLongSize(this.clientTicks, true, 8, true, 0L);
            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, this.RoleID, true, 0);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, this.Action, true, 0);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, this.MapCode, true, 0);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, this.ToMapX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, this.ToMapY, true, 0);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, this.ToDiection, true, 0);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, this.TryRun, true, 0);
            ProtoUtil.LongMemberToBytes(data, 8, ref offset, this.clientTicks, true, 0L);
            return(data);
        }
Esempio n. 3
0
        public void TestHasComponentSerialization()
        {
            // Arrange
            HasComponents unitUnderTest = this.CreateHasComponents();

            // Act
            byte[] data = ProtoUtil.Serialize(unitUnderTest);

            Assert.IsNotNull(data, "Serialization failed");

            HasComponents deserialized = ProtoUtil.Deserialize <HasComponents>(data);

            // Assert
            Assert.IsNotNull(deserialized, "Deserialization failed");

            Assert.IsTrue(unitUnderTest.HasComponent <DropWhenCompletelyHarvested>());
            Assert.IsNotNull(unitUnderTest.GetExactComponent <DropWhenCompletelyHarvested>());
            Assert.IsNotNull(unitUnderTest.GetComponent <DropWhenCompletelyHarvested>());
            Assert.IsNotNull(unitUnderTest.GetComponent <ComponentHarvestable>());

            Assert.IsTrue(deserialized.HasComponent <DropWhenCompletelyHarvested>());
            Assert.IsNotNull(deserialized.GetExactComponent <DropWhenCompletelyHarvested>());
            Assert.IsNotNull(deserialized.GetComponent <DropWhenCompletelyHarvested>());
            Assert.IsNotNull(deserialized.GetComponent <ComponentHarvestable>());
            Assert.IsNotNull(deserialized.GetExactComponent <ComponentSelectable>(), "Components didn't serialize properly");
            Assert.IsNotNull(deserialized.GetExactComponent <ComponentRenderer>(), "Components didn't serialize properly");
        }
Esempio n. 4
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(this.roleID, true, 1);
            total += ProtoUtil.GetIntSize(this.roleX, true, 2);
            total += ProtoUtil.GetIntSize(this.roleY, true, 3);
            total += ProtoUtil.GetIntSize(this.enemy, true, 4);
            total += ProtoUtil.GetIntSize(this.enemyX, true, 5);
            total += ProtoUtil.GetIntSize(this.enemyY, true, 6);
            total += ProtoUtil.GetIntSize(this.realEnemyX, true, 7);
            total += ProtoUtil.GetIntSize(this.realEnemyY, true, 8);
            total += ProtoUtil.GetIntSize(this.magicCode, true, 9);
            total += ProtoUtil.GetLongSize(this.clientTicks, true, 10);
            total += ProtoUtil.GetStringSize(this.attackedList, true, 11);

            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, this.roleID);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, this.roleX);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, this.roleY);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, this.enemy);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, this.enemyX);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, this.enemyY);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, this.realEnemyX);
            ProtoUtil.IntMemberToBytes(data, 8, ref offset, this.realEnemyY);
            ProtoUtil.IntMemberToBytes(data, 9, ref offset, this.magicCode);
            ProtoUtil.LongMemberToBytes(data, 10, ref offset, this.clientTicks);
            ProtoUtil.StringMemberToBytes(data, 11, ref offset, this.attackedList);

            return(data);
        }
Esempio n. 5
0
    //初始化网络组件
    public void InitNetComponent()
    {
        if (_netComponentInitted)
        {
            return;
        }

        Log.info(">> 初始化网络组件!");
        _netComponentInitted = true;


        //------------- 定义GameSvr连接 -----------
        //协议
        _gameSvrProtoUtil = new ProtoUtil();
        //连接
        _gameSvrConnect = NetworkConnect.Create("GameSvrNet", Core.SystemPluginRoot, _gameSvrProtoUtil);
        _gameSvrConnect.RegisterHandle(this.SendHeartBeadPkg, this.ChkSendPkg, this.ChkRecvPkg, this.PkgError);

        //TODO 后续可以定义 BattleSvr 连接,并添加到管理列表

        //网络状态监控
        _networkMonitor = NetworkMonitor.Create(Core.SystemPluginRoot);
        //降定义的svr连接加入到网络状态监控器中
        _networkMonitor.AddServerNet(_gameSvrConnect);
    }
Esempio n. 6
0
        public int fromBytes(byte[] data, int offset, int count)
        {
            int pos     = offset;
            int mycount = 0;

            for (; mycount < count;)
            {
                int fieldnumber = -1;
                int wt          = -1;
                ProtoUtil.GetTag(data, ref pos, ref fieldnumber, ref wt, ref mycount);

                switch (fieldnumber)
                {
                case 1: this.roleID = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 2: this.npcID = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 3: this.taskID = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 4: this.state = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                default:
                {
                    throw new ArgumentException("error!!!");
                }
                }
            }
            return(pos);
        }
Esempio n. 7
0
// read from proto
        public void FromProto(netproto.EquipPack pdata)
        {
            if (pdata.limit != null)
            {
                this.limit        = ProtoUtil.OptVal(pdata.limit);
                this.isDirtylimit = true;
            }
            for (int i = 0; i < pdata.equips.Count; i++)
            {
                var val = pdata.equips[i];
                if (val.val == null)
                {
                    this.equips.Remove(ProtoUtil.OptVal(val.key));
                }
                else
                {
                    Equip oval;
                    if (!this.equips.TryGetValue(ProtoUtil.OptVal(val.key), out oval))
                    {
                        oval = new Equip();
                        oval.FromProto(val.val);
                        this.equips[ProtoUtil.OptVal(val.key)] = oval;
                    }
                    else
                    {
                        oval.FromProto(val.val);
                    }
                }
            }
            this.isDirtyequips = true;
        }
Esempio n. 8
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(enemy, true, 1);
            total += ProtoUtil.GetIntSize(burst, true, 2);
            total += ProtoUtil.GetIntSize(injure, true, 3);
            total += ProtoUtil.GetDoubleSize(enemyLife, true, 4);
            total += ProtoUtil.GetLongSize(newExperience, true, 5);
            total += ProtoUtil.GetLongSize(currentExperience, true, 6);
            total += ProtoUtil.GetIntSize(newLevel, true, 7);
            total += ProtoUtil.GetIntSize(MerlinInjuer, true, 8);
            total += ProtoUtil.GetIntSize(MerlinType, true, 9);
            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, enemy);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, burst);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, injure);
            ProtoUtil.DoubleMemberToBytes(data, 4, ref offset, enemyLife);
            ProtoUtil.LongMemberToBytes(data, 5, ref offset, newExperience);
            ProtoUtil.LongMemberToBytes(data, 6, ref offset, currentExperience);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, newLevel);
            ProtoUtil.IntMemberToBytes(data, 8, ref offset, MerlinInjuer);
            ProtoUtil.IntMemberToBytes(data, 9, ref offset, MerlinType);

            return(data);
        }
Esempio n. 9
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(this.RoleID, true, 1, true, 0);
            total += ProtoUtil.GetIntSize(this.MapCode, true, 2, true, 0);
            total += ProtoUtil.GetLongSize(this.StartMoveTicks, true, 3, true, 0L);
            total += ProtoUtil.GetIntSize(this.CurrentX, true, 4, true, 0);
            total += ProtoUtil.GetIntSize(this.CurrentY, true, 5, true, 0);
            total += ProtoUtil.GetIntSize(this.CurrentDirection, true, 6, true, 0);
            total += ProtoUtil.GetIntSize(this.Action, true, 7, true, 0);
            total += ProtoUtil.GetIntSize(this.ToX, true, 8, true, 0);
            total += ProtoUtil.GetIntSize(this.ToY, true, 9, true, 0);
            total += ProtoUtil.GetDoubleSize(this.MoveCost, true, 10, true, 0.0);
            total += ProtoUtil.GetIntSize(this.ExtAction, true, 11, true, 0);
            total += ProtoUtil.GetStringSize(this.PathString, true, 12);
            total += ProtoUtil.GetIntSize(this.CurrentPathIndex, true, 13, true, 0);
            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, this.RoleID, true, 0);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, this.MapCode, true, 0);
            ProtoUtil.LongMemberToBytes(data, 3, ref offset, this.StartMoveTicks, true, 0L);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, this.CurrentX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, this.CurrentY, true, 0);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, this.CurrentDirection, true, 0);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, this.Action, true, 0);
            ProtoUtil.IntMemberToBytes(data, 8, ref offset, this.ToX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 9, ref offset, this.ToY, true, 0);
            ProtoUtil.DoubleMemberToBytes(data, 10, ref offset, this.MoveCost, true, 0.0);
            ProtoUtil.IntMemberToBytes(data, 11, ref offset, this.ExtAction, true, 0);
            ProtoUtil.StringMemberToBytes(data, 12, ref offset, this.PathString);
            ProtoUtil.IntMemberToBytes(data, 13, ref offset, this.CurrentPathIndex, true, 0);
            return(data);
        }
Esempio n. 10
0
    public static int GetListIntBytesSize(List <int> lst, bool calcMember = false, int protoMember = 0)
    {
        int result;

        if (lst == null || lst.Count <= 0)
        {
            result = 0;
        }
        else
        {
            int ntag = 0;
            if (calcMember)
            {
                if (protoMember <= 15)
                {
                    ntag = 1;
                }
                else
                {
                    ntag = 2;
                }
            }
            int count = 0;
            count += ProtoUtil.CalcIntSize(lst.Count);
            int tc = lst.Count;
            for (int i = 0; i < tc; i++)
            {
                count += ProtoUtil.CalcIntSize(lst[i]);
            }
            result = ntag + count;
        }
        return(result);
    }
Esempio n. 11
0
    public static List <int> ListIntFromBytes(byte[] data, int wt, ref int offset, ref int ncount, List <int> lst)
    {
        List <int> result;

        if (data == null)
        {
            result = lst;
        }
        else
        {
            if (wt != 2)
            {
                throw new ArgumentException("list member from bytes error, type error!!!");
            }
            int count = ProtoUtil.IntFromBytes(data, ref offset, ref ncount);
            if (count <= 0)
            {
                result = lst;
            }
            else
            {
                if (lst == null)
                {
                    lst = new List <int>(count);
                }
                for (int i = 0; i < count; i++)
                {
                    int val = ProtoUtil.IntFromBytes(data, ref offset, ref ncount);
                    lst.Add(val);
                }
                result = lst;
            }
        }
        return(result);
    }
Esempio n. 12
0
 public static void ListMemberFromBytes <T>(List <T> lst, byte[] data, int wt, ref int offset, ref int ncount) where T : class, IProtoBuffData, new()
 {
     if (lst != null && data != null)
     {
         if (wt != 2)
         {
             throw new ArgumentException("list member from bytes error, type error!!!");
         }
         int count = ProtoUtil.IntFromBytes(data, ref offset, ref ncount);
         for (int i = 0; i < count; i++)
         {
             int size = ProtoUtil.IntFromBytes(data, ref offset, ref ncount);
             T   obj  = Activator.CreateInstance <T>();
             if (size <= 0)
             {
                 lst.Add(obj);
             }
             else
             {
                 int newPos = obj.fromBytes(data, offset, size);
                 ncount += newPos - offset;
                 offset  = newPos;
                 lst.Add(obj);
             }
         }
     }
 }
Esempio n. 13
0
    public static int GetStringSize(string val, bool calcMember = false, int protoMember = 0)
    {
        int result;

        if (val == null)
        {
            result = 0;
        }
        else
        {
            int ntag = 0;
            if (calcMember)
            {
                if (protoMember <= 15)
                {
                    ntag = 1;
                }
                else
                {
                    ntag = 2;
                }
            }
            int len = val.Length;
            if (len == 0)
            {
                result = 1 + ntag;
            }
            else
            {
                int predicted = new UTF8Encoding().GetByteCount(val);
                result = ntag + ProtoUtil.CalcIntSize(predicted) + predicted;
            }
        }
        return(result);
    }
Esempio n. 14
0
    public static void GetTag(byte[] data, ref int offset, ref int fieldnumber, ref int wt, ref int ncount)
    {
        int tag = ProtoUtil.IntFromBytes(data, ref offset, ref ncount);

        fieldnumber = tag >> 3;
        wt          = (tag & 7);
    }
Esempio n. 15
0
        public int fromBytes(byte[] data, int offset, int count)
        {
            int pos     = offset;
            int mycount = 0;

            for (; mycount < count;)
            {
                int fieldnumber = -1;
                int wt          = -1;
                ProtoUtil.GetTag(data, ref pos, ref fieldnumber, ref wt, ref mycount);

                switch (fieldnumber)
                {
                case 1: roleID = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 2: mapCode = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 3: toX = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 4: toY = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 5: currentPosTicks = ProtoUtil.LongMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 6: toDirection = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                default:
                {
                    throw new ArgumentException("error!!!");
                }
                }
            }

            return(pos);
        }
Esempio n. 16
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(RoleID, true, 1);
            total += ProtoUtil.GetIntSize(Action, true, 2);
            total += ProtoUtil.GetIntSize(MapCode, true, 3);
            total += ProtoUtil.GetIntSize(ToMapX, true, 4);
            total += ProtoUtil.GetIntSize(ToMapY, true, 5);
            total += ProtoUtil.GetIntSize(ToDiection, true, 6);
            total += ProtoUtil.GetIntSize(TryRun, true, 7);
            total += ProtoUtil.GetLongSize(clientTicks, true, 8);

            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, RoleID);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, Action);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, MapCode);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, ToMapX);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, ToMapY);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, ToDiection);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, TryRun);
            ProtoUtil.LongMemberToBytes(data, 8, ref offset, clientTicks);

            return(data);
        }
Esempio n. 17
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(this.roleID, true, 1, true, 0);
            total += ProtoUtil.GetIntSize(this.mapCode, true, 2, true, 0);
            total += ProtoUtil.GetIntSize(this.direction, true, 3, true, 0);
            total += ProtoUtil.GetIntSize(this.action, true, 4, true, 0);
            total += ProtoUtil.GetIntSize(this.toX, true, 5, true, 0);
            total += ProtoUtil.GetIntSize(this.toY, true, 6, true, 0);
            total += ProtoUtil.GetIntSize(this.targetX, true, 7, true, 0);
            total += ProtoUtil.GetIntSize(this.targetY, true, 8, true, 0);
            total += ProtoUtil.GetIntSize(this.yAngle, true, 9, true, 0);
            total += ProtoUtil.GetIntSize(this.moveToX, true, 10, true, 0);
            total += ProtoUtil.GetIntSize(this.moveToY, true, 11, true, 0);
            total += ProtoUtil.GetLongSize(this.clientTicks, true, 12, true, 0L);
            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, this.roleID, true, 0);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, this.mapCode, true, 0);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, this.direction, true, 0);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, this.action, true, 0);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, this.toX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, this.toY, true, 0);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, this.targetX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 8, ref offset, this.targetY, true, 0);
            ProtoUtil.IntMemberToBytes(data, 9, ref offset, this.yAngle, true, 0);
            ProtoUtil.IntMemberToBytes(data, 10, ref offset, this.moveToX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 11, ref offset, this.moveToY, true, 0);
            ProtoUtil.LongMemberToBytes(data, 12, ref offset, this.clientTicks, true, 0L);
            return(data);
        }
Esempio n. 18
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(this.Error, true, 1);
            total += ProtoUtil.GetIntSize(this.DbId, true, 2);
            total += ProtoUtil.GetIntSize(this.Cnt, true, 3);

            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, this.Error);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, this.DbId);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, this.Cnt);

            /*
             * MemoryStream ms = new MemoryStream();
             *
             * Serializer.Serialize<SC_SprUseGoods>(ms,this);
             * ms.Position = 0;
             * byte[] buff = new byte[ ms.Length ];
             * ms.Read(buff, 0, (int)ms.Length);*/

            return(data);
        }
Esempio n. 19
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(roleID, true, 1);
            total += ProtoUtil.GetIntSize(mapCode, true, 2);
            total += ProtoUtil.GetIntSize(action, true, 3);
            total += ProtoUtil.GetIntSize(toX, true, 4);
            total += ProtoUtil.GetIntSize(toY, true, 5);
            total += ProtoUtil.GetIntSize(extAction, true, 6);
            total += ProtoUtil.GetIntSize(fromX, true, 7);
            total += ProtoUtil.GetIntSize(fromY, true, 8);
            total += ProtoUtil.GetLongSize(startMoveTicks, true, 9);
            total += ProtoUtil.GetStringSize(pathString, true, 10);
            total += ProtoUtil.GetDoubleSize(moveCost, true, 11);
            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, roleID);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, mapCode);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, action);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, toX);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, toY);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, extAction);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, fromX);
            ProtoUtil.IntMemberToBytes(data, 8, ref offset, fromY);
            ProtoUtil.LongMemberToBytes(data, 9, ref offset, startMoveTicks);
            ProtoUtil.StringMemberToBytes(data, 10, ref offset, pathString);
            ProtoUtil.DoubleMemberToBytes(data, 11, ref offset, moveCost);
            return(data);
        }
Esempio n. 20
0
        public int fromBytes(byte[] data, int offset, int count)
        {
            int pos     = offset;
            int mycount = 0;

            for (; mycount < count;)
            {
                int fieldnumber = -1;
                int wt          = -1;
                ProtoUtil.GetTag(data, ref pos, ref fieldnumber, ref wt, ref mycount);

                switch (fieldnumber)
                {
                case 1: this.RoleID = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 2: this.TeleportID = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 3: this.NewMapCode = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 4: this.ToNewMapX = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 5: this.ToNewMapY = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 6: this.ToNewDiection = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 7: this.State = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                default:
                {
                    throw new ArgumentException("error!!!");
                }
                }
            }
            return(pos);
        }
Esempio n. 21
0
        public int fromBytes(byte[] data, int offset, int count)
        {
            int pos     = offset;
            int mycount = 0;

            for (; mycount < count;)
            {
                int fieldnumber = -1;
                int wt          = -1;
                ProtoUtil.GetTag(data, ref pos, ref fieldnumber, ref wt, ref mycount);

                switch (fieldnumber)
                {
                case 1: this.RoleID = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 2: this.RandToken = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 3: this.Ticks = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 4: this.ReportCliRealTick = ProtoUtil.LongMemberFromBytes(data, wt, ref pos, ref mycount); break;

                default:
                {
                    throw new ArgumentException("error!!!");
                }
                }
            }
            return(pos);
        }
Esempio n. 22
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(RoleID, true, 1);
            total += ProtoUtil.GetIntSize(TeleportID, true, 2);
            total += ProtoUtil.GetIntSize(NewMapCode, true, 3);
            total += ProtoUtil.GetIntSize(ToNewMapX, true, 4);
            total += ProtoUtil.GetIntSize(ToNewMapY, true, 5);
            total += ProtoUtil.GetIntSize(ToNewDiection, true, 6);
            total += ProtoUtil.GetIntSize(State, true, 7);

            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, RoleID);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, TeleportID);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, NewMapCode);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, ToNewMapX);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, ToNewMapY);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, ToNewDiection);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, State);

            return(data);
        }
Esempio n. 23
0
        public int fromBytes(byte[] data, int offset, int count)
        {
            int pos     = offset;
            int mycount = 0;

            for (; mycount < count;)
            {
                int fieldnumber = -1;
                int wt          = -1;
                ProtoUtil.GetTag(data, ref pos, ref fieldnumber, ref wt, ref mycount);

                switch (fieldnumber)
                {
                case 1: this.RoleID = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 2: this.Strength = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 3: this.Intelligence = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 4: this.Dexterity = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                case 5: this.Constitution = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount); break;

                default:
                {
                    throw new ArgumentException("error!!!");
                }
                }
            }
            return(pos);
        }
Esempio n. 24
0
        public int fromBytes(byte[] data, int offset, int count)
        {
            int pos     = offset;
            int mycount = 0;

            while (mycount < count)
            {
                int fieldnumber = -1;
                int wt          = -1;
                ProtoUtil.GetTag(data, ref pos, ref fieldnumber, ref wt, ref mycount);
                switch (fieldnumber)
                {
                case 1:
                    this.roleId = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount);
                    break;

                case 2:
                    this.magicCode = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount);
                    break;

                case 3:
                    ProtoUtil.ListMemberFromBytes <SpriteHitedInnerData>(this.enemys, data, wt, ref pos, ref mycount);
                    break;

                default:
                    throw new ArgumentException("error!!!");
                }
            }
            return(pos);
        }
Esempio n. 25
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(roleID, true, 1);
            total += ProtoUtil.GetIntSize(mapCode, true, 2);
            total += ProtoUtil.GetIntSize(direction, true, 3);
            total += ProtoUtil.GetIntSize(action, true, 4);
            total += ProtoUtil.GetIntSize(toX, true, 5);
            total += ProtoUtil.GetIntSize(toY, true, 6);
            total += ProtoUtil.GetIntSize(targetX, true, 7);
            total += ProtoUtil.GetIntSize(targetY, true, 8);
            total += ProtoUtil.GetIntSize(yAngle, true, 9);
            total += ProtoUtil.GetIntSize(moveToX, true, 10);
            total += ProtoUtil.GetIntSize(moveToY, true, 11);
            total += ProtoUtil.GetLongSize(clientTicks, true, 12);
            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, roleID);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, mapCode);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, direction);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, action);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, toX);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, toY);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, targetX);
            ProtoUtil.IntMemberToBytes(data, 8, ref offset, targetY);
            ProtoUtil.IntMemberToBytes(data, 9, ref offset, yAngle);
            ProtoUtil.IntMemberToBytes(data, 10, ref offset, moveToX);
            ProtoUtil.IntMemberToBytes(data, 11, ref offset, moveToY);
            ProtoUtil.LongMemberToBytes(data, 12, ref offset, clientTicks);
            return(data);
        }
Esempio n. 26
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(this.State, true, 1, true, 0);
            total += ProtoUtil.GetIntSize(this.ModType, true, 2, true, 0);
            total += ProtoUtil.GetIntSize(this.ID, true, 3, true, 0);
            total += ProtoUtil.GetIntSize(this.IsUsing, true, 4, true, 0);
            total += ProtoUtil.GetIntSize(this.Site, true, 5, true, 0);
            total += ProtoUtil.GetIntSize(this.Count, true, 6, true, 0);
            total += ProtoUtil.GetIntSize(this.BagIndex, true, 7, true, 0);
            total += ProtoUtil.GetIntSize(this.NewHint, true, 8, true, 0);
            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, this.State, true, 0);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, this.ModType, true, 0);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, this.ID, true, 0);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, this.IsUsing, true, 0);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, this.Site, true, 0);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, this.Count, true, 0);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, this.BagIndex, true, 0);
            ProtoUtil.IntMemberToBytes(data, 8, ref offset, this.NewHint, true, 0);
            return(data);
        }
Esempio n. 27
0
            /// <exception cref="System.IO.IOException"/>
            public virtual void ReadFields(BinaryReader reader)
            {
                int length = ProtoUtil.ReadRawVarint32(@in);

                theResponseRead = new byte[length];
                @in.ReadFully(theResponseRead);
            }
Esempio n. 28
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(this.roleID, true, 1, true, 0);
            total += ProtoUtil.GetIntSize(this.mapCode, true, 2, true, 0);
            total += ProtoUtil.GetIntSize(this.action, true, 3, true, 0);
            total += ProtoUtil.GetIntSize(this.toX, true, 4, true, 0);
            total += ProtoUtil.GetIntSize(this.toY, true, 5, true, 0);
            total += ProtoUtil.GetIntSize(this.extAction, true, 6, true, 0);
            total += ProtoUtil.GetIntSize(this.fromX, true, 7, true, 0);
            total += ProtoUtil.GetIntSize(this.fromY, true, 8, true, 0);
            total += ProtoUtil.GetLongSize(this.startMoveTicks, true, 9, true, 0L);
            total += ProtoUtil.GetStringSize(this.pathString, true, 10);
            total += ProtoUtil.GetDoubleSize(this.moveCost, true, 11, true, 0.0);
            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, this.roleID, true, 0);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, this.mapCode, true, 0);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, this.action, true, 0);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, this.toX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, this.toY, true, 0);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, this.extAction, true, 0);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, this.fromX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 8, ref offset, this.fromY, true, 0);
            ProtoUtil.LongMemberToBytes(data, 9, ref offset, this.startMoveTicks, true, 0L);
            ProtoUtil.StringMemberToBytes(data, 10, ref offset, this.pathString);
            ProtoUtil.DoubleMemberToBytes(data, 11, ref offset, this.moveCost, true, 0.0);
            return(data);
        }
Esempio n. 29
0
        public int fromBytes(byte[] data, int offset, int count)
        {
            int pos     = offset;
            int mycount = 0;

            while (mycount < count)
            {
                int fieldnumber = -1;
                int wt          = -1;
                ProtoUtil.GetTag(data, ref pos, ref fieldnumber, ref wt, ref mycount);
                switch (fieldnumber)
                {
                case 1:
                    this.RoleID = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount);
                    break;

                case 2:
                    this.NextStarLevel = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount);
                    break;

                case 3:
                    this.NextStarExp = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount);
                    break;

                case 4:
                    this.State = ProtoUtil.IntMemberFromBytes(data, wt, ref pos, ref mycount);
                    break;

                default:
                    throw new ArgumentException("error!!!");
                }
            }
            return(pos);
        }
Esempio n. 30
0
        public byte[] toBytes()
        {
            int total = 0;

            total += ProtoUtil.GetIntSize(this.roleID, true, 1, true, 0);
            total += ProtoUtil.GetIntSize(this.roleX, true, 2, true, 0);
            total += ProtoUtil.GetIntSize(this.roleY, true, 3, true, 0);
            total += ProtoUtil.GetIntSize(this.enemy, true, 4, true, 0);
            total += ProtoUtil.GetIntSize(this.enemyX, true, 5, true, 0);
            total += ProtoUtil.GetIntSize(this.enemyY, true, 6, true, 0);
            total += ProtoUtil.GetIntSize(this.realEnemyX, true, 7, true, 0);
            total += ProtoUtil.GetIntSize(this.realEnemyY, true, 8, true, 0);
            total += ProtoUtil.GetIntSize(this.magicCode, true, 9, true, 0);
            total += ProtoUtil.GetLongSize(this.clientTicks, true, 10, true, 0L);
            byte[] data   = new byte[total];
            int    offset = 0;

            ProtoUtil.IntMemberToBytes(data, 1, ref offset, this.roleID, true, 0);
            ProtoUtil.IntMemberToBytes(data, 2, ref offset, this.roleX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 3, ref offset, this.roleY, true, 0);
            ProtoUtil.IntMemberToBytes(data, 4, ref offset, this.enemy, true, 0);
            ProtoUtil.IntMemberToBytes(data, 5, ref offset, this.enemyX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 6, ref offset, this.enemyY, true, 0);
            ProtoUtil.IntMemberToBytes(data, 7, ref offset, this.realEnemyX, true, 0);
            ProtoUtil.IntMemberToBytes(data, 8, ref offset, this.realEnemyY, true, 0);
            ProtoUtil.IntMemberToBytes(data, 9, ref offset, this.magicCode, true, 0);
            ProtoUtil.LongMemberToBytes(data, 10, ref offset, this.clientTicks, true, 0L);
            return(data);
        }