Beispiel #1
0
        public void SplitAsteroid(Asteroid parent, AsteroidType type)
        {
            Asteroid a = null, b = null;

            Vector2 v1 = new Vector2((float)Math.Sin(rand.Next() % 1000), (float)Math.Cos(rand.Next() % 1000));
            Vector2 v2 = new Vector2((float)Math.Sin(rand.Next() % 1000), (float)Math.Cos(rand.Next() % 1000));

            // Rotations
            float r1 = rand.Next(0, 359);
            float r2 = rand.Next(0, 359);

            // Rotation Speed
            float s1 = ((float)Math.Sin(rand.Next(0, 1000))) * 0.05f;
            float s2 = ((float)Math.Sin(rand.Next(0, 1000))) * 0.05f;

            if (type == AsteroidType.MEDIUM)
            {
                a = new Asteroid(currentId++, AsteroidType.MEDIUM, texture_medium, parent.Position, v1, r1, s1);
                b = new Asteroid(currentId++, AsteroidType.MEDIUM, texture_medium, parent.Position, v2, r2, s2);
            }
            else if (type == AsteroidType.SMALL)
            {
                a = new Asteroid(currentId++, AsteroidType.SMALL, texture_small, parent.Position, v1, r1, s1);
                b = new Asteroid(currentId++, AsteroidType.SMALL, texture_small, parent.Position, v2, r2, s2);
            }
            asteroids.Add(a);
            asteroids.Add(b);
        }
Beispiel #2
0
    public Asteroid GetUnusedAsteroid(AsteroidType type)
    {
        Asteroid asteroid = null;

        for (int i = 0; i < asteroids.Count; i++)
        {
            if (!asteroids [i].gameObject.activeInHierarchy && asteroids [i].type == type)
            {
                asteroid = asteroids [i];
                break;
            }
        }

        if (asteroid == null)
        {
            switch (type)
            {
            case AsteroidType.Asteroid:
                asteroid = Instantiate(asteroidPrefab, transform);
                break;

            case AsteroidType.SuperAsteroid:
                asteroid = Instantiate(superAsteroidPrefab, transform);
                break;
            }
            asteroid.gameObject.SetActive(false);
            asteroids.Add(asteroid);
        }

        return(asteroid);
    }
Beispiel #3
0
 //Set up new set of new Asteroids
 static public void    SpawnNew(Vector2 vPositon, int vCount, AsteroidType vType)
 {
     for (int i = 0; i < vCount; i++)
     {
         Instantiate(GM.sGM.Asteroids [(int)vType], vPositon, Quaternion.identity);
     }
 }
        private Asteroid CreateNewAsteroid(AsteroidType asteroidType)
        {
            Asteroid asteroid;

            switch (asteroidType)
            {
            case AsteroidType.GOLDEN:
                asteroid = new Asteroid(this, -1);
                break;

            case AsteroidType.NORMAL:
                asteroid = new Asteroid(this, -1);
                break;

            case AsteroidType.SPAWNED:
                asteroid = new MinorAsteroid(this, -1);
                break;

            case AsteroidType.UNSTABLE:
                asteroid = new UnstableAsteroid(this, -1);
                break;

            default:
                asteroid = new Asteroid(this, -1);
                break;
            }

            asteroid.AsteroidType = asteroidType;
            return(asteroid);
        }
Beispiel #5
0
        public void CreateDebris(AsteroidType t, PowerupType p)
        {
            GameObject debris;
            if (t == AsteroidType.Medium)
            {
                if (p == PowerupType.Blue)
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidMediumBlue_Prefab);
                else if (p == PowerupType.Green)
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidMediumGreen_Prefab);
                else
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidMedium_Prefab);
            }
            else
            {
                if (p == PowerupType.Blue)
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidSmallBlue_Prefab);
                else if (p == PowerupType.Green)
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidSmallGreen_Prefab);
                else
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidSmall_Prefab);
            }
            debris.Transform.Pos = this.GameObj.Transform.Pos;
            debris.Transform.Vel += this.GameObj.Transform.Vel;

            Scene.Current.RegisterObj(debris);
        }
Beispiel #6
0
 public AsteroidDestroyedPayload(AsteroidType asteroidType, Vector2 pos, IAsteroid asteroid)
 {
     EventName    = GameConsts.AsteroidDestroyed;
     AsteroidType = asteroidType;
     Pos          = pos;
     Asteroid     = asteroid;
 }
