using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MLEM.Extensions; using MLEM.Startup; using MLEM.Textures; namespace ThemeParkClicker.Attractions { public class Attraction { public static readonly Dictionary Attractions = new Dictionary(); public static readonly UniformTextureAtlas Texture = new UniformTextureAtlas(MlemGame.LoadContent("Textures/Attractions"), 16, 16); public static readonly Vector2 TileSize = new Vector2(Texture.RegionWidth, Texture.RegionHeight); static Attraction() { Attractions.Add("Carousel", () => new Attraction(new[,] {{true}}, Texture[0, 0, 1, 1], 0.5F, 50)); Attractions.Add("FoodCourt", () => new Attraction(new[,] {{true, true}}, Texture[1, 0, 2, 1], 0.7F, 300)); } private readonly bool[,] area; public int Width => this.area.GetLength(0); public int Height => this.area.GetLength(1); public readonly TextureRegion TextureRegion; public readonly float GenerationPerSecond; public readonly long InitialPrice; private float ticketPercentage; public Attraction(bool[,] area, TextureRegion texture, float generationPerSecond, long initialPrice) { this.area = area; this.TextureRegion = texture; this.GenerationPerSecond = generationPerSecond; this.InitialPrice = initialPrice; } public bool HasTileAt(int x, int y) { return this.area[y, x]; } public delegate Attraction Constructor(); public long GetPrice() { return this.InitialPrice; } public void GainTickets(GameTime time) { this.ticketPercentage += this.GenerationPerSecond * (float) time.ElapsedGameTime.TotalSeconds; var amount = this.ticketPercentage.Floor(); if (amount > 0) { GameImpl.Instance.Tickets += amount; this.ticketPercentage -= amount; } } } }