public void AddSpawnCollectables(Collectable.CollectType SpawnType, int SpawnCount) { int intSepPos = (int)Math.Ceiling(background.backgroundPixelsToFinishScreen / (SpawnCount + 1)); for (var i = 1; i <= SpawnCount; i++) collectableSpawns.Add(new CollectableSpawnDetail(SpawnType, intSepPos * i)); }
void SpawnCollectable(Collectable.CollectType Type) { Texture2D collTexture = collectWifiTexture; switch (Type) { case Collectable.CollectType.BIKE: collTexture = collectBikeTexture; break; case Collectable.CollectType.POINTS: collTexture = collectPointsTexture; break; case Collectable.CollectType.WIFI: collTexture = collectWifiTexture; break; case Collectable.CollectType.HPSML: collTexture = collectHPSmlTexture; break; case Collectable.CollectType.HPLGE: collTexture = collectHPLgeTexture; break; } float randomY = rand.Next(TopBoundary, BottomBoundary); Vector2 offset = new Vector2(collTexture.Width, collTexture.Height) / 2.0f; Vector2 Pos = new Vector2(graphics.PreferredBackBufferWidth + OffScreenRightOffset, randomY); while (!CollisionCheckForSpawn(Pos, offset, collTexture.Width, collTexture.Height)) { if ((Pos.Y + 10) < BottomBoundary) Pos.Y += 10; else Pos.Y = TopBoundary; } Collectable c = new Collectable(collTexture, Pos, defaultSpeed, Type); c.collectScrollSpeed = scrollSpeed; collectables.Add(c); }
public CollectableSpawnDetail(Collectable.CollectType collType, int collXPos) { this.Type = collType; this.CollectXPos = collXPos; this.Spawned = false; }