Example #1
0
 public void fire()
 {
     if (!dead)
     {
         animator.SetTrigger("fire");
         soundmanager.play_sound(SoundManager.SoundType.EnemyShoot);
         nozzle.fire();
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (dead)
        {
            kill_timer--;
            if (kill_timer == 0)
            {
                GameObject.Destroy(gameObject);
            }

            return;
        }
        float x = Input.GetAxis("Horizontal");

        Vector3 new_pos = gameObject.transform.position;

        if (x < 0)
        {
            new_pos.x = Mathf.Max(new_pos.x - 1f, left_boundary);
        }
        else if (x > 0)
        {
            new_pos.x = Mathf.Min(new_pos.x + 1f, right_boundary);
        }

        gameObject.transform.position = new_pos;

        float z = Input.GetAxis("Fire1");

        if (z > 0 && !shooting)
        {
            bool fired = nozzle.fire();
            if (fired)
            {
                animator.SetTrigger("fire");
                shooting = true;
                soundmanager.play_sound(SoundManager.SoundType.PlayerShoot);
            }
        }
        else if (z == 0)
        {
            shooting = false;
        }
    }