예제 #1
0
        public static RpEnterScene Deserialization(Dictionary <byte, object> parameters)
        {
            object byteArrayObj = null;

            if (!parameters.TryGetValue(1, out byteArrayObj))
            {
                return(null);
            }
            if (byteArrayObj.GetType() != typeof(byte[]))
            {
                return(null);
            }
            byte[] byteArray = byteArrayObj as byte[];
            if (byteArray.Length < 2)
            {
                return(null);
            }
            int   index = 0;
            short count = SerializeUtils.ReadShort(byteArray, ref index);

            if (count * 4 + index != byteArray.Length)
            {
                return(null);
            }
            int[] sceneUnits = new int[count];
            for (int i = 0; i < count; ++i)
            {
                sceneUnits[i] = SerializeUtils.ReadInt(byteArray, ref index);
            }
            return(new RpEnterScene(sceneUnits));
        }
예제 #2
0
        public static BattleUnitTargetSkill Deserialize(byte[] data, ref int index)
        {
            short skillId      = SerializeUtils.ReadShort(data, ref index);
            int   targetUnitId = SerializeUtils.ReadInt(data, ref index);

            return(new BattleUnitTargetSkill(targetUnitId, skillId));
        }
        public static BattleAreaTargetSkill Deserialize(byte[] data, ref int index)
        {
            short skillId     = SerializeUtils.ReadShort(data, ref index);
            short skillAngle  = SerializeUtils.ReadShort(data, ref index);
            short skillParam1 = SerializeUtils.ReadShort(data, ref index);

            return(new BattleAreaTargetSkill(skillId, skillAngle, skillParam1));
        }
예제 #4
0
        public static object Deserialize(byte[] data)
        {
            int          index       = 0;
            int          accountId   = SerializeUtils.ReadInt(data, ref index);
            string       accountName = SerializeUtils.ReadString(data, ref index);
            bool         isReady     = SerializeUtils.ReadBool(data, ref index);
            RpPlayerData rpData      = new RpPlayerData(accountId, accountName, isReady);

            return(rpData);
        }
예제 #5
0
        public static byte[] Serialize(object x)
        {
            RpPlayerData rpData = (RpPlayerData)x;

            byte[] res   = new byte[4 + 2 + rpData.PlayerName.Length + 1];
            int    index = 0;

            SerializeUtils.WriteInt(res, ref index, rpData.PlayerId);
            SerializeUtils.WriteString(res, ref index, rpData.PlayerName);
            SerializeUtils.WriteBool(res, ref index, rpData.IsReady);
            return(res);
        }
