void Update()
    {
        if (hasAi && StageHandler.InStageBounds(transform.position))
        {
            if (!ai.inBounds)
            {
                ai.nextFire = Time.time;
                ai.inBounds = true;
            }
        }
        else
        {
            ai.inBounds = false;
        }

        if (hitOnFrame)
        {
            SFXHandler.PlaySound("enemyhit_loop", true);
            hitOnFrame = false;
        }
        else
        {
            SFXHandler.StopSound("enemyhit_loop");
        }
    }
Esempio n. 2
0
    void Update()
    {
        // Handle controls
        focus = Input.GetButton("Focus");
        focusHitbox.enabled = focus;
        Orb.radius          = focus ? .4f : .6f;

        shooting = Input.GetButton("Shoot");
        // Reset fire timer and play shooting sound
        if (Input.GetButtonDown("Shoot"))
        {
            SFXHandler.PlaySound("generic_shot", true);
            nextFire = Time.time;
        }
        if (Input.GetButtonUp("Shoot"))
        {
            SFXHandler.StopSound("generic_shot");
        }

        if (Input.GetButtonDown("Bomb"))
        {
            Bomb();
        }

        // Movement
        movement = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        movement.Normalize(); movement *= focus ? focusMovementSpeed : movementSpeed;

        // Animation
        if (paralyzed)
        {
            anim.SetFloat("Horizontal", 0);
            anim.SetBool("Moving", false);
        }
        else
        {
            anim.SetFloat("Horizontal", movement.x);
            anim.SetBool("Moving", movement.x != 0);
        }
    }