// +++ life cycle +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void Start()
 {
     NvpPipePool.INSTANCE = this;
     _pool = new Queue <GameObject>();
     if (_prefillPoolCount > 1)
     {
         PreparePool(_prefillPoolCount);
     }
 }
示例#2
0
    // +++ class methods ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    private void CheckPipeSpawnCondition()
    {
        _spawningTimer += Time.deltaTime;
        if (_spawningTimer > _spawningInterval)
        {
            _spawningTimer = 0;

            var pipe = NvpPipePool.GetPooledItem();
            var nextSpawnLocation = _spawnPositionCalculator.GetNextSpawnPosition();
            var nextGapSize       = _gapSizeGenerator.GetNextGap();

            pipe.transform.position = nextSpawnLocation;
            pipe.GetComponent <NvpPipeController>().SetGap(nextGapSize);
            pipe.gameObject.SetActive(true);
        }
    }