Exemple #1
0
 public void SetState(Type pState)
 {
     Debug.Log("Switching state to:" + pState.FullName);
     EnteredNewState = true;
     if (NavAgent.isOnNavMesh)
     {
         NavAgent.Stop();
     }
     SetSeeTarget();
     _state = _stateCache[pState];
 }
Exemple #2
0
 public void Update()
 {
     if (Target)
     {
         // Debug.Log((Target.transform.position - transform.position).magnitude);
         if ((Target.transform.position - transform.position).sqrMagnitude < 1f)
         {
             navAgent.Stop();
             Target.ShipOn(this);
             Target = null;
             if (Player.ship == this)
             {
                 Player.DeselectShip();
             }
         }
     }
 }
Exemple #3
0
        public void StopMove()
        {
            if (null != NavAgent && NavAgent.enabled == true)
            {
                NavAgent.Stop();
                //如果在moveto时 禁用了旋转 移动结束后 重新置为打开
                if (IsMoveToNoFaceTo)
                {
                    EnableMovingRotation(true);
                    IsMoveToNoFaceTo = false;
                }
            }

            if (ObjType == Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_MAIN_PLAYER)
            {
//                Obj_MainPlayer MainPlayer = this as Obj_MainPlayer;
                //if (MainPlayer.Thirdcontroller != null && MainPlayer.Thirdcontroller.IsMoving)
                //{
                //    CurObjAnimState = Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_WALK;
                //}
                //else
                //{
                CurObjAnimState = Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_NORMOR;
                //}
                //取消地面移动特效
                if (null != GameManager.gameManager.ActiveScene)
                {
                    GameManager.gameManager.ActiveScene.DeactiveMovingCircle();
                }
            }
            else
            {
#if UNITY_ANDROID
                if (ObjType != Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER)
                {
#endif
                CurObjAnimState = Games.GlobeDefine.GameDefine_Globe.OBJ_ANIMSTATE.STATE_NORMOR;

#if UNITY_ANDROID
            }
#endif
            }

            //正常结束处理
            bool isPlayerSound = m_bIsMoving;
            m_bIsMoving  = false;
            m_bIsTracing = false;
            float fDis = Vector3.Distance(this.Position, m_vecTargetPos);
            if (m_fStopRange - fDis >= 0)
            {
                OnMoveOver();
            }

            //   MoveTarget = null;
            ResetMoveOverEvent();

            //重置移动卡住校验
            m_LastPosition     = Vector3.zero;
            m_LastPositionTime = 0;

            Obj_MainPlayer MainPlayer1 = this as Obj_MainPlayer;
            if (MainPlayer1 != null)
            {
                if (isPlayerSound)
                {
                    MainPlayer1.PlayerStopMountSound();
                    MainPlayer1.PlayerMountStopMoveSound();
                }
            }
        }