Пример #1
0
    // Start is called before the first frame update

    /*void Start () {
     *  StartCoroutine (Shooter ());
     * } */

    IEnumerator Shooter()
    {
        while (enabled)
        {
            // wait until not paused
            yield return(new WaitUntil(() => !GameManager.instance.paused));

            // wait for frequency
            yield return(new WaitForSeconds(Random.Range(frequency.x, frequency.y)));

            // Cheating
            shootingEvent.Invoke(this);
            yield return(new WaitForSeconds(0.45f));

            // spawn
            GameObject debris = Instantiate(debrisPrefabs[Random.Range(0, debrisPrefabs.Length)], transform);
            debris.transform.position = transform.position;
            debris.transform.SetParent(null);
            EnemyDebris component = debris.GetComponent <EnemyDebris> ();
            component.force     = Random.Range(force.x, force.y);
            component.damage    = Random.Range(damage.x, damage.y);
            component.direction = direction;
            if (component.allowPooling && !debrisInStorage.Contains(component))
            {
                component.debrisHitEvent.AddListener(AddToStorage);
            }
            ;
        }
    }