Beispiel #1
0
 // Start is called before the first frame update
 void Start()
 {
     controller = gameObject.GetComponent <TopDownPlayerController>();
     anim       = gameObject.GetComponent <Animator>();
     rb         = gameObject.GetComponent <SimpleRigidbody>();
     anim.SetFloat(DirectionXHash, rb.GetDirection().x);
     anim.SetFloat(DirectionYHash, rb.GetDirection().y);
 }
Beispiel #2
0
    private void PerformStateOperations()
    {
        switch (state)
        {
        case PlayerState.Idle:
            targetVelocity = Vector3.zero;

            break;

        case PlayerState.Walking:
            MovePlayer();

            break;

        case PlayerState.Knockback:
            knockbackTimer -= Time.deltaTime;
            isI_frame       = true;

            break;

        case PlayerState.Attacking:
            rb.SetVelocity(Vector2.zero);

            break;

        case PlayerState.Frozen:
            rb.SetVelocity(Vector2.zero);

            break;

        case PlayerState.RoomTransition:
            rb.SetVelocity(rb.GetDirection() * knockback * 0.3f);

            break;
        }
    }
Beispiel #3
0
 void Update()
 {
     anim.SetFloat(DirectionXHash, rb.GetDirection().x);
     anim.SetFloat(DirectionYHash, rb.GetDirection().y);
     UpdateAnimatorState();
 }
Beispiel #4
0
 void Attack()
 {
     controller.state = PlayerState.Attacking;
     anim.SetTrigger("Attack");
     PlayerAttack?.Invoke(this, new AttackEventArgs(rb.GetDirection(), attackEndLag));
 }