示例#1
0
    // Update is called once per frame
    void Update()
    {
        enemyAnimator.SetInteger("WalkingMode", VelocityToWalkingMode(enemyBrain.legs.GetEnemyVelocity()));
        enemyAnimator.SetBool("Equiped", enemyBrain.arms.GetWeaponOut());
        enemyAnimator.SetInteger("WeaponMode", (int)enemyBrain.arms.GetEquipedWeapon().weaponType);

        enemyAnimator.SetBool("Aim", enemyBrain.arms.IsAimingWithWeapon());

        //If we aim, do we shoot ?
        if (enemyBrain.arms.IsAimingWithWeapon())
        {
            //Shoot
            if (enemyBrain.arms.IsShootingWithWeapon())
            {
                Weapon.ShootOutput output = enemyBrain.arms.GetEquipedWeapon().GetShootOutput();
                switch (output)
                {
                //Shoot is valid, we do anim shoot !
                case Weapon.ShootOutput.VALID:
                    enemyAnimator.SetBool("Shoot", true);
                    enemyAnimator.SetTrigger("TriggerPulled");
                    break;

                //Oups, we need to reload, play reload animation
                case Weapon.ShootOutput.RELOAD:
                    enemyAnimator.SetBool("Shoot", false);
                    enemyAnimator.SetTrigger("Reload");
                    break;
                }
            }
            else
            {
                //We stop the shoot animation in case it's a loop (machine gun)
                enemyAnimator.SetBool("Shoot", false);
            }
        }

        if (lastCurrentLife != enemyHitbox.getCurrentLife() && enemyHitbox.getCurrentLife() > 0f)
        {
            enemyAnimator.SetTrigger("Hurt");
            lastCurrentLife = enemyHitbox.getCurrentLife();
        }
    }
示例#2
0
    public void UpdateShootBehavior()
    {
        Weapon.ShootOutput output = GetEquipedWeapon().Shoot();

        switch (output)
        {
        case Weapon.ShootOutput.VALID:
            SoundManager.instance.play(GetEquipedWeapon().shootSound, transform.position, SoundManager.AudioType.SOUND);
            break;

        case Weapon.ShootOutput.EMPTY:
            SoundManager.instance.play("EmptyAmmo", transform.position, SoundManager.AudioType.SOUND);
            break;

        case Weapon.ShootOutput.RELOAD:
            SoundManager.instance.play("Reload", transform.position, SoundManager.AudioType.SOUND);
            break;
        }
    }
示例#3
0
    public void Shoot()
    {
        Weapon.ShootOutput output = equipedWeapon.Shoot();

        switch (output)
        {
        case Weapon.ShootOutput.VALID:
            SoundManager.instance.play(equipedWeapon.shootSound, transform.position, SoundManager.AudioType.SOUND);
            break;

        case Weapon.ShootOutput.EMPTY:
            SoundManager.instance.play("EmptyAmmo", transform.position, SoundManager.AudioType.SOUND);
            break;

        case Weapon.ShootOutput.RELOAD:
            SoundManager.instance.play("Reload", transform.position, SoundManager.AudioType.SOUND);
            break;
        }

        isShooting = true;
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        playerAnimator.SetInteger("WalkingMode", VelocityToWalkingMode(playerBehaviour.GetPlayerVelocity()));
        playerAnimator.SetBool("Equiped", playerBehaviour.GetEquipedWeapon() != null);

        isCollidingWithWall = playerBehaviour.GetPlayerWallMovement() >= PlayerBehaviour.PlayerWallMovement.COLLIDE;
        playerAnimator.SetBool("AgainstAWall", isCollidingWithWall);
        if (isCollidingWithWall)
        {
            playerAnimator.SetBool("OrientedRight", playerBehaviour.isPlayerMovingRight());
            playerAnimator.SetBool("Look", playerBehaviour.GetPlayerWallMovement() == PlayerBehaviour.PlayerWallMovement.LOOK);
        }

        if (playerBehaviour.GetEquipedWeapon() != null)
        {
            playerAnimator.SetInteger("WeaponMode", (int)playerBehaviour.GetEquipedWeapon().weaponType);
            playerAnimator.SetBool("Aim", Input.GetButton("Aim"));

            //If we aim, do we shoot ?
            if (Input.GetButton("Aim"))
            {
                //Shoot
                if (Input.GetButtonDown("Shoot"))
                {
                    Weapon.ShootOutput output = playerBehaviour.GetEquipedWeapon().GetShootOutput();
                    switch (output)
                    {
                    //Shoot is valid, we do anim shoot !
                    case Weapon.ShootOutput.VALID:
                        playerAnimator.SetBool("Shoot", true);
                        playerAnimator.SetTrigger("TriggerPulled");
                        break;

                    //Oups, we need to reload, play reload animation
                    case Weapon.ShootOutput.RELOAD:
                        playerAnimator.SetBool("Shoot", false);
                        playerAnimator.SetTrigger("Reload");
                        break;
                    }
                }

                //We stop the shoot animation in case it's a loop (machine gun)
                if (Input.GetButtonUp("Shoot"))
                {
                    playerAnimator.SetBool("Shoot", false);
                }
            }
            else
            {
                //If we are not aiming but clic the shoot button, it reloads the weapon
                if (Input.GetButtonDown("Shoot") && playerBehaviour.GetEquipedWeapon().GetShootOutput() == Weapon.ShootOutput.RELOAD)
                {
                    playerAnimator.SetTrigger("Reload");
                }
            }
        }

        if (lastCurrentLife != playerHitbox.getCurrentLife() && playerHitbox.getCurrentLife() > 0f)
        {
            playerAnimator.SetTrigger("Hurt");
            lastCurrentLife = playerHitbox.getCurrentLife();
        }
    }