2020-05-31 00:44:15 +02:00
|
|
|
using System.Collections.Generic;
|
2020-05-31 17:24:10 +02:00
|
|
|
using Microsoft.Xna.Framework;
|
2020-05-31 00:44:15 +02:00
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2020-05-31 17:24:10 +02:00
|
|
|
using MLEM.Extensions;
|
2020-05-31 00:44:15 +02:00
|
|
|
using MLEM.Startup;
|
|
|
|
using MLEM.Textures;
|
|
|
|
|
|
|
|
namespace ThemeParkClicker.Attractions {
|
|
|
|
public class Attraction {
|
|
|
|
|
|
|
|
public static readonly Dictionary<string, Constructor> Attractions = new Dictionary<string, Constructor>();
|
|
|
|
public static readonly UniformTextureAtlas Texture = new UniformTextureAtlas(MlemGame.LoadContent<Texture2D>("Textures/Attractions"), 16, 16);
|
2020-05-31 17:24:10 +02:00
|
|
|
public static readonly Vector2 TileSize = new Vector2(Texture.RegionWidth, Texture.RegionHeight);
|
2020-05-31 00:44:15 +02:00
|
|
|
|
|
|
|
static Attraction() {
|
2020-05-31 17:24:10 +02:00
|
|
|
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));
|
2020-05-31 00:44:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2020-05-31 17:24:10 +02:00
|
|
|
private float ticketPercentage;
|
2020-05-31 00:44:15 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-05-31 17:24:10 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-31 00:44:15 +02:00
|
|
|
}
|
|
|
|
}
|