예제 #6
0
        public static Dictionary <byte, object> Serialization(int[] sceneUnits)
        {
            byte[] byteArray = new byte[sceneUnits.Length * 4 + 2];
            int    index     = 0;

            SerializeUtils.WriteShort(byteArray, ref index, (short)sceneUnits.Length);
            for (int i = 0; i < sceneUnits.Length; ++i)
            {
                SerializeUtils.WriteInt(byteArray, ref index, sceneUnits[i]);
            }
            Dictionary <byte, object> retDic = new Dictionary <byte, object>();

            retDic[1] = byteArray;
            return(retDic);
        }
        public static BattleInstructionBase Deserializetion(byte[] byteArray, ref int index)
        {
            if (byteArray.Length < SelfSerializationByteLength)
            {
                return(null);
            }
            int sceneUnitId = SerializeUtils.ReadInt(byteArray, ref index);
            BattleInstructionType instructionType = (BattleInstructionType)SerializeUtils.ReadByte(byteArray, ref index);
            BattleInstructionBase ret             = null;

            switch (instructionType)
            {
            case BattleInstructionType.Move:
                ret = BattleMove.Deserialize(byteArray, ref index);
                break;

            case BattleInstructionType.StopMove:
                ret = BattleStopMove.Deserialize(byteArray, ref index);
                break;

            case BattleInstructionType.NoTargetSkill:
                ret = BattleNoTargetSkill.Deserialize(byteArray, ref index);
                break;

            case BattleInstructionType.UnitTargetSkill:
                ret = BattleUnitTargetSkill.Deserialize(byteArray, ref index);
                break;

            case BattleInstructionType.AreaTargetSkill:
                ret = BattleAreaTargetSkill.Deserialize(byteArray, ref index);
                break;

            default:

                break;
            }
            if (null != ret)
            {
                ret.SceneUnitId = sceneUnitId;
            }
            return(ret);
        }
        public static RpBattleInstructionList Deserialization(Dictionary <byte, object> parameters)
        {
            byte[] byteArray = parameters[1] as byte[];
            if (byteArray == null || byteArray.Length < 7)
            {
                return(null);
            }

            List <BattleInstructionBase> instructionList = new List <BattleInstructionBase>();

            int   index            = 0;
            int   frameCount       = SerializeUtils.ReadInt(byteArray, ref index);
            short instructionCount = SerializeUtils.ReadShort(byteArray, ref index);
            bool  isFrameFinish    = SerializeUtils.ReadBool(byteArray, ref index);

            RpBattleInstructionList retBattleInstruction = new RpBattleInstructionList(frameCount, instructionList, isFrameFinish);

            for (int i = 0; i < instructionCount; ++i)
            {
                BattleInstructionBase instruction = BattleInstructionBase.Deserializetion(byteArray, ref index);
                instructionList.Add(instruction);
            }
            return(retBattleInstruction);
        }
        public static Dictionary <byte, object> Serialization(int frameCount, List <BattleInstructionBase> battleInstructionList, bool isFrameFinish)
        {
            int totalByteLength = 4 + 2 + 1;

            for (int i = 0; i < battleInstructionList.Count; ++i)
            {
                totalByteLength += battleInstructionList[i].GetSerializationByteLength();
            }
            byte[] byteArray = new byte[totalByteLength];
            int    index     = 0;

            SerializeUtils.WriteInt(byteArray, ref index, frameCount);
            SerializeUtils.WriteShort(byteArray, ref index, (short)battleInstructionList.Count);
            SerializeUtils.WriteBool(byteArray, ref index, isFrameFinish);
            for (int i = 0; i < battleInstructionList.Count; ++i)
            {
                battleInstructionList[i].Serialization(byteArray, ref index);
            }

            Dictionary <byte, object> retDic = new Dictionary <byte, object>();

            retDic[1] = byteArray;
            return(retDic);
        }
예제 #10
0
 protected override void SerializationToByte(byte[] bytes, ref int index)
 {
     SerializeUtils.WriteShort(bytes, ref index, SkillId);
     SerializeUtils.WriteInt(bytes, ref index, TargetUnitId);
 }
 public void Serialization(byte[] byteArray, ref int index)
 {
     SerializeUtils.WriteInt(byteArray, ref index, SceneUnitId);
     SerializeUtils.WriteByte(byteArray, ref index, (byte)InstructionType);
     SerializationToByte(byteArray, ref index);
 }
예제 #12
0
        public static BattleNoTargetSkill Deserialize(byte[] data, ref int index)
        {
            short skillId = SerializeUtils.ReadShort(data, ref index);

            return(new BattleNoTargetSkill(skillId));
        }
예제 #13
0
        public static BattleMove Deserialize(byte[] data, ref int index)
        {
            short movaAngle = SerializeUtils.ReadShort(data, ref index);

            return(new BattleMove(movaAngle));
        }
예제 #14
0
 protected override void SerializationToByte(byte[] bytes, ref int index)
 {
     SerializeUtils.WriteShort(bytes, ref index, MoveAngle);
 }
 protected override void SerializationToByte(byte[] bytes, ref int index)
 {
     SerializeUtils.WriteShort(bytes, ref index, SkillId);
     SerializeUtils.WriteShort(bytes, ref index, SkillAngle);
     SerializeUtils.WriteInt(bytes, ref index, SkillParam1);
 }