Exemplo n.º 1
0
 public static AnimatorPropertyName GetInstance()
 {
     if (instance == null)
     {
         instance = new AnimatorPropertyName();
     }
     return(instance);
 }
Exemplo n.º 2
0
 public void StopMoving()
 {
     if (isMoving)
     {
         animator.SetTrigger(AnimatorPropertyName.GetInstance().Movement2StopTrigger);
         animator.SetInteger(AnimatorPropertyName.GetInstance().BodyLevel, AnimatorBodyLevel.Stand);
         currentPathSegment = null;
         isMoving           = false;
     }
 }
Exemplo n.º 3
0
    private IEnumerator RepathForCurrentTarget(bool priorMove)
    {
        if (priorMove)
        {
            yield return(new WaitForSeconds(0.1F));
        }
        else
        {
            animator.SetInteger(AnimatorPropertyName.GetInstance().BodyLevel, AnimatorBodyLevel.Stand);
            animator.SetBool(AnimatorPropertyName.GetInstance().TeaseBTrigger, true);
            yield return(new WaitForSeconds(3));
        }

        MoveToTarget(targetPosition, finalDirection);
    }
Exemplo n.º 4
0
    void OnCollisionEnter(Collision collision)
    {
        if (IsMoving && collisionTime + collisionTimeInterval < Time.time && collision.collider.CompareTag("Player"))
        {
            collisionTime = Time.time;

            currentPathSegment = null;
            animator.SetTrigger(AnimatorPropertyName.GetInstance().Movement2StopTrigger);
            CharacterMovementController collisionMovementController = collision.transform.GetComponent <CharacterMovementController> ();
            if (collisionMovementController.IsMoving)
            {
                StartCoroutine(RepathForCurrentTarget(transform.GetInstanceID() > collision.transform.GetInstanceID()));
            }
            else
            {
                StartCoroutine(RepathForCurrentTarget(true));
            }
        }
    }
Exemplo n.º 5
0
    private void UpdateSegmentTargetAndDirection()
    {
        currentPathSegment = kittyPath.Next();

        // 调整角色方向
        _lookAtTarget.x = currentPathSegment.endPoint.x;
        _lookAtTarget.z = currentPathSegment.endPoint.z;
        _lookAtTarget.y = transform.position.y;
        transform.LookAt(_lookAtTarget);

        //设置角色动画参数
        if (PathSegmentThroughStyle.Directly == currentPathSegment.throughStyle)
        {
            animator.SetInteger(AnimatorPropertyName.GetInstance().BodyLevel, AnimatorBodyLevel.Trot);
        }
        else
        {
            jumpStateController.JumpToTarget(currentPathSegment.endPoint, currentPathSegment.throughStyle);
        }
    }
    void OnMouseDown()
    {
        Vector3 direction = transform.position - Camera.main.transform.position;

        if (direction.magnitude < maxInteractiveDistance)
        {
            if (animator.GetBool(AnimatorPropertyName.GetInstance().InteractiveMode))
            {
                behaviorTree.SendEvent(clickEventName);
            }
            else
            {
                if (Time.realtimeSinceStartup - clickTime < doubleClickInterval)
                {
                    Debug.Log("BehaviorTree Event: " + doubleClickEventName);
                    behaviorTree.SendEvent(doubleClickEventName);
                }
                else
                {
                    clickTime = Time.realtimeSinceStartup;
                }
            }
        }
    }