TouchyTickets/ThemeParkClicker/GameImpl.cs

63 lines
2.1 KiB
C#
Raw Normal View History

2020-05-30 19:41:49 +02:00
using System.Numerics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
2020-05-31 17:24:10 +02:00
using MLEM.Cameras;
2020-05-30 19:41:49 +02:00
using MLEM.Extensions;
using MLEM.Font;
using MLEM.Startup;
2020-05-31 17:24:10 +02:00
using ThemeParkClicker.Attractions;
2020-05-30 19:41:49 +02:00
namespace ThemeParkClicker {
public class GameImpl : MlemGame {
public static GameImpl Instance { get; private set; }
public BigInteger Tickets = 200;
2020-05-31 17:24:10 +02:00
public ParkMap Map { get; private set; }
public Camera Camera { get; private set; }
2020-05-30 19:41:49 +02:00
public Ui Ui { get; private set; }
2020-05-31 21:16:50 +02:00
public bool DrawMap;
2020-05-30 19:41:49 +02:00
public GameImpl() {
Instance = this;
}
protected override void LoadContent() {
base.LoadContent();
this.Ui = new Ui(this.UiSystem);
2020-05-31 17:24:10 +02:00
this.Map = new ParkMap(10, 10);
this.Camera = new Camera(this.GraphicsDevice) {
2020-05-31 21:16:50 +02:00
Scale = 16,
AutoScaleWithScreen = true,
AutoScaleReferenceSize = new Point(720, 1280),
MaxScale = 24,
MinScale = 4
2020-05-31 17:24:10 +02:00
};
this.Map.Place(Point.Zero, Attraction.Attractions["Carousel"]());
this.Map.Place(new Point(1, 0), Attraction.Attractions["Carousel"]());
this.Map.Place(new Point(3, 0), Attraction.Attractions["Carousel"]());
2020-05-31 21:16:50 +02:00
this.Map.Place(new Point(1, 2), Attraction.Attractions["FoodCourt"]());
2020-05-30 19:41:49 +02:00
}
public string DisplayTicketCount() {
return this.Tickets.ToString();
}
protected override void DoUpdate(GameTime gameTime) {
base.DoUpdate(gameTime);
2020-05-31 17:24:10 +02:00
this.Map.Update(gameTime);
this.Ui.Update(gameTime);
}
2020-05-30 19:41:49 +02:00
protected override void DoDraw(GameTime gameTime) {
2020-05-31 21:16:50 +02:00
this.GraphicsDevice.Clear(Color.Black);
if (this.DrawMap) {
this.SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, transformMatrix: this.Camera.ViewMatrix);
this.Map.Draw(gameTime, this.SpriteBatch, Vector2.Zero, 1);
this.SpriteBatch.End();
}
2020-05-30 19:41:49 +02:00
base.DoDraw(gameTime);
}
}
}