//开始进行轻功移动 private void StartLightSkillMove(int nAnimID, Vector3 vecTargetPos) { IsLightState = true; m_fTotalLightHightRefix = 0.0f; //首先屏蔽掉NavMesh和胶囊碰撞 if (null != NavAgent && NavAgent.enabled) { NavAgent.enabled = false; } //面向目标点 FaceTo(vecTargetPos); //皆为直线运动,所以直接底层MoveTo即可 MoveTo(vecTargetPos, null, 0.0f); if (null != AnimLogic) { AnimLogic.Stop(); AnimLogic.Play(nAnimID); } if (null != ObjEffectController) { ObjEffectController.PlayEffect(GlobeVar.LIGHT_SKILL_EFFECT); } m_LightSkillTargetPos = vecTargetPos; //开启拖尾特效 //ShowLightShadowEffect(true); //主角的话播放音效 if (ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_MAIN_PLAYER) { if (null != GameManager.gameManager.SoundManager) { GameManager.gameManager.SoundManager.PlaySoundEffect(149); } //打开拖尾特效 if (null != ObjEffectController) { ObjEffectController.PlayEffect(GlobeVar.LIGHT_SKILL_TAIL); } } }
protected void UpdateLightSkill() { if (false == m_bIsLightState || m_LightSkillTargetPos == Vector3.zero) { return; } if (ObjTransform == null) { return; // 判空 } m_fMoveSpeed = BaseAttr.MoveSpeed; //如果在轻功过程中产生强制移动行为,则进行强制移动的Update,忽略轻功本身的路径 if (m_bTeleMoveInLight) { if (Vector3.Distance(m_vecLightTelePos, ObjTransform.position) <= 1.0f) { EndLightSkillMove(); m_bTeleMoveInLight = false; // 被击退情况结束了,置回来 } return; } //轻功结束 //if (Vector3.Distance(m_LightSkillTargetPos, ObjTransform.position) <= 2.0f) if (Vector2.Distance( new Vector2(m_LightSkillTargetPos.x, m_LightSkillTargetPos.z), new Vector2(ObjTransform.position.x, ObjTransform.position.z) ) <= 0.5f) { EndLightSkillMove(); } //进行高度修正,目前的轨迹是一条正弦曲线 if (m_fLightLastTime > 0.0f) { float timeElps = Time.time - m_fLightStartTime; if (timeElps <= m_fLightLastTime) { //float fAngle = (timeElps / m_fLightLastTime) * 3.1415f; //float fHeightRefix = Mathf.Cos(fAngle) * 0.1f; ////由于现在地表高度为精确高度,所以发现到达地面的时候则停止轻功 //if (fHeightRefix < 0.0f && ObjTransform.position.y < ActiveScene.GetTerrainPosition(ObjTransform.position).y) //{ // EndLightSkillMove(); //} ////if (ObjTransform.position.y + fHeightRefix < 8.0f) ////限制高度 //if (m_fTotalLightHightRefix >=3.0f && fHeightRefix>0) //{ // fHeightRefix = 0.0f; //} //else if (m_fTotalLightHightRefix < 1.0f && fHeightRefix < 0) //{ // fHeightRefix = 0.0f; //} //m_fTotalLightHightRefix += fHeightRefix; //ObjTransform.position = new Vector3(ObjTransform.position.x, ObjTransform.position.y + fHeightRefix, ObjTransform.position.z); if (m_fLightLastTime == 0) { m_fLightLastTime = 0.1f; // 判除零 } float fAngle = (timeElps / m_fLightLastTime) * 3.1415f; float fHeightRefix = Mathf.Sin(fAngle) * m_fLightWantHight; // 最高距离是3米 float old_offsety = m_fTotalLightHightRefix; m_fTotalLightHightRefix = fHeightRefix; float new_y = ObjTransform.position.y - old_offsety + m_fTotalLightHightRefix; // 当前位置,减去上次位置,加上这次位置 if (new_y < ActiveScene.GetTerrainPosition(ObjTransform.position).y) { // 如果算出来的位置小于地形高度,则是地形高度 new_y = ActiveScene.GetTerrainPosition(ObjTransform.position).y; } ObjTransform.position = new Vector3( ObjTransform.position.x, new_y, ObjTransform.position.z); } else { EndLightSkillMove(); } float fBeforeTime = 0.35f; if (ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_MAIN_PLAYER || ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER) { Obj_OtherPlayer _Player = this as Obj_OtherPlayer; if (_Player) { switch (_Player.Profession) { case (int)CharacterDefine.PROFESSION.SHAOLIN: fBeforeTime = 0.35f; break; case (int)CharacterDefine.PROFESSION.TIANSHAN: fBeforeTime = 0.35f; break; case (int)CharacterDefine.PROFESSION.XIAOYAO: fBeforeTime = 0.35f; break; case (int)CharacterDefine.PROFESSION.DALI: fBeforeTime = 0.35f; break; } } } if (AnimLogic != null && AnimLogic.CurAnimData != null) { // 判空 if (AnimLogic.CurAnimData.AnimID != (int)CharacterDefine.CharacterAnimId.LIGHTSKILLEND) { if (m_fLightLastTime - timeElps <= fBeforeTime || Vector3.Distance(m_LightSkillTargetPos, ObjTransform.position) <= 1.75f) { AnimLogic.Stop(); AnimLogic.Play((int)CharacterDefine.CharacterAnimId.LIGHTSKILLEND); } } } } //暂时屏蔽二段跳 //如果在轻功状态并且二段跳还未被激活,则判断是否可以进行二段跳跃 //if (!m_bIsLightSecondStepState && !m_bIsLightSecondStepActived) //{ // //激活二段跳(只能激活一次) // if (Vector3.Distance(m_LightSkillTargetPos, ObjTransform.position) <= 5.0f) // { // m_bIsLightSecondStepState = true; // m_bIsLightSecondStepActived = false; // } //} }