Пример #1
0
        private IEnumerator Routine(GenericPool pool)
        {
            var remainder = count; // Remaining number of Flake to place
            var state     = true;

            while (state)
            {
                var batch = Random.Range(spawnRange.x, spawnRange.y);
                remainder -= batch;

                if (remainder <= 0) // If going into zero or negative, break out of the loop after last execution
                {
                    remainder = 0;
                    batch    -= remainder; // Correct the negative value

                    state = false;
                }

                for (var i = 0; i < batch; i++)
                {
                    var flake = pool.CastSingle <Flake>(); // A GenericPool allows to directly cast an Object request
                    flake.transform.position = new Vector2(Random.Range(rect.xMin, rect.xMax), rect.yMax);
                }

                yield return(new WaitForSeconds(Random.Range(delayRange.x, delayRange.y))); // Random wait for next placed batch
            }

            routine = null;
        }
Пример #2
0
    private EntityInfo SetupInfoFor(InfoAnchor anchor, TileableBase source)
    {
        var instance = infoPool.CastSingle <EntityInfo>();

        instance.RectTransform.SetParent(infoParent);
        instance.AssignTo(anchor, source);

        return(instance);
    }