Beispiel #7
0
    private void CreateAsteroid(float x, float z)
    {
        position = new Vector3(x, 0, z);
        Quaternion rot = new Quaternion(0, 0, 0, 0);
        //Instantiate an asteroid at set position in 3D space
        int rand = Random.Range(1, 6);

        if (rand == 1)
        {
            instantiatedAsteroid = Instantiate(Asteroid_Grey, position, rot) as Rigidbody;
            asteroidType         = AsteroidType.Grey;
        }
        if (rand == 2)
        {
            instantiatedAsteroid = Instantiate(Asteroid_Blue, position, rot) as Rigidbody;
            asteroidType         = AsteroidType.Blue;
        }
        if (rand == 3)
        {
            instantiatedAsteroid = Instantiate(Asteroid_Green, position, rot) as Rigidbody;
            asteroidType         = AsteroidType.Green;
        }
        if (rand == 4)
        {
            instantiatedAsteroid = Instantiate(Asteroid_Brown, position, rot) as Rigidbody;
            asteroidType         = AsteroidType.Brown;
        }
        if (rand == 5)
        {
            instantiatedAsteroid = Instantiate(Asteroid_Red, position, rot) as Rigidbody;
            asteroidType         = AsteroidType.Red;
        }
    }
        public GameObject GenerateAsteroid(AsteroidType type)
        {
            GameObject result = null;

            if (type == AsteroidType.Small)
            {
                PowerupType p = Player.Instance != null?Player.Instance.PickValidPowerup(PowerupType.Random) : PowerupType.None;

                result = new GameObject(p == PowerupType.Blue ? GameRes.Data.Prefabs.AsteroidSmallBlue_Prefab : GameRes.Data.Prefabs.AsteroidSmall_Prefab);
            }
            else if (type == AsteroidType.Medium)
            {
                PowerupType p = Player.Instance != null?Player.Instance.PickValidPowerup(PowerupType.Random) : PowerupType.None;

                result = new GameObject(p == PowerupType.Blue ? GameRes.Data.Prefabs.AsteroidMediumBlue_Prefab : GameRes.Data.Prefabs.AsteroidMedium_Prefab);
            }
            else if (type == AsteroidType.Big)
            {
                int rnd = MathF.Rnd.Next(3);
                result = new GameObject(rnd == 0 ? GameRes.Data.Prefabs.AsteroidBig1_Prefab : (rnd == 1 ? GameRes.Data.Prefabs.AsteroidBig2_Prefab : GameRes.Data.Prefabs.AsteroidBig3_Prefab));
            }

            result.Transform.Pos = this.FindValidAsteroidPos(250);
            Scene.Current.RegisterObj(result);
            return(result);
        }
    public void OnAsteriodDead(AsteroidType asteroidtype, Transform damgedTransform)
    {
        switch (asteroidtype)
        {
        case AsteroidType.Big:
            return;

        case AsteroidType.Medium:
            for (int i = 0; i < 2; i++)
            {
                var ast = Instantiate(asteroidPrefabs[0]);
                ast.transform.position = damgedTransform.position;
                spwandAsteroids.Add(ast);
            }
            break;

        case AsteroidType.Small:
            for (int i = 0; i < 2; i++)
            {
                var ast = Instantiate(asteroidPrefabs[1]);
                ast.transform.position = damgedTransform.position;
                spwandAsteroids.Add(ast);
            }
            break;
        }
    }
Beispiel #10
0
 private void CreateAsteroid(float x, float z)
 {
     position = new Vector3(x, 0, z);
     Quaternion rot = new Quaternion(0, 0, 0, 0);
     //Instantiate an asteroid at set position in 3D space
     int rand = Random.Range(1,6);
     if ( rand == 1){
         instantiatedAsteroid = Instantiate(Asteroid_Grey, position, rot) as Rigidbody;
         asteroidType = AsteroidType.Grey;
     }
     if ( rand == 2){
         instantiatedAsteroid = Instantiate(Asteroid_Blue, position, rot) as Rigidbody;
         asteroidType = AsteroidType.Blue;
     }
     if (rand == 3){
         instantiatedAsteroid = Instantiate(Asteroid_Green, position, rot) as Rigidbody;
         asteroidType = AsteroidType.Green;
     }
     if (rand == 4){
         instantiatedAsteroid = Instantiate(Asteroid_Brown, position, rot) as Rigidbody;
         asteroidType = AsteroidType.Brown;
     }
     if (rand == 5){
         instantiatedAsteroid = Instantiate(Asteroid_Red, position, rot) as Rigidbody;
         asteroidType = AsteroidType.Red;
     }
 }
Beispiel #11
0
    public void SpawnAsteroid(AsteroidType type, Vector3 spawnPosition, Vector3 direction)
    {
        Asteroid asteroidToSpawn = null;

        switch (type)
        {
        case AsteroidType.small:
            asteroidToSpawn = m_GameParameters.smallAsteroid;
            break;

        case AsteroidType.medium:
            asteroidToSpawn = m_GameParameters.mediumAsteroid;
            m_NumberOfSpawnedAsteroids++;
            break;

        case AsteroidType.big:
            asteroidToSpawn = m_GameParameters.bigAsteroid;
            m_NumberOfSpawnedAsteroids++;
            break;

        default:
            break;
        }

        Asteroid asteroid = Instantiate(asteroidToSpawn, spawnPosition, Quaternion.identity);

        asteroid.transform.SetParent(m_GameParameters.asteroidSpawnParent); // Avois the hierarchy to be filled with asteroids gameObjects
        asteroid.SetAcceleration(direction * asteroid.EntityParameters.accelerationScalar);
        asteroid.ApplyForces(false);

        asteroid.AsteroidType = type;

        m_Asteroids.Add(asteroid); // Add to the list of asteroids
    }
Beispiel #12
0
		void UpdateProperties ()
		{
			AsteroidType = (AsteroidType)Type;
			_speed = Speed;
			_rotateClockWise = (ClockwiseRotation == 0) ? true : false;
			_pathLength = PathLength;
		}
