Ejemplo n.º 1
0
        void Start()
        {
#if UNITY_EDITOR
            var currentActiveScene = SceneManager.GetActiveScene();
            var cloudScene         = SceneManager.CreateScene("Clouds");
            SceneManager.SetActiveScene(cloudScene);
#endif
            clouds = new CloudData[numClouds];

            for (int i = 0; i < numClouds; i++)
            {
                Vector3 startPosition = Vector3.zero;
                startPosition.x = Random.Range(cloudBorders.xMin, cloudBorders.xMax);
                startPosition.y = Random.Range(cloudBorders.yMin, cloudBorders.yMax);
                var go             = Instantiate(cloudPrefab, startPosition, Quaternion.identity);
                var spriteRenderer = go.GetComponent <SpriteRenderer>();
                var cloudData      = new CloudData(go.transform, spriteRenderer);
                cloudData.SpriteRenderer.sprite = GetRandomSprite();
                cloudData.SpeedPerSecond        = cloudSpeed.GetRandomValue() * directionMultiplier;
                clouds[i] = cloudData;
            }
#if UNITY_EDITOR
            SceneManager.SetActiveScene(currentActiveScene);
#endif
        }
Ejemplo n.º 2
0
 private void CloudReachedEnd(CloudData cloudData)
 {
     cloudData.SpriteRenderer.sprite = GetRandomSprite();
     cloudData.SpeedPerSecond        = cloudSpeed.GetRandomValue() * directionMultiplier;
     cloudData.Position.x            = direction == Direction.LeftToRight ? cloudBorders.xMin : cloudBorders.xMax;
     cloudData.Position.y            = Random.Range(cloudBorders.yMin, cloudBorders.yMax);
 }