Пример #1
0
    public virtual void MoveTo(Vector3 target, float speed)
    {
        if (mFSM.CurRule == Monster_Die.GetInstance())
        {
            return;
        }

        mFSM.SetState(Monster_MoveTo.GetInstance());

        if (ReverseMove == true)
        {
            target.x = -target.x;
        }

        //targetPos = new Vector3(2.5f,1.5f,0);
        startPos  = new Vector3(transform.position.x, transform.position.y, 0);
        targetPos = new Vector3(target.x, target.y, 0);
        float dis = Vector3.Magnitude(startPos - targetPos);

        moveto_totalTime = dis / (speed + 0.1f);

        if (AlwaysUp == false)
        {
            transform.rotation = LookAtTarget(targetPos);
        }
        //
        Animator animator = GetComponent <Animator>();

        if (animator != null)
        {
            animator.SetBool("attack", false);
        }
        //
    }
Пример #2
0
 public static Monster_MoveTo GetInstance()
 {
     if (instance == null)
     {
         instance = new Monster_MoveTo();
     }
     return(instance);
 }