Beispiel #13
0
        private void SpawnAsteroid(AsteroidType asteroidType, Vector2 spawnPos)
        {
            var asteroid = asteroidPool.Get(asteroidType);

            asteroids.Add(asteroid);
            asteroid.SetPosition(spawnPos);
            asteroid.ThrowAsteroid();
        }
Beispiel #14
0
 public Level(int levelIndex, int seed)
 {
     Seed = seed;
     Random.InitState(Seed);
     ObstacleCount = levelIndex + Random.Range(5, 10);
     ObstacleType  = (AsteroidType)Random.Range(1, 3);
     SpawnPause    = Random.Range(1.0f, 2.0f);
 }
Beispiel #15
0
 public AsteroidData(AsteroidType type, int score, float speed, AsteroidType destroyToType, int destroyToCount)
 {
     Type           = type;
     Score          = score;
     Speed          = speed;
     DestroyToType  = destroyToType;
     DestroyToCount = destroyToCount;
 }
Beispiel #16
0
    public void Configure(AsteroidType asteroidType)
    {
        GetComponent <Rigidbody2D>().velocity =
            Vector2.down * Random.Range(asteroidType.MinSpeed, asteroidType.MaxSpeed);

        _spriteRenderer.sprite = asteroidType.Sprite;
        _points     = asteroidType.Points;
        _durability = asteroidType.Durability;
    }
    void Start()
    {
        type = AsteroidType.Standard;

        pointsForAvoiding = 1;
        pointsForDestroying = 10;
        pointsForColliding = -1;

        rotateAmount = Random.Range(-1f, 1f);
    }
Beispiel #18
0
        public Asteroid(CollidableType type, float boundingRadius, AsteroidType asteroidType, Vector3 position, float rotationSpeed)
        {
            Position = position;
            AsteroidType = asteroidType;
            Rotation = Quaternion.Identity;
            _rotationSpeed = rotationSpeed;
            World = Matrix.CreateTranslation(position);

            this.CollidableType = type;
            this.BoundingSphereRadius = boundingRadius;
        }
Beispiel #19
0
    private AsteroidView CreateAsteroidView(AsteroidType type, Vector3 position)
    {
        var asteroid = new GameObject(type.ToString() + "Asteroid");

        asteroid.transform.position = position + new Vector3(0, 1, 0);
        asteroid.layer = 9;
        asteroid.transform.localScale = new Vector3(4, 4, 1);
        asteroid.AddComponent <SpriteRenderer>().sprite   = Resources.Load <Sprite>("Meteors/meteorBrown_" + type.ToString() + Random.Range(1, 3).ToString());
        asteroid.AddComponent <BoxCollider2D>().isTrigger = true;
        asteroid.AddComponent <Rigidbody2D>().bodyType    = RigidbodyType2D.Kinematic;
        return(asteroid.AddComponent <AsteroidView>());
    }
        public AsteroidSettings GetAsteroidSettings(AsteroidType type)
        {
            var settings = AsteroidsSettings.Find(s => s.Type == type);

            if (settings != null)
            {
                return(settings);
            }

            Debug.LogError(string.Format("Failed to find AsteroidSettings of type: {0}", type));
            return(null);
        }
Beispiel #21
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (!isAlive)
        {
            return;
        }

        int force = 0;

        if (collider.tag == "Laser")
        {
            force = 1;
        }

        else if (collider.tag == "Rocket")
        {
            RocketControl rc = collider.GetComponent <RocketControl>();

            if (rc != null)
            {
                rc.Boom();
            }

            force = 3;
        }

        if (force > 0)
        {
            type = (AsteroidType)Mathf.Max((float)type - force, 0);

            if (type == AsteroidType.DESTROYED)
            {
                asteroidsCount--;
                destroyParticles.Emit(30);
                boomParticles.Emit(10);
                Destroy(this.gameObject, 0.375f);
                isAlive = false;
                SoundManager.playSound(SoundManager.Sound.ASTEROID_DESTROY);
                OnDestroy();
            }
            else
            {
                boomParticles.Emit(30);
                SoundManager.playSound(SoundManager.Sound.ASTEROID_HIT);
            }

            animator.SetTrigger("boom");
        }

        setupByType();
    }
Beispiel #22
0
        public Asteroid(Game game, AsteroidType asteroidType, Vector3 position)
            : base(game, new BasicEffectShape(game, BasicEffectShapes.Asteroid, (int)asteroidType, LightingType.InGame), position)
        {
            //Random spin increments on all 3 axis
            rollIncrement = (float)random.NextDouble() - .5f;
            pitchIncrement = (float)random.NextDouble() - .5f;
            yawIncrement = (float)random.NextDouble() - .5f;

            if (asteroidType == AsteroidType.Large)
                Radius = 15;

            if (asteroidType == AsteroidType.Small)
                Radius = 6;
        }
Beispiel #23
0
        public Asteroid(int id, AsteroidType type, Texture2D texture, Vector2 position, Vector2 velocity, float rotation, float rotationSpeed)
        {
            Random rand = new Random();

            this.isActive = true;

            //this.guid     = Guid.NewGuid();
            this.id            = id;
            this.type          = type;
            this.texture       = texture;
            this.position      = position;
            this.velocity      = velocity;
            this.origin        = new Vector2(texture.Width / 2, texture.Height / 2);
            this.rotation      = rotation;
            this.rotationSpeed = rotationSpeed;
        }
Beispiel #24
0
 public void NotifyAsteroidDestroyed(AsteroidType type)
 {
     if (_hasActiveQuest)
     {
         if (!_currentQuestInfo.complexQuest && (_currentQuestInfo.asteroidType == type || _currentQuestInfo.asteroidType == AsteroidType.ANY_TYPE))
         {
             --_countDownAsteroid;
             if (_countDownAsteroid == 0)
             {
                 _hasActiveQuest = false;
                 GameLogic.Instance.QuestCompleted(_currentQuestInfo);
                 GameLogic.Instance.PlayUISound(questSuccessSound);
                 UnlockNextQuest(_currentQuestInfo);
             }
         }
     }
 }
        public Asteroid(Game game, AsteroidType asteroidType, Vector3 position)
            : base(game, new BasicEffectShape(game, BasicEffectShapes.Asteroid, (int)asteroidType, LightingType.InGame), position)
        {
            //Random spin increments on all 3 axis
            rollIncrement  = (float)random.NextDouble() - .5f;
            pitchIncrement = (float)random.NextDouble() - .5f;
            yawIncrement   = (float)random.NextDouble() - .5f;

            if (asteroidType == AsteroidType.Large)
            {
                Radius = 15;
            }

            if (asteroidType == AsteroidType.Small)
            {
                Radius = 6;
            }
        }
Beispiel #26
0
        private void UpdateGameData()
        {
            if (packetReader == null)
            {
                throw new ArgumentNullException("packetReader");
            }

            int numberAsteroids = packetReader.ReadInt32();

            // Remove all the asteroids
            asteroidManager.Asteroids.Clear();

            for (int i = 0; i < numberAsteroids; i++)
            {
                int          id    = packetReader.ReadInt32();
                AsteroidType pType = (AsteroidType)packetReader.ReadInt32();

                asteroidManager.AddAsteroid(pType, packetReader.ReadVector2(), packetReader.ReadVector2(), 0, 0);
            }
        }
Beispiel #27
0
    private void InitializeGameManager()
    {
        lvl            = LvlManager.currentLvl;
        playerProgress = PlayerPrefs.GetInt("PlayerProgress", 0);
        switch (lvl)
        {
        case 0:
            asteroidType = AsteroidType.big;
            break;

        case 1:
            asteroidType = AsteroidType.medium;
            break;

        case 2:
            asteroidType = AsteroidType.small;
            break;

        default:
            asteroidType = AsteroidType.small;
            break;
        }
        points      = new ReactiveProperty <int>(0);
        ssPresenter = new GameObject("SpaceshipPresenter").AddComponent <SpaceshipPresenter>();
        scPresenter = new GameObject("ScorePresenter").AddComponent <ScorePresenter>();
        scPresenter.SubscribeToManager(this);
        bulletPull   = new GameObject("BulletPull").AddComponent <BulletPullPresenter>();
        asteroidPull = new GameObject("AsteroidPull").AddComponent <AsteroidPullPresenter>();
        asteroidPull.asteroidType = this.asteroidType;
        MessageBroker.Default
        .Receive <ScoringNotice>()
        .Subscribe(_ => {
            points.Value += (int)asteroidType;
            if (points.Value >= pointsToWin)
            {
                GameOver(true);
            }
        })
        .AddTo(this);
        StartGame();
    }
Beispiel #28
0
        private Asteroid GetAsteroidByType(AsteroidType asteroidType, bool moveToObjectPoolScene)
        {
            Asteroid asteroidObject;

            switch (asteroidType)
            {
            case AsteroidType.Big:
                asteroidObject = CreateGameObjectInstance(asteroidPrefabsBig[Random.Range(0, TotalBigPrefabs)], moveToObjectPoolScene);
                break;

            case AsteroidType.Small:
                asteroidObject = CreateGameObjectInstance(asteroidPrefabsSmall[Random.Range(0, TotalSmallPrefabs)], moveToObjectPoolScene);
                break;

            default:
                asteroidObject = CreateGameObjectInstance(asteroidPrefabsBig[Random.Range(0, TotalBigPrefabs)], moveToObjectPoolScene);
                break;
            }

            return(asteroidObject);
        }
Beispiel #29
0
 /// <summary>
 /// Allows the game to run logic such as updating the world,
 /// checking for collisions, gathering input, and playing audio.
 /// </summary>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 public void Update(int width, int height)
 {
     if (smallAsteroid)
     {
         currentAsteroid = AsteroidType.Small;
     }
     if (medAsteroid)
     {
         currentAsteroid = AsteroidType.Medium;
     }
     if (bigAsteroid)
     {
         currentAsteroid = AsteroidType.Big;
     }
     if (alive)
     {
         turnRate += 0.05f;
         position += new Vector2(speedX, speedY);
         BoundryChecking(width, height, texture);
     }
 }
        public static Asteroid Generate(Vector3 position, AsteroidType type, Transform parent)
        {
            var asteroidObj = GameObject.Instantiate(
                type.asteroidPrefab,
                position,
                Random.rotation,
                parent
                );

            var asteroid = asteroidObj.GetComponent <Asteroid>();

            asteroid.radius        = Random.Range(type.MinRadius, type.MaxRadius);
            asteroid.material      = Rnd.Pick(type.Materials);
            asteroid.density       = type.Density;
            asteroid.seed          = (int)Random.Range(0, 65535);
            asteroid.rotationSpeed = Random.Range(0.01f, 0.5f);

            asteroid.Init();

            return(asteroid);
        }
Beispiel #31
0
        public void CreateDebris(AsteroidType t, PowerupType p)
        {
            GameObject debris;

            if (t == AsteroidType.Medium)
            {
                if (p == PowerupType.Blue)
                {
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidMediumBlue_Prefab);
                }
                else if (p == PowerupType.Green)
                {
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidMediumGreen_Prefab);
                }
                else
                {
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidMedium_Prefab);
                }
            }
            else
            {
                if (p == PowerupType.Blue)
                {
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidSmallBlue_Prefab);
                }
                else if (p == PowerupType.Green)
                {
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidSmallGreen_Prefab);
                }
                else
                {
                    debris = new GameObject(GameRes.Data.Prefabs.AsteroidSmall_Prefab);
                }
            }
            debris.Transform.Pos  = this.GameObj.Transform.Pos;
            debris.Transform.Vel += this.GameObj.Transform.Vel;

            Scene.Current.RegisterObj(debris);
        }
Beispiel #32
0
    Asteroid SpawnAsteroid(AsteroidType asteroidType, Vector2 vector, bool randomVelocity)
    {
        Asteroid asteroid;
        Vector3  vector3 = vector;
        Vector2  velocity;

        asteroid = Instantiate(asteroidPrefabs[asteroidType], vector3, Quaternion.identity);
        asteroid.gameObject.SetActive(true);
        asteroid.transform.SetParent(transform);

        if (randomVelocity)
        {
            velocity = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)) * GameArea.AsteroidTypeData[asteroidType].Speed;
        }
        else
        {
            velocity = Vector2.one * GameArea.AsteroidTypeData[asteroidType].Speed;
        }

        asteroid.GetComponent <Rigidbody2D>().velocity = velocity;
        return(asteroid);
    }
Beispiel #33
0
        private static AsteroidType GetAsteroidType()
        {
            AsteroidType type = AsteroidType.Stone;

            int t = Utility.RandomNumber(0, 2);

            switch (t)
            {
            case 0:
                type = AsteroidType.Ice;
                break;

            case 1:
                type = AsteroidType.Metal;
                break;

            case 2:
                type = AsteroidType.Stone;
                break;
            }
            return(type);
        }
Beispiel #34
0
    public void Start()
    {
        type = (AsteroidType)Mathf.Floor(Random.value * 3 + 1);

        animator = GetComponent <Animator>();

        setupByType();

        Rigidbody2D rigidbody             = GetComponent <Rigidbody2D>();
        float       randomAngularVelocity = 15.0f + Random.value * 15.0f;

        randomAngularVelocity    *= Random.value > 0.5f ? 1.0f : -1.0f;
        rigidbody.angularVelocity = randomAngularVelocity;

        Vector3 randomVelocity = new Vector3(0.0f, Random.value, 0.0f);

        randomVelocity.x   = Mathf.Sqrt(1.0f - randomVelocity.y * randomVelocity.y);
        randomVelocity.x  *= Random.value > 0.5f ? 1.0f : -1.0f;
        randomVelocity.y  *= Random.value > 0.5f ? 1.0f : -1.0f;
        randomVelocity    *= 0.2f + Random.value * 0.5f;
        rigidbody.velocity = randomVelocity;
    }
Beispiel #35
0
        public Asteroid(AsteroidType type)
        {
            switch (type)
            {
            case AsteroidType.Tiny:
                this.diameter = 10;
                break;

            case AsteroidType.Small:
                this.diameter = 50;
                break;

            case AsteroidType.Medium:
                this.diameter = 100;
                break;

            case AsteroidType.Big:
                this.diameter = 250;
                break;

            case AsteroidType.Large:
                this.diameter = 500;
                break;

            case AsteroidType.Huge:
                this.diameter = 1000;
                break;

            case AsteroidType.Immense:
                this.diameter = 5000;
                break;

            default:
                this.diameter = 100;
                break;
            }
            Collider = new CircleCollider(this, this.diameter / 2);
        }
Beispiel #36
0
        public Asteroid Get(AsteroidType asteroidType)
        {
            Asteroid asteroidObject;
            int      index = (int)asteroidType;

            if (recycle)
            {
                if (pools == null || !SceneManager.GetSceneByName(name).isLoaded)
                {
                    CreatePools();
                }

                int lastIndex = pools[index].Count - 1;
                if (lastIndex < 0)
                {
                    asteroidObject = GetAsteroidByType(asteroidType, true);
                    asteroidObject.Init();
                    asteroidObject.OriginPool = this;
                }
                else
                {
                    asteroidObject = pools[index][lastIndex];
                    asteroidObject.GameObject.SetActive(true);
                    asteroidObject.ResetState();
                    pools[index].RemoveAt(lastIndex);
                }
            }
            else
            {
                asteroidObject = GetAsteroidByType(asteroidType, false);
                asteroidObject.Init();
                asteroidObject.OriginPool = this;
            }

            return(asteroidObject);
        }
		public GameObject GenerateAsteroid(AsteroidType type)
		{
			GameObject result = null;

			if (type == AsteroidType.Small)
			{
				PowerupType p = Player.Instance != null ? Player.Instance.PickValidPowerup(PowerupType.Random) : PowerupType.None;
				result = new GameObject(p == PowerupType.Blue ? GameRes.Data.Prefabs.AsteroidSmallBlue_Prefab : GameRes.Data.Prefabs.AsteroidSmall_Prefab);
			}
			else if (type == AsteroidType.Medium)
			{
				PowerupType p = Player.Instance != null ? Player.Instance.PickValidPowerup(PowerupType.Random) : PowerupType.None;
				result = new GameObject(p == PowerupType.Blue ? GameRes.Data.Prefabs.AsteroidMediumBlue_Prefab : GameRes.Data.Prefabs.AsteroidMedium_Prefab);
			}
			else if (type == AsteroidType.Big)
			{
				int rnd = MathF.Rnd.Next(3);
				result = new GameObject(rnd == 0 ? GameRes.Data.Prefabs.AsteroidBig1_Prefab : (rnd == 1 ? GameRes.Data.Prefabs.AsteroidBig2_Prefab : GameRes.Data.Prefabs.AsteroidBig3_Prefab));
			}

			result.Transform.Pos = this.FindValidAsteroidPos(250);
			Scene.Current.RegisterObj(result);
			return result;
		}
Beispiel #38
0
 public void SetUpLevel(AsteroidType[] types, int asteroidPoints, Random r)
 {
     Asteroids.Clear(); //Just to make sure it's really empty
     int width = _gameMain.LevelSize.X;
     int height = _gameMain.LevelSize.Y;
     _astCells = new AstCell[width / GameMain.CELL_SIZE][];
     for (int i = 0; i < _astCells.Length; i++)
     {
         _astCells[i] = new AstCell[height / GameMain.CELL_SIZE];
         for (int j = 0; j < _astCells[i].Length; j++)
         {
             _astCells[i][j] = new AstCell();
             _astCells[i][j].PlayerIsOwedMoney += _gameMain.PayPlayer;
         }
     }
     while (asteroidPoints > 0)
     {
         var type = types[r.Next(types.Length)];
         Asteroid newAst = new Asteroid(type, width, height, r);
         Asteroids.Add(newAst);
         asteroidPoints -= newAst.Point;
     }
 }
Beispiel #39
0
 //This funtions is called whenever we want to Instantiate a smaller asteroid when a larger asteroid is destroyed.
 //It takes three arguments 1)The asteroid Type 2)its size
 void InstantiateAsteroid(AsteroidType AsType, AsteroidSize AsSize)
 {
     ///<summary>
     /// What you are doing here is that you are basically checking is there any collider2D within the radius calculated as the maximum of the
     /// (x,y) of the collider attached to the current gameObject(asteroid) + some arbitrary value. Around the point of the current
     /// random position generated above i.e pos. So if there is no Colider2D in this radius that means we have an empty spot where we can
     /// succesfully spawn a asteroid prefab.
     /// </summary>
     float arbValue = (AsSize == AsteroidSize.HUGE || AsSize == AsteroidSize.MEDIUM) ? 0.5F : 0.3F;
     if (!Physics2D.OverlapCircle (new Vector2 (pos.x, pos.y), Mathf.Max (gameObject.GetComponent<Collider2D> ().bounds.size.x, gameObject.GetComponent<Collider2D> ().bounds.size.y) + arbValue)) {
         //If the asteroid type to which it is attached to is of brown type
         if (AsType == AsteroidType.BROWN) {
             //If the asteroid size is HUGE
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.brownMedium [Random.Range (0, astList.brownMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.brownSmall [Random.Range (0, astList.brownSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.brownTiny [Random.Range (0, astList.brownTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         } else if (AsType == AsteroidType.GREY) {
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.greyMedium [Random.Range (0, astList.greyMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.greySmall [Random.Range (0, astList.greySmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.greyTiny [Random.Range (0, astList.greyTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         } else if (AsType == AsteroidType.FERROUS) {
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.ferrousMedium [Random.Range (0, astList.ferrousMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.ferrousSmall [Random.Range (0, astList.ferrousSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.ferrousTiny [Random.Range (0, astList.ferrousTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         } else if (AsType == AsteroidType.TIN) {
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.tinMedium [Random.Range (0, astList.tinMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.tinSmall [Random.Range (0, astList.tinSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.tinTiny [Random.Range (0, astList.tinTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         } else if (AsType == AsteroidType.COBALT) {
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.cobaltMedium [Random.Range (0, astList.cobaltMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.cobaltSmall [Random.Range (0, astList.cobaltSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.cobaltTiny [Random.Range (0, astList.cobaltTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         } else if (AsType == AsteroidType.INDIUM) {
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.indiumMedium [Random.Range (0, astList.indiumMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.indiumSmall [Random.Range (0, astList.indiumSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.indiumTiny [Random.Range (0, astList.indiumTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         } else if (AsType == AsteroidType.GOLD) {
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.goldMedium [Random.Range (0, astList.goldMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.goldSmall [Random.Range (0, astList.goldSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.goldTiny [Random.Range (0, astList.goldTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         } else if (AsType == AsteroidType.YTTRIUM) {
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.yttriumMedium [Random.Range (0, astList.yttriumMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.yttriumSmall [Random.Range (0, astList.yttriumSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.yttriumTiny [Random.Range (0, astList.yttriumTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         } else if (AsType == AsteroidType.URANIUM) {
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.uraniumMedium [Random.Range (0, astList.uraniumMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.uraniumSmall [Random.Range (0, astList.uraniumSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.uraniumTiny [Random.Range (0, astList.uraniumTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         } else if (AsType == AsteroidType.REQUILIUM) {
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.requiliumMedium [Random.Range (0, astList.requiliumMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.requiliumSmall [Random.Range (0, astList.requiliumSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.requiliumTiny [Random.Range (0, astList.requiliumTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         } else if (AsType == AsteroidType.XERINIUM) {
             if (AsSize == AsteroidSize.HUGE) {
                 Instantiate (astList.xeriniumMedium [Random.Range (0, astList.xeriniumMedium.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.MEDIUM) {
                 Instantiate (astList.xeriniumSmall [Random.Range (0, astList.xeriniumSmall.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.SMALL) {
                 Instantiate (astList.xeriniumTiny [Random.Range (0, astList.xeriniumTiny.Length)], new Vector3 (pos.x, pos.y, 0), gameObject.transform.rotation);
                 breakOut = true;
             } else if (AsSize == AsteroidSize.TINY) {
                 //If its tiny just destroy it and do nothing.
             }
         }
     }
 }
        //add a specified type asteroid
        public static void AddAsteroid(AsteroidType type, bool offScreen = false)
        {
            GameObject tempAsteroid; //temporary asteroid
            bool isOverlap = false; //overlap flag
            int counter = 0; //generation counter
            Texture2D text; //temporary texture
            switch (type) //assign appropriate texture to asteroid type
            {
                case AsteroidType.Small: text = ContentHandler.Textures[SMALL_ASTEROID];
                    break;
                case AsteroidType.Large: text = ContentHandler.Textures[LARGE_ASTEROID];
                    break;
                case AsteroidType.Ore: text = ContentHandler.Textures[ORE_ASTEROID];
                    break;
                default:
                    throw new InvalidOperationException();
            }

            do //Do-While to ensure that the asteroid gets generated at least once
            {
                float rot = MathHelper.ToRadians((float)Util.rnd.NextDouble(0f, 359f)); //random rotation

                //random rotational velocity; within constants
                float rotVel = MathHelper.ToRadians((float)Util.rnd.NextDouble(MINROTATIONALVELOCITY, MAXROTATIONALVELOCITY));

                float colRadius = text.GetMeanRadius();

                Vector2 vel; //temporary velocity
                Vector2 worldPos; //temporary worldposition

                if (offScreen) //if asteroid needs to be generated offscreen
                {
                    SpawnSide side = Util.RandomEnumValue<SpawnSide>(); //pick a random world border to spawn it from
                    switch (side)
                    {
                        case SpawnSide.Up:
                            vel = GetVelocity(MathHelper.ToRadians((float)Util.rnd.Next(140, 230))); //get a velocity pointing between 140/230 degrees

                            worldPos = new Vector2( //and add a velocity which will knock it into the world borders next tick
                                Util.rnd.Next(Camera.WorldRectangle.X, Camera.WorldRectangle.Width),
                                Camera.WorldRectangle.Y - text.Height);
                            break;
                        case SpawnSide.Left:
                            vel = GetVelocity(MathHelper.ToRadians((float)Util.rnd.Next(50, 130))); //between 50/130 degrees

                            worldPos = new Vector2(
                                Camera.WorldRectangle.X - text.Width,
                                Util.rnd.Next(Camera.WorldRectangle.Y, Camera.WorldRectangle.Height));
                            break;
                        case SpawnSide.Right:
                            vel = GetVelocity(MathHelper.ToRadians((float)Util.rnd.Next(230, 310))); //between 230/310 degrees

                            worldPos = new Vector2(
                                Camera.WorldRectangle.Width + text.Width,
                                Util.rnd.Next(Camera.WorldRectangle.Y, Camera.WorldRectangle.Height));
                            break;
                        case SpawnSide.Down:
                            vel = GetVelocity(
                                MathHelper.ToRadians(Util.rnd.Next(320, 410) % 360)); //between 320/(360 + 50) degrees

                            worldPos = new Vector2(
                                Util.rnd.Next(Camera.WorldRectangle.X, Camera.WorldRectangle.Width),
                                Camera.WorldRectangle.Height + text.Height);
                            break;
                        default:
                            throw new InvalidOperationException();
                    }
                }
                else //if the asteroid does not need to be generated offscreen...
                {
                    vel = GetVelocity(rot); //get a random velocity according to the rotation

                    worldPos = new Vector2( //and simply get a random position in the world to place it...
                        Util.rnd.Next(Camera.WorldRectangle.X, Camera.WorldRectangle.Width),
                        Util.rnd.Next(Camera.WorldRectangle.Y, Camera.WorldRectangle.Height));
                }

                tempAsteroid = new GameObject( //init a temporary asteroid to check for overlaps
                    text, worldPos, vel, Color.White, false, rot, rotVel, 1f, ASTEROID_DRAW_DEPTH, false, text.GetMeanRadius());

                foreach (GameObject asteroid in Asteroids)
                {
                    if (tempAsteroid.BoundingBox.Intersects(asteroid.BoundingBox)
                        || tempAsteroid.BoundingCircle.Intersects(Player.SpawnCircle))
                    {
                        isOverlap = true; //flag if overlapping
                        break; //and break; no need to check all other asteroids
                    }
                }
                counter++; //increase counter

            } while (isOverlap && counter < MAX_TRIES); //if overlapping, loop, if maxtries exceeded, quit

            if (counter >= MAX_TRIES)
            {
                return;
            }
            else
            {
                Asteroids.Add(tempAsteroid); //add the temp asteroid if not at maxtries
            }
        }
Beispiel #41
0
        public Asteroid(AsteroidType asteroidType, int width, int height, Random r)
        {
            AsteroidType = asteroidType;
            ImpactedBullets = new List<Bullet>();
            ToBeRemoved = false;
            //Safe zone can't be spawned in, 400x400 in middle of level
            int safeWidth = (width / 2) - 200;
            int safeHeight = (height / 2) - 200;

            //Determine which side to spawn on
            int temp = r.Next(4);

            switch (temp)
            {
                case 0: //left side
                    PositionX = r.Next(safeWidth);
                    PositionY = r.Next(height);
                    break;
                case 1: //right side
                    PositionX = width - (r.Next(safeWidth) + 1);
                    PositionY = r.Next(height);
                    break;
                case 2: //top side
                    PositionX = r.Next(width);
                    PositionY = r.Next(safeHeight);
                    break;
                case 3: //bottom side
                    PositionX = r.Next(width);
                    PositionY = height - (r.Next(safeHeight) + 1);
                    break;
            }

            Size = r.Next(5) + 1;
            Radius = Size * 16;
            Style = r.Next(3) + 1;
            RotationSpeed = (r.Next(1800) / 10.0f) * (r.Next(2) > 0 ? -1 : 1);
            Phase = 255;
            IsPhasing = true;

            //Here begins asteroid-type specific code
            switch (AsteroidType)
            {
                case AsteroidType.GENERIC:
                    {
                        Color = Color.White;

                        VelocityX = r.Next(20, 200) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(20, 200) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 200;
                        HP = Size * 5;
                        break;
                    }
                case AsteroidType.CLUMPY:
                    {
                        Color = Color.MediumPurple;

                        VelocityX = r.Next(80, 260) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(80, 260) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 300;
                        HP = Size * 10;
                        break;
                    }
                case AsteroidType.MAGNETIC:
                    {
                        Color = Color.Blue;

                        VelocityX = r.Next(80, 240) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(80, 240) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 160;
                        HP = Size * 10;
                        break;
                    }
                case AsteroidType.EXPLOSIVE:
                    {
                        Color = Color.OrangeRed;

                        VelocityX = r.Next(160, 200) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(160, 200) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 240;
                        HP = Size * 3;
                        break;
                    }
                case AsteroidType.BLACK:
                    {
                        Color = Color.Black;

                        VelocityX = r.Next(20, 200) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(20, 200) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 200;
                        HP = Size * 5;
                        break;
                    }
                case AsteroidType.DENSE:
                    {
                        Color = Color.Gray;

                        VelocityX = r.Next(20, 160) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(20, 160) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 1100;
                        HP = Size * 50;
                        break;
                    }
                case AsteroidType.GRAVITIC:
                    {
                        Color = Color.Cyan;

                        VelocityX = r.Next(200, 400) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(200, 400) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 300;
                        HP = Size * 10;
                        break;
                    }
                case AsteroidType.ZIPPY:
                    {
                        Color = Color.GreenYellow;

                        VelocityX = r.Next(400, 1000) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(400, 1000) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 30;
                        HP = Size * 5;
                        break;
                    }
                case AsteroidType.REPULSER:
                    {
                        Color = Color.HotPink;

                        VelocityX = r.Next(200, 400) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(200, 400) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 260;
                        HP = Size * 10;
                        break;
                    }
                case AsteroidType.PHASING:
                    {
                        Color = Color.DarkRed;

                        VelocityX = r.Next(40, 280) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(40, 280) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 220;
                        HP = Size * 20;

                        PhaseSpeed = r.Next(10, 255);
                        break;
                    }
                case AsteroidType.GOLD:
                    {
                        Color = Color.Gold;

                        VelocityX = r.Next(100, 300) * (r.Next(2) > 0 ? -1 : 1);
                        VelocityY = r.Next(100, 300) * (r.Next(2) > 0 ? -1 : 1);

                        Mass = Size * 400;
                        HP = Size * 40;
                        break;
                    }
            }
        }