PowerUpGlyph GetPowerUpGlyph(float x, float y, Type type) { Sprite theSprite = G.PowerUpTypeToSprite(type); if (PowerUpPool.Count > 0) { PowerUpGlyph g = PowerUpPool[PowerUpPool.Count - 1]; PowerUpPool.RemoveAt(PowerUpPool.Count - 1); g.Position = new Vector2(x, y); g.Sprite = theSprite; g.Visible = true; return(g); } return(PowerUpGlyph.CreatePowerUpGlyph(x, y, theSprite)); }
public void Redraw() { foreach (var g in PowerUpsGlyphs) { g.Visible = false; g.PowerUp = null; PowerUpPool.Add(g); } PowerUpsGlyphs.Clear(); int index = 0; selectedGlyph.Visible = false; foreach (var kv in thing.PowerUps) { var powerup = kv.Value; if (powerup.hide) { continue; } PowerUpGlyph glyph = GetPowerUpGlyph(index, 14.75f, powerup.GetType()); glyph.PowerUp = kv.Value; if (selected == null) { selected = powerup; } if (selected == powerup) { selectedGlyph.Position = new Vector2(index, 14.75f); selectedGlyph.Visible = true; } PowerUpsGlyphs.Add(glyph); index++; } }