void OnNotifyMove(SocketModel model) { NotifyMove notify = SerializeUtil.Deserialize <NotifyMove>(model.message); BaseTank tank = TankManager.instance.GetTank(notify.id); if (tank != null) { tank.Move(Tools.ToVec3(notify.pos), Tools.ToVec3(notify.rot)); } }
private void OnReqMove(UserToken token, SocketModel model) { ReqMove req = SerializeUtil.Deserialize <ReqMove>(model.message); //保存坦克的实时坐标 AccountData acc = CacheManager.instance.GetAccount(token.accountid); if (acc == null) { return; } Battle battle = CacheManager.instance.GetBattle(acc.battleid, acc.battleType); if (battle == null) { return; } Tank t = battle.GetTank(token.accountid); if (t != null && t.hp > 0) { ////校验两帧的移动距离 //float deltaTime = Time.time * 0.001f - t.lastMoveTime; //float distance = deltaTime * 5; //float reqDistance = Luna3D.Vector3.Distance(Tools.ToLunaVec3(req.pos), t.lastPos); //if (reqDistance > distance + 0.2f) return; //t.lastMoveTime = Time.time * 0.001f; //修改缓存 t.pos = new Vector3(req.pos.x, 0, req.pos.z); t.rot = Tools.ToLunaVec3(req.rot); t.lastPos = t.pos; //给别人发通知 NotifyMove notify = new NotifyMove(); notify.id = token.accountid; notify.pos = Tools.ToVec_3(t.pos); notify.rot = req.rot; MsgSender.SendOther <NotifyMove>(battle.accounts, token, (int)MsgID.NotifyMove, notify); } }