public uint Execute(PacketDistributed ipacket) { GC_TELEMOVE packet = (GC_TELEMOVE )ipacket; if (null == packet) { return((uint)PACKET_EXE.PACKET_EXE_ERROR); } //enter your logic Obj_Character _objChar = Singleton <ObjManager> .GetInstance().FindObjCharacterInScene(packet.ObjId); if (_objChar == null) { return((uint)PACKET_EXE.PACKET_EXE_CONTINUE); } Vector3 targetPos = new Vector3(packet.TargetPosX / 100.0f, 0, packet.TargetPosZ / 100.0f); targetPos = ActiveScene.GetTerrainPosition(targetPos); //如果_objChar为轻功状态,则打断轻功 if (_objChar.IsLightState) { //_objChar.EndLightSkillMove(); _objChar.BeginTeleMoveInLight(targetPos); } //是否需要改变朝向 if (packet.NeedChangeFaceto == 1) { _objChar.FaceTo(targetPos); } else { _objChar.IsMoveToNoFaceTo = true; } AutoMove autoMove = _objChar.AutoMoveComponent; if (autoMove != null) { autoMove.ResetAutoMove(); } //向目标点移动 _objChar.MoveTo(targetPos, null, 0); //是否需要播放附加动作 if (packet.HasAnimaId && _objChar.AnimLogic != null) { _objChar.AnimLogic.Stop(); _objChar.AnimLogic.Play(packet.AnimaId); //现在这里播放击退效果 todo临时的 _objChar.PlayEffect(121); } return((uint)PACKET_EXE.PACKET_EXE_CONTINUE); }
//private bool IsReachPoint(AutoMovePos pos) //{ // //先判断序列号 // if (pos.m_nPosSerial != m_nCurPosSerial) // { // return false; // } // Vector2 dstPos = new Vector2(pos.m_fDstPosX, pos.m_fDstPosZ); // Vector2 curPos = new Vector2(gameObject.transform.position.x, gameObject.transform.position.z); // if (Vector2.Distance(curPos, dstPos) < 0.5f) // { // return true; // } // return false; //} //到达当前点,删除当前点,向下一个点移动 // private void ReachPoint() // { // if (null == m_posList || m_posList.Count <= 0) // { // return; // } //#if UNITY_ANDROID // BeginMove(m_posList[0]); // 移除当前点 // m_posList.RemoveAt(0); //#else // 移除当前点 // m_posList.RemoveAt(0); // 判断剩余点 // if (m_posList.Count <= 0) // { // 已经无点,停止移动 // StopMove(); // } // else // { // BeginMove(m_posList[0]); // } //#endif // } //移动开始 private void BeginMove(AutoMovePos dstPos) { if (null == m_BindObj) { return; } //记录当前点序列号 m_nCurPosSerial = dstPos.m_nPosSerial; //开始移动 Vector3 dest = new Vector3(dstPos.m_fDstPosX, 0.0f, dstPos.m_fDstPosZ); dest = ActiveScene.GetTerrainPosition(dest); // m_bIsMove = true; m_BindObj.MoveTo(dest, null, 0.0f); }
//走向某一个路点 private int GotoPatrolPoint(int nPatrolIdx) { //越界判断 if (nPatrolIdx < 0 || m_patrolPoint.ListPatrolPoint.Count <= nPatrolIdx) { return(GlobeVar.INVALID_ID); } //检测是否是Obj类型 Obj_Character obj = this.gameObject.GetComponent <Obj_Character>(); if (obj) { m_nCurrentPatrolIdx = nPatrolIdx; Vector2 point2D = m_patrolPoint.ListPatrolPoint[nPatrolIdx]; Vector3 dest = new Vector3(point2D.x, 0, point2D.y); obj.MoveTo(dest, null, m_fStopDistance); return(nPatrolIdx); } return(GlobeVar.INVALID_ID); }