public static List <Color> randomColorSet(int count) { // get a random and unique subset of the available colors List <int> range = Enumerable.Range(0, colorCount).ToList(); List <int> sample = new List <int>(); // set up the indexes in the sample list for (int i = 0; i < count; i++) { int choice = XNACS1Base.RandomInt(range.Count); sample.Add(range.ElementAt(choice)); range.RemoveAt(choice); } // get the colors from the indexes in the sample list List <Color> colors = new List <Color>(); foreach (int i in sample) { colors.Add(colorPicker(i)); } return(colors); }
public Debris(Hero hero, List <Enemy> enemies, float minX, float maxX) { float padding = size; float randomX = XNACS1Base.RandomFloat(minX + padding, maxX - padding); float randomY = XNACS1Base.RandomFloat(GameWorld.bottomEdge + padding, GameWorld.topEdge - padding); texture = new XNACS1Rectangle(new Vector2(randomX, randomY), size, size); switch (XNACS1Base.RandomInt(3)) { case 0: texture.Texture = "Beak"; break; case 1: texture.Texture = "Window"; break; case 2: texture.Texture = "Wing2"; texture.Width = texture.Height * 1.8f; break; } obstacle = new Obstacle(hero, enemies, texture.Center, texture.Width * .9f, texture.Height * .9f); }
private void fillPlatform(int offset, float leftEdge, bool continuous) { // set up platform float Ypos = ((offset * 1f) / Stargate.GATE_COUNT) * GameWorld.topEdge; if (continuous) { float Xpos = leftEdge + (Stargate.width / 2); Obstacle obstacle = new Obstacle(hero, enemies, new Vector2(Xpos, Ypos), Stargate.width + mask, height); obstacles.Add(obstacle); } else { // randomly fill platform float width = Stargate.width / SEGMENT_COUNT; Obstacle obstacle; int consecutiveChance = 10; bool platform = true; for (int i = 0; i < SEGMENT_COUNT; i++) { if (platform) { float Xpos = (width * 0.5f) + leftEdge + (i * width); obstacle = new Obstacle(hero, enemies, new Vector2(Xpos, Ypos), width + mask, height); obstacles.Add(obstacle); } consecutiveChance -= 2; if (XNACS1Base.RandomInt(consecutiveChance) == 0) { platform = !platform; consecutiveChance = 10; } } } }
private static Color randomStarColor() { int r = XNACS1Base.RandomInt(200, 256); int g = XNACS1Base.RandomInt(200, 256); int b = XNACS1Base.RandomInt(200, 256); return(new Color(r, g, b)); }
public static PowerUp randomPowerUp(Hero hero, float minX, float maxX) { switch (XNACS1Base.RandomInt(4)) { case 0: return(new SpeedUp(hero, minX, maxX)); case 1: return(new Ghost(hero, minX, maxX)); case 2: return(new Invincibility(hero, minX, maxX)); default: return(new Overload(hero, minX, maxX)); } }
public override void update() { // remove any dead enemies foreach (Enemy e in enemies.Where(enemy => !enemy.isAlive())) { e.remove(); } enemies.RemoveAll(enemy => !enemy.isAlive()); foreach (Enemy e in enemies) { e.update(); } // prevent generating enemy if (GameWorld.Speed != 0) { newEnemyTimer.update(); } //generate new enemy if (newEnemyTimer.isDone()) { float randomY = XNACS1Base.RandomFloat(GameWorld.topEdge - 5, GameWorld.bottomEdge + 5); Vector2 position = new Vector2(GameWorld.rightEdge + 5, randomY); switch (XNACS1Base.RandomInt(0, 3)) { case 1: enemies.Add(new BrainEnemy(position, 7.5f, hero)); break; case 2: enemies.Add(new RedBeamEnemy(position, 7.5f, hero)); break; default: enemies.Add(new SpiderEnemy(position, 7.5f, hero)); break; } newEnemyTimer.reset(); } }
public static Color randomColor() { // get a single random color return(colorPicker(XNACS1Base.RandomInt(6))); }