public override bool Act()
    {
        // if the player is moving
        if (ParentEntity.State == Enemy.EnemyState.PATROL)
        {
            // if the enemy has jumped and is in the air
            if (!ParentEntity.IsGrounded())
            {
                ParentEntity.Animator.SetBool("Jump", true);
                ParentEntity.Animator.SetBool("Run", false);
            }
            else
            {
                ParentEntity.Animator.SetBool("Run", true);
                ParentEntity.Animator.SetBool("Jump", false);
            }
        }
        // if the renegade is not moving
        else if (ParentEntity.State == Enemy.EnemyState.IDLE)
        {
            ParentEntity.Animator.SetBool("Run", false);
            ParentEntity.Animator.SetBool("Idle", true);
        }



        return(true);
    }
Beispiel #2
0
    /*
     *      Act
     *
     *      Returns: true: Any additional derived Act methods can be executed. False: the
     *              derived act methods should not be executed.
     *      Purpose: This is the main method where this behavior modifies its parent. This should
     *              be overridden for each base class, and the value of the super Act() methods needs to be
     *              true for the derived class to execute. This sets the appropriate animation based on
     *              the current enemy state.
     */
    public override bool Act()
    {
        // Swap direction of sprite depending on walk direction
        if (ParentEntity.Rigidbody2D.velocity.x < 0)
        {
            transform.localScale = new Vector3(10.0f, 10.0f, 10.0f);
        }
        else if (ParentEntity.Rigidbody2D.velocity.x > 0)
        {
            transform.localScale = new Vector3(-10.0f, 10.0f, 10.0f);
        }

        // if we are dead, do not change our animation as it has already been set
        if (dead)
        {
            return(false);
        }

        // set the animation as dead
        if (ParentEntity.State == Enemy.EnemyState.DEAD)
        {
            ParentEntity.Animator.SetTrigger("Death");
            dead = true;
            return(false);
        }
        // If we are not on the ground, and we have not already set our jump animation,
        // and we are not attacking
        else if (!ParentEntity.IsGrounded() &&
                 !jumped &&
                 !ParentEntity.Attacking)
        {
            ParentEntity.Animator.SetTrigger("Jump");
            ParentEntity.Animator.SetBool("Grounded", false);
            jumped = true;
            return(false);
        }
        // if we are attacking, we want this animation to play, so return
        else if (ParentEntity.Attacking)
        {
            return(false);
        }
        // if we are grounded, set it appropriately
        else if (ParentEntity.IsGrounded())
        {
            jumped = false;
            ParentEntity.Animator.SetBool("Grounded", true);
            return(false);
        }
        // if we are jumping and in the air, we want to keep the jump animation
        else if (!ParentEntity.IsGrounded())
        {
            return(false);
        }

        // Set the miscellaneous states
        switch (ParentEntity.State)
        {
        case Enemy.EnemyState.ATTACKING:
            ParentEntity.Animator.SetTrigger("Attack");
            break;

        case Enemy.EnemyState.COMBAT:
            break;

        case Enemy.EnemyState.DEAD:
            ParentEntity.Animator.SetTrigger("Death");
            break;

        case Enemy.EnemyState.IDLE:
            ParentEntity.Animator.SetInteger("AnimState", 0);
            break;

        case Enemy.EnemyState.PATROL:
            ParentEntity.Animator.SetInteger("AnimState", 2);
            break;

        default:
            break;
        }
        return(false);
    }