public Coin(Texture2D texture, Rectangle rectangle, int value, CoinSoundController sound) : base(texture, rectangle) { this.value = value; this.isActive = true; this.animation = new ItemAnimation(texture, rectangle, 4, 1); this.sound = sound; }
private void GenerateObjects() { CoinSoundController coinSound = new CoinSoundController(content.Load <Song>("Audio/handleCoins")); spawnPoint = map.spawnPosition; GeneratePlayerAndBackground(); foreach (Rectangle obj in map.movableObjects) { movableItems.Add(new MovableItem(content.Load <Texture2D>("Items/chest"), obj)); } foreach (Rectangle obj in map.fallableObjects) { FallableObject temp = new FallableObject(content.Load <Texture2D>("Items/bridge"), obj); fallableObjects.Add(temp); map.mapObjects.Add(temp.rectangle); } foreach (Rectangle tmp in map.springs) { springs.Add(new Spring(content.Load <Texture2D>("Items/spring"), tmp)); } foreach (var tmp in map.checkPoints) { var newItem = new CheckPoint(tmp, content.Load <Texture2D>("Items/checkpoint"), content.Load <Texture2D>("Items/checkpointanim")); _checkpoints.Add(newItem); _items.Add(newItem); } foreach (var tmp in map.levers) { List <Platform> platforms = new List <Platform>(); foreach (PlatformInstanceForMap platform in map.platforms) { if (platform.leverNumber == tmp.leverNumber) { platforms.Add(new Platform(content.Load <Texture2D>("items/platform"), platform.rectangle)); } } _items.Add(new Lever(content.Load <Texture2D>("items/lever"), tmp.rectangle, map, platforms)); } foreach (var tmp in map.GetCoins()) { _items.Add(new Coin(content.Load <Texture2D>("Items/coinAnimation"), new Rectangle((int)tmp.X, (int)tmp.Y, 50, 50), 1, coinSound)); } foreach (var tmp in map.GetLadders()) { _items.Add(new Ladder(tmp)); } foreach (var tmp in map.tourches) { _items.Add(new Tourch(content.Load <Texture2D>("items/tourch"), tmp)); } foreach (var tmp in map.snails) { _sprites.Add(new MovingBug(content.Load <Texture2D>("Sprites/snailAnimation"), tmp, content.Load <Texture2D>("textureEffects/whiteFogAnimation"), 100, 1)); } foreach (var tmp in map.mouse) { _sprites.Add(new MovingBug(content.Load <Texture2D>("Sprites/mouseAnimation"), tmp, content.Load <Texture2D>("textureEffects/whiteFogAnimation"), 300, 3)); } foreach (var tmp in map.worms) { _sprites.Add(new MovingBug(content.Load <Texture2D>("Sprites/greenWormAnimation"), tmp, content.Load <Texture2D>("textureEffects/whiteFogAnimation"), 150, 2)); } foreach (var tmp in map.flyingBugs) { _sprites.Add(new Fly(content.Load <Texture2D>("Sprites/flyAnimation"), tmp, content.Load <Texture2D>("textureEffects/whiteFogAnimation"), 400, 2)); } EndPoint = map.endPosition; foreach (var tmp in map.powerups) { if (tmp.Height == 1) { InventoryItem tmpItem = new InventoryItem(tmp.Height, 20, content.Load <Texture2D>("jetpack"), false); _items.Add(new PickableItem(content.Load <Texture2D>("jetpack"), new Rectangle(tmp.X, tmp.Y, tmp.Width, tmp.Width), tmpItem)); } } gameMaster = new GameMaster(content, new Vector2(graphics.Viewport.Width, graphics.Viewport.Height), map.gameMasterSpawn, messageList); }