Ejemplo n.º 1
0
    public void arrive(FlyingDoge theDoge)
    {
        theDoge.canMove = false;
        theDoge.reset();

        dogePool.Enqueue(theDoge.gameObject);
        dogeCount--;
    }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        Vector3 initPos = new Vector3(RightBound, upperBound, 0);

        for (int i = 0; i < dogeCountLimit; i++)
        {
            GameObject newBornDogeObject = Instantiate(doge, initPos, Quaternion.identity);
            FlyingDoge theDoge           = newBornDogeObject.GetComponent <FlyingDoge>();
            theDoge.generator = this;
            dogePool.Enqueue(newBornDogeObject);
        }

        StartCoroutine(generateDoge());
    }
Ejemplo n.º 3
0
    private IEnumerator generateDoge()
    {
        while (true)
        {
            // gen
            if (dogeCount < dogeCountLimit && Random.Range(0f, 1f) < prob)
            {
                FlyingDoge nextDoge = dogePool.Dequeue().GetComponent <FlyingDoge>();
                nextDoge.canMove = true;
                nextDoge.reset();
                nextDoge.startFly();

                dogeCount++;
            }

            yield return(new WaitForSeconds(coolDown));
        }
    }