/// <summary> /// 开始朝方向移动时,发送消息 /// </summary> protected void SendWalkBegin(Vector3 dir, bool force_sendmsg) { if (!mIsSendMsg) { return; } dir.Normalize(); // 通过限制夹角来控制方向同步的频率 float curAngle = Maths.Util.VectorToAngle(dir); if (mLastSendAngle != -100 && force_sendmsg == false) { if (Mathf.Abs(curAngle - mLastSendAngle) < minAngle) { return; } } mLastSendAngle = curAngle; Vector3 pos = mOwner.Trans.position; C2SNwarMove c2sMove = new C2SNwarMove(); PkgNwarMove move_data = new PkgNwarMove(); move_data.id = mOwner.UID.obj_idx; //move_data.type = (uint)walk_type; PkgNwarPos nwarPos = new PkgNwarPos(); nwarPos.px = (int)(pos.x * 100); nwarPos.py = (int)(pos.z * 100); move_data.pos = nwarPos; //move_data.dir = Mathf.Atan(dir.z / dir.x); move_data.dir = Maths.Util.VectorToAngle(dir); move_data.speed = (uint)(mOwner.MoveSpeed * 100); c2sMove.move = move_data; Net.NetClient.GetCrossClient().SendData <C2SNwarMove>(NetMsg.MSG_NWAR_MOVE, c2sMove); mIsMoving = true; mLastSendMovePackageTime = Time.realtimeSinceStartup; mLastSendMoveDir = dir; //GameDebug.Log("<<<MSG_NWAR_MOVE, dirx: " + dir.x + " diry: " + dir.z); }
/// <summary> /// 开始 /// </summary> public override bool Begin(SkillAction action) { base.Begin(action); m_DynamicStageTime = mSkillAction.ActionData.CastingStageTime; m_RealTargetPos = Vector3.zero; // 判定是否要进入持续施法阶段 if (mSkillAction.ActionData.SkillInfo.CastingTime <= 0.0f) { return(false); } Actor src_actor = mSkillAction.SkillParent.SrcActor; // 技能的隐身 if (mSkillAction.ActionData.SkillInfo.Invisible) { if (src_actor.mVisibleCtrl.VisibleMode == EVisibleMode.Visible) { mSkillAction.HideActor = true; src_actor.mVisibleCtrl.SetActorVisible(false, true, false, VisiblePriority.SKILL); } } // 播放动画 string casting_ani = mSkillAction.ActionData.CastingAnimation; if (casting_ani != string.Empty && casting_ani != mSkillAction.ActionData.SkillAnimation) { src_actor.Play(mSkillAction.ActionData.CastingAnimation); } src_actor.SetAnimationSpeed(mSkillAction.SkillParent.SpeedScale); // 施法阶段的位移 MoveCtrl move_ctrl = src_actor.MoveCtrl; mSkillAction.SkillParent.MovingSpeed = mSkillAction.ActionData.SkillInfo.CastingSpeed; src_actor.MoveSpeed = mSkillAction.ActionData.SkillInfo.CastingSpeed; mSkillAction.BeginMove(); uint target_id = mSkillAction.SkillParent.TargetID; // 目标玩家的id if (target_id == 0) // 无目标玩家 { move_ctrl.MoveDirInAttacking(src_actor.ForwardDir); // 沿当前方向移动 Vector3 src_pos = src_actor.Trans.position; m_RealTargetPos = src_pos + mSkillAction.SkillParent.AttackDir * mSkillAction.ActionData.SkillInfo.CastingSpeed * mSkillAction.ActionData.CastingStageTime; XNavMeshHit hit; if (XNavMesh.Raycast(src_pos, m_RealTargetPos, out hit, xc.Dungeon.LevelManager.GetInstance().AreaExclude)) { m_RealTargetPos = PhysicsHelp.BoundaryHitPos(src_pos, hit.position); } } else// 有目标玩家 { Vector3 src_pos = src_actor.Trans.position; Actor target_actor = ActorManager.Instance.GetPlayer(target_id);// 获取目标玩家 Vector3 target_pos = Vector3.zero; if (target_actor != null) { target_pos = target_actor.Trans.position; Vector3 vec = target_pos - src_pos; float len = vec.magnitude; if (len > mSkillAction.RushTargetRange) { float real_len = len - mSkillAction.RushTargetRange; target_pos = src_pos + vec * real_len / len; XNavMeshHit hit; if (XNavMesh.Raycast(src_pos, target_pos, out hit, xc.Dungeon.LevelManager.GetInstance().AreaExclude)) { target_pos = PhysicsHelp.BoundaryHitPos(src_pos, hit.position); } if (mSkillAction.ActionData.SkillInfo.CastingSpeed != 0) { m_RealTargetPos = target_pos; float calc_castingTime = real_len / mSkillAction.ActionData.SkillInfo.CastingSpeed;// 根据距离和速度计算施法阶段的时间 float fix_castingTime = mSkillAction.ActionData.CastingStageTime; if (calc_castingTime < fix_castingTime) { m_DynamicStageTime = calc_castingTime; } } } else { target_pos = src_pos; m_DynamicStageTime = 0; } move_ctrl.MoveDirInAttacking(vec);// 冲到目标点的方向 } else { target_pos = src_pos + mSkillAction.SkillParent.AttackDir * mSkillAction.ActionData.SkillInfo.CastingSpeed * mSkillAction.ActionData.CastingStageTime; XNavMeshHit hit; if (XNavMesh.Raycast(src_pos, target_pos, out hit, xc.Dungeon.LevelManager.GetInstance().AreaExclude)) { target_pos = PhysicsHelp.BoundaryHitPos(src_pos, hit.position); m_RealTargetPos = target_pos; } } if (src_actor.AttackCtrl.mIsSendMsg) { C2SNwarChargeStop charge_stop = new C2SNwarChargeStop(); charge_stop.skill_id = mSkillAction.ActionData.SkillInfo.Id; PkgNwarMove move = new PkgNwarMove(); move.id = src_actor.UID.obj_idx; PkgNwarPos pos = new PkgNwarPos(); pos.px = (int)(target_pos.x * 100); pos.py = (int)(target_pos.z * 100); move.pos = pos; move.speed = 0; move.time = 0; charge_stop.move = move; NetClient.GetCrossClient().SendData <C2SNwarChargeStop>(NetMsg.MSG_NWAR_CHARGE_STOP, charge_stop); } } return(true); }
/// <summary> /// 飞鞋 /// </summary> public static bool TravelBootsJump(Vector3 pos, uint instanceId = 0, bool isFree = false, uint line = 1, bool isAutoFighting = false) { if (instanceId == 0) { instanceId = SceneHelp.Instance.CurSceneID; } if (PKModeManagerEx.Instance.TryToOtherDungeonScene() == false) { return(false); } DBInstance.InstanceInfo instanceInfo = DBInstance.Instance.GetInstanceInfo(instanceId); if (instanceInfo == null) { GameDebug.LogError("Travel boots ump to scene " + instanceId + " error, can not find instance info!!!"); return(false); } // 本地玩家处于护送状态不能用飞鞋 if (CheckLocalPlayerEscortTaskState() == false) { return(false); } // 检查道具 if (isFree == false) { if (VipHelper.GetIsFlyFree() == false) { uint need_goods = GameConstHelper.GetUint("GAME_ITEM_TRAVEL_BOOTS"); if (need_goods > 0) { var num = ItemManager.Instance.GetGoodsNumForBagByTypeId(need_goods); if (num <= 0) { UINotice.Instance.ShowMessage(DBConstText.GetText("ITME_NUM_NOTENOUGH")); return(false); } } } } bool isInstance = false; if (instanceInfo.mWarType == GameConst.WAR_TYPE_DUNGEON) { isInstance = true; } // 检查是否达到等级 uint needLv = InstanceHelper.GetInstanceNeedRoleLevel(instanceId); if (LocalPlayerManager.Instance.LocalActorAttribute.Level < needLv) { // 巅峰等级 uint peakLv = 0; bool isPeak = TransferHelper.IsPeak(needLv, out peakLv); string levelStr = ""; if (isPeak) { levelStr = string.Format(DBConstText.GetText("UI_PLAYER_PEAK_LEVEL_FORMAT_2"), peakLv); // 巅峰{0} } else { levelStr = peakLv.ToString(); // {0} } if (isInstance == true) { UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("INSTANCE_IS_NOT_UNLOCK_NEED_LEVEL"), levelStr)); } else { UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("WILD_INSTANCE_IS_NOT_UNLOCK_NEED_LEVEL"), levelStr)); } return(false); } // 检查是否通关某主线任务 uint needTaskId = instanceInfo.mNeedTaskId; if (needTaskId > 0) { if (TaskHelper.MainTaskIsPassed(needTaskId) == false) { TaskDefine needTaskDefine = TaskDefine.MakeDefine(needTaskId); if (needTaskDefine != null) { // 巅峰等级 uint peakLv = 0; bool isPeak = TransferHelper.IsPeak((uint)needTaskDefine.RequestLevelMin, out peakLv); string levelStr = ""; if (isPeak) { levelStr = string.Format(DBConstText.GetText("UI_PLAYER_PEAK_LEVEL_FORMAT_2"), peakLv); // 巅峰{0} } else { levelStr = peakLv.ToString(); // {0} } if (isInstance == true) { UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("INSTANCE_IS_NOT_UNLOCK_NEED_TASK"), levelStr, needTaskDefine.Name, instanceInfo.mName)); } else { UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("WILD_INSTANCE_IS_NOT_UNLOCK_NEED_TASK"), levelStr, needTaskDefine.Name, instanceInfo.mName)); } } return(false); } } // 判断是否可到达 if (instanceId == SceneHelp.Instance.CurSceneID) { if (InstanceHelper.CanWalkTo(pos) == false) { UINotice.Instance.ShowMessage(DBConstText.GetText("MAP_POS_CAN_NOT_REACH")); return(false); } } // 跳往不同的场景需要加个转圈,防止同时多次跳转 if (instanceId != SceneHelp.Instance.CurSceneID) { ui.ugui.UIManager.GetInstance().ShowWaitScreen(true); } C2STravelBootsJump data = new C2STravelBootsJump(); data.dungeon_id = instanceId; data.line = line; PkgNwarPos pkgNwarPos = new PkgNwarPos(); pkgNwarPos.px = (int)(pos.x / GlobalConst.UnitScale); pkgNwarPos.py = (int)(pos.z / GlobalConst.UnitScale); data.pos = pkgNwarPos; if (isFree == true) { data.is_free = 1; } else { data.is_free = 0; } NetClient.BaseClient.SendData <C2STravelBootsJump>(NetMsg.MSG_TRAVEL_BOOTS_JUMP, data); SceneHelp.Instance.IsAutoFightingAfterSwitchInstance = isAutoFighting; InstanceManager.Instance.IsAutoFighting = false; return(true); }