Beispiel #1
0
        GameObjectPool asteroidObjectPool; //Shouldn't be here... since it's already used in the AsteroidFactory...
        // maybe have a separate class responsible for the pool ?


        private void EnableLargeAsteroids(int ammount)
        {
            DisableAllAsteroids();
            for (int i = 0; i < ammount; i++)
            {
                GameObject asteroid = asteroidFactory.GetLargeAsteroid();
                asteroid.transform.position = ScreenSpaceUtility.GetRandomLocationInWorldSpace();
                asteroid.SetActive(true);
                AddForceInRandomDirectionRelativeToSize(asteroid.GetComponent <Rigidbody2D>());
            }
        }
Beispiel #2
0
        void SetRandomStartingLocation() //might wanna move it to ScreenSpaceUtility.cs ???
        {
            float randomVerticalLocation = Random.Range(halfWidth, Screen.height - halfWidth);

            bool leftside = (Random.value > 0.5f);

            if (leftside)
            {
                Vector3 leftScreenLocation = ScreenSpaceUtility.ConvertScreenSpaceToWorldSpace(halfWidth, randomVerticalLocation);
                transform.position = leftScreenLocation;
            }
            else
            {
                Vector3 rightScreenLodation = ScreenSpaceUtility.ConvertScreenSpaceToWorldSpace(Screen.width - halfWidth, randomVerticalLocation);
                transform.position = rightScreenLodation;
            }
        }
 private void TeleportToRandomLocation()
 {
     rigidBody.position = ScreenSpaceUtility.GetRandomLocationInWorldSpace();
 }