private void SpawnPlatform(float xPosition) { var platformGameObject = PoolsManager.GetGameObjectsPool(EngineSettings.Platforms.PlatformsPoolTagName).Take(); platformGameObject.transform.position = new Vector3(xPosition, EngineSettings.Platforms.MinimumHeight, 0f); platformGameObject.GetComponent <Platform>().Activate(); }
private void OnGenerateNextPlatform() { var platformGameObject = PoolsManager.GetGameObjectsPool(EngineSettings.Platforms.PlatformsPoolTagName).Take(); var xRandomPosition = Random.Range(-EngineSettings.Platforms.MaxMinXPosition, EngineSettings.Platforms.MaxMinXPosition); platformGameObject.transform.position = new Vector3(xRandomPosition, 0f, lastSpawnZPosition); lastSpawnZPosition += EngineSettings.Platforms.SpawnEachZ; platformGameObject.transform.parent = transform; if (platforms.Count > EngineSettings.Platforms.SpawnRowsCount + 1) { var platformToReturn = platforms.Dequeue(); platformToReturn.GetComponent <Platforms.Platform>().DestroyPlatform(); } platforms.Enqueue(platformGameObject); platformGameObject.GetComponent <Platforms.Platform>().GenerateCrystal(); }
private void Awake() { instance = this; }