//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; } }
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); }
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(); }
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; }
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); }
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); }
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); }
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(); }
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); }
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); }
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)); }
//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 } }
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 } }