Ejemplo n.º 1
0
    void shoot()
    {
        if (ammo.Count > 0)
        {
            //if (timer_hold >= duration_hold) {
            if (ammo[ammo.Count - 1] == "mega_ammo")
            {
                //mega ammo

                Ammunition a = Ammunition.Instantiate(megaAmmoPrefab);
                a.transform.SetParent(mainGame.Ammunitions.transform, false);
                a.transform.position = transform.position + (aim_direction).normalized * distance_aim;
                a.setDirection(aim_direction);
                a.setShot(true);
            }
            else if (ammo[ammo.Count - 1] == "ammo")
            {
                //regular ammo

                Ammunition a = Ammunition.Instantiate(ammoPrefab);
                a.transform.SetParent(mainGame.Ammunitions.transform, false);
                a.transform.position = transform.position + (aim_direction).normalized * distance_aim;
                a.setDirection(aim_direction);
                a.setShot(true);
            }

            is_shooting = true;
            anim_shoot.start();
            this.GetComponent <AudioSource>().Play();

            ammo.RemoveAt(ammo.Count - 1);

            timer_hold = 0;
            hold_blast = false;
        }
        else
        {
            //cannot shoot ! no ammo
        }
    }