public int GameTime;//剩余总时间. public void SyncPlayer(FrameCommand fmd) { //不同步自己的信息,因为客户端是最新数据,服务器的是旧数据 if (fmd.playerId == PlayerId) { return; } //同步角色的位置,旋转,动作,速度,武器,气血,模型,怒气,buff if (fmd.command == MeteorMsg.Command.ServerSync) { MeteorUnit unit = U3D.GetUnit((int)fmd.playerId); if (unit != null) { unit.synced = true; System.IO.MemoryStream ms = new System.IO.MemoryStream(fmd.Data); PlayerSync sync = ProtoBuf.Serializer.Deserialize <PlayerSync>(ms); unit.ShadowPosition = new Vector3(sync.position.x / 1000.0f, sync.position.y / 1000.0f, sync.position.z / 1000.0f); unit.ShadowRotation = new Quaternion(sync.rotation.x / 1000.0f, sync.rotation.y / 1000.0f, sync.rotation.z / 1000.0f, sync.rotation.w / 1000.0f); unit.ActionMgr.SetAction(sync.action); unit.angle = sync.ang; unit.Attr.hpCur = (int)sync.hp; if (unit.ModelId != sync.model) { ModelItem m = null; if (GameStateMgr.Ins.gameStatus.IsModelInstalled((int)sync.model, ref m)) { U3D.ChangePlayerModel(unit, (int)sync.model); } else { //模型不一样,但是未安装此模型 } } unit.SyncWeapon((int)sync.weapon, (int)sync.weapon1); List <int> buffs = new List <int>(); foreach (var each in BuffMng.Ins.BufDict) { if (each.Value.Units.ContainsKey(unit)) { buffs.Add(each.Key); } } //把我不该有的buff删除 for (int i = 0; i < buffs.Count; i++) { if (!sync.buff.Contains((uint)buffs[i])) { BuffMng.Ins.BufDict[buffs[i]].ClearBuff(unit); } } //把我没有的buff加上 for (int i = 0; i < sync.buff.Count; i++) { if (!buffs.Contains((int)sync.buff[i])) { Option opt = MenuResLoader.Ins.GetItemInfo((int)sync.buff[i]); if (opt != null && opt.IsItem()) { unit.AddBuf(opt); } } } } } }