示例#1
0
        //UnitName unit, Vector3 position, Quaternion rotation
        public static void CreateObject(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            UnitName   unitName = (UnitName)proto.GetByte(start, ref start);
            Vector3    pos      = ParseVector3(proto, ref start);
            Quaternion rot      = ParseQuaternion(proto, ref start);
            int        unitId   = proto.GetByte(start, ref start);

            bool       isLocal  = proto.GetByte(start, ref start) == 1;
            UnitData   unitData = Gamef.LoadUnitData(unitName);
            GameObject prefab   = isLocal ? unitData.LocalPrefab : unitData.NetPrefab;
            GameObject gameObj  = Gamef.Instantiate(prefab, pos, rot);
            //set id
            Unit unit = gameObj.GetComponent <Unit>();

            unit.InitAttributes(unitId);
            if (unitName == UnitName.Player && isLocal)
            {
                CameraGroupController.Instance.ResetTransform(pos, rot);
                GameCtrl.PlayerUnit = unit;
            }
        }
示例#2
0
        public static void SyncTimeCheck(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long delta = proto.GetLong(start, ref start);

            ClientLauncher.Instance.TimeCheck(delta);
        }
示例#3
0
        public static void StartGame(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            Client.Instance.pl_info.id_game = proto.GetByte(start, ref start);

            //Loading
            GameCtrl.Instance.StartLoadingGameScene();
        }
示例#4
0
        public static void Chatting(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            string str;

            Debug.Log(str = proto.GetString(start, ref start));
            ClientLauncher.Instance.message = str;
        }
示例#5
0
        public static void SyncMouseButton0Up(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long instant = proto.GetInt(start, ref start);
            int  id      = proto.GetByte(start, ref start);
            Unit unit    = Gamef.GetUnit(id);

            unit.SyncPlayerInput.SyncMouseButton0Up(instant);
        }
示例#6
0
        public static void SyncMP(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long  instant = proto.GetInt(start, ref start);
            int   id      = proto.GetByte(start, ref start);
            Unit  unit    = Gamef.GetUnit(id);
            float val     = proto.GetFloat(start, ref start);

            unit.SyncUnitState.SyncMP(instant, val);
        }
示例#7
0
        public static void SyncStop(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long instant    = proto.GetInt(start, ref start);
            int  id         = proto.GetByte(start, ref start);
            int  skillIndex = proto.GetByte(start, ref start);
            Unit unit       = Gamef.GetUnit(id);

            unit.SyncPlayerCastingState.SyncStop(instant, skillIndex);
        }
示例#8
0
        public static void DestroyObj(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long instant = proto.GetInt(start, ref start);
            int  id      = proto.GetByte(start, ref start);
            Unit unit    = Gamef.GetUnit(id);

            //Destroy the object.
            unit.Death();
        }
示例#9
0
        public static void SyncTransform(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long       instant  = proto.GetInt(start, ref start);
            int        id       = proto.GetByte(start, ref start);
            Unit       unit     = Gamef.GetUnit(id);
            Vector3    position = ParseVector3(proto, ref start);
            Quaternion rot      = ParseQuaternion(proto, ref start);
            float      speed    = proto.GetFloat(start, ref start);

            unit.SyncMovement.SyncTransform(instant, position, rot, speed);
        }
示例#10
0
        public static void SyncMobileControlAxes(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long instant = proto.GetInt(start, ref start);           //parse instant
            int  id      = proto.GetByte(start, ref start);          //parse id

            int[]   hv  = ParseHaV(proto.GetByte(start, ref start)); //parse h and v
            Vector3 fwd = ParseVector3(proto, ref start);            // parse camera forward

            Unit unit = Gamef.GetUnit(id);

            unit.SyncPlayerInput.SyncMobileControlAxes(instant, hv[0], hv[1], fwd);
        }
示例#11
0
        public static void SyncAimTarget(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            long instant  = proto.GetInt(start, ref start);
            int  sourceId = proto.GetByte(start, ref start);
            int  targetId = proto.GetByte(start, ref start);

            if (targetId == 255)
            {
                targetId = -1;
            }
            Unit unit = Gamef.GetUnit(sourceId);

            Debug.Log(string.Format("Send sync target ID {0} -> ID {1}", sourceId, targetId));
            unit.SyncPlayerCastingState.SyncTarget(instant, Gamef.GetUnit(targetId));
        }
示例#12
0
        //public void Logout(ProtocolBase protocol){}

        public static void Register(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            int ispass = proto.GetByte(start, ref start);

            if (ispass == 1)
            {
                //int id = proto.GetByte(start, ref start);
                Debug.Log("Reg success");
                //Login
            }
            else
            {
                Debug.Log("Reg failed");
                //Login failed
            }
        }
示例#13
0
        public static void Login(ProtocolBase protocol)
        {
            int           start = 0;
            ProtocolBytes proto = (ProtocolBytes)protocol;

            proto.GetNameX(start, ref start);
            int ispass = proto.GetByte(start, ref start);

            if (ispass == 1)
            {
                Debug.Log("Login success");
                Client.Instance.pl_info.isLogin = true;
                //Login
                //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                DataSync.Match();
                //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            }
            else
            {
                Debug.Log("Login failed");
                //Login failed
            }
        }