/// <summary> /// Create the asteroids /// </summary> public override void LoadContent() { CheckShouldLoad(); SpaceBackgroundData data = AssetManager.GetData <SpaceBackgroundData>(backgroundDataAsset); // Add any extra decals first so that they appear underneath our board sections // This will prevent anything obstructing our cards and card objects // Create the fixed size array of asteroids Asteroids = new Asteroid[data.AsteroidTextureAssets.Count * asteroidDensity]; Debug.Assert(AttachedComponent is BaseScreen); BaseScreen screen = AttachedComponent as BaseScreen; Vector2 size = ScreenManager.Instance.ScreenDimensions; int asteroidTypeIndex = 0; foreach (string asteroidTextureAsset in data.AsteroidTextureAssets) { for (int i = 0; i < asteroidDensity; ++i) { float xPos = MathUtils.GenerateFloat(-Region.X * 0.1f, Region.X * 0.9f); float yPos = MathUtils.GenerateFloat(0, Region.Y); // Make sure this is all rendered at the back by doing add game object Asteroids[asteroidTypeIndex * asteroidDensity + i] = screen.AddGameObject(new Asteroid(new Vector2(xPos, yPos), asteroidTextureAsset), true); } asteroidTypeIndex++; } base.LoadContent(); }
public override void PerformImmediately() { BaseScreen.AddGameObject(GameObject, Tag); Done = true; }
public override void Run(GameTime gameTime) { BaseScreen.AddGameObject(GameObject, Tag); }