using System; using System.Collections.Generic; using System.Runtime.Serialization; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MLEM.Extensions; using MLEM.Startup; using MLEM.Textures; namespace ThemeParkClicker.Attractions { [DataContract] public class Attraction { public static readonly UniformTextureAtlas Texture = new UniformTextureAtlas(MlemGame.LoadContent("Textures/Attractions"), 16, 16); public static readonly Vector2 TileSize = new Vector2(Texture.RegionWidth, Texture.RegionHeight); [DataMember] public readonly AttractionType Type; [DataMember] private float ticketPercentage; public Attraction(AttractionType type) { this.Type = type; } public IEnumerable GetCoveredTiles() { for (var x = 0; x < this.Type.Width; x++) { for (var y = 0; y < this.Type.Height; y++) { if (this.Type.Area[y, x]) yield return new Point(x, y); } } } public void Update(GameTime time, TimeSpan passed) { this.ticketPercentage += this.Type.GenerationPerSecond * (float) passed.TotalSeconds; var amount = this.ticketPercentage.Floor(); if (amount > 0) { GameImpl.Instance.Tickets += amount; this.ticketPercentage -= amount; } } } }