attraction flags and haunted house modifier

This commit is contained in:
Ellpeck 2020-06-05 23:40:31 +02:00
parent 5f09262b6b
commit db6811cc20
7 changed files with 42 additions and 24 deletions

View file

@ -8,6 +8,8 @@ using MLEM.Extensions;
using MLEM.Misc; using MLEM.Misc;
using MLEM.Startup; using MLEM.Startup;
using MLEM.Textures; using MLEM.Textures;
using static TouchyTickets.Attractions.AttractionFlags;
using static TouchyTickets.Attractions.AttractionType;
namespace TouchyTickets.Attractions { namespace TouchyTickets.Attractions {
[DataContract] [DataContract]
@ -28,11 +30,12 @@ namespace TouchyTickets.Attractions {
public float Update(GameTime time, TimeSpan passed, ParkMap map, Point position) { public float Update(GameTime time, TimeSpan passed, ParkMap map, Point position) {
var genRate = this.Type.GetGenerationRate(); var genRate = this.Type.GetGenerationRate();
// only apply dynamic upgrades here, static ones go into the type if (Upgrade.FoodCourtModifier.IsActive() && this.GetSurrounding(map, position, FoodCourt).Any())
if (Upgrade.FoodCourtModifier.IsActive() && this.GetSurrounding(map, position, AttractionType.FoodCourt).Any())
genRate *= 2; genRate *= 2;
if (Upgrade.SpiralSlideModifier.IsActive() && this.GetSurrounding(map, position, AttractionType.SpiralSlide).Any()) if (Upgrade.SpiralSlideModifier.IsActive() && this.GetSurrounding(map, position, SpiralSlide).Any())
genRate *= 2; genRate *= 2;
if (Upgrade.HauntedHouseModifier.IsActive() && this.Type.Flags.HasFlag(Relaxed) && this.GetSurrounding(map, position, HauntedHouse).Any())
genRate *= 3;
this.ticketPercentage += genRate * (float) passed.TotalSeconds; this.ticketPercentage += genRate * (float) passed.TotalSeconds;
var amount = this.ticketPercentage.Floor(); var amount = this.ticketPercentage.Floor();

View file

@ -0,0 +1,13 @@
using System;
namespace TouchyTickets.Attractions {
[Flags]
public enum AttractionFlags {
None = 0,
Relaxed = 1,
FastCars = 2,
Walking = 4
}
}

View file

@ -3,23 +3,24 @@ using System.Collections.Generic;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using MLEM.Textures; using MLEM.Textures;
using Newtonsoft.Json; using Newtonsoft.Json;
using static TouchyTickets.Attractions.AttractionFlags;
namespace TouchyTickets.Attractions { namespace TouchyTickets.Attractions {
[JsonConverter(typeof(Converter))] [JsonConverter(typeof(Converter))]
public class AttractionType { public class AttractionType {
public static readonly Dictionary<string, AttractionType> Attractions = new Dictionary<string, AttractionType>(); public static readonly Dictionary<string, AttractionType> Attractions = new Dictionary<string, AttractionType>();
public static readonly AttractionType Carousel = Register(new AttractionType("Carousel", RectArea(1, 1), Attraction.Texture[0, 0, 1, 1], 0.5F, 50)); public static readonly AttractionType Carousel = Register(new AttractionType("Carousel", RectArea(1, 1), Attraction.Texture[0, 0, 1, 1], 0.5F, 50, Relaxed));
public static readonly AttractionType MirrorHouse = Register(new AttractionType("MirrorHouse", RectArea(1, 1), Attraction.Texture[3, 0, 1, 1], 1, 150)); public static readonly AttractionType MirrorHouse = Register(new AttractionType("MirrorHouse", RectArea(1, 1), Attraction.Texture[3, 0, 1, 1], 1, 150, Relaxed | Walking));
public static readonly AttractionType FoodCourt = Register(new AttractionType("FoodCourt", RectArea(2, 1), Attraction.Texture[1, 0, 2, 1], 2F, 300)); public static readonly AttractionType FoodCourt = Register(new AttractionType("FoodCourt", RectArea(2, 1), Attraction.Texture[1, 0, 2, 1], 2F, 300, None));
public static readonly AttractionType SpiralSlide = Register(new AttractionType("SpiralSlide", RectArea(1, 2), Attraction.Texture[5, 0, 1, 2], 4, 1200)); public static readonly AttractionType SpiralSlide = Register(new AttractionType("SpiralSlide", RectArea(1, 2), Attraction.Texture[5, 0, 1, 2], 4, 1200, Relaxed | Walking));
public static readonly AttractionType HedgeMaze = Register(new AttractionType("HedgeMaze", RectArea(2, 2), Attraction.Texture[3, 3, 2, 2], 8, 2500)); public static readonly AttractionType HedgeMaze = Register(new AttractionType("HedgeMaze", RectArea(2, 2), Attraction.Texture[3, 3, 2, 2], 8, 2500, Relaxed | Walking));
public static readonly AttractionType FerrisWheel = Register(new AttractionType("FerrisWheel", RectArea(2, 2), Attraction.Texture[0, 1, 2, 2], 12, 4000)); public static readonly AttractionType FerrisWheel = Register(new AttractionType("FerrisWheel", RectArea(2, 2), Attraction.Texture[0, 1, 2, 2], 12, 4000, Relaxed));
public static readonly AttractionType FreefallCoaster = Register(new AttractionType("FreefallCoaster", new[,] {{true, false, true}, {true, true, true}}, Attraction.Texture[6, 0, 3, 2], 24, 8000)); public static readonly AttractionType FreefallCoaster = Register(new AttractionType("FreefallCoaster", new[,] {{true, false, true}, {true, true, true}}, Attraction.Texture[6, 0, 3, 2], 24, 8000, FastCars));
public static readonly AttractionType HauntedHouse = Register(new AttractionType("HauntedHouse", RectArea(2, 2), Attraction.Texture[3, 5, 2, 2], 30, 12000)); public static readonly AttractionType HauntedHouse = Register(new AttractionType("HauntedHouse", RectArea(2, 2), Attraction.Texture[3, 5, 2, 2], 30, 12000, FastCars));
public static readonly AttractionType WildMouse = Register(new AttractionType("WildMouse", RectArea(3, 2), Attraction.Texture[2, 1, 3, 2], 50, 24000)); public static readonly AttractionType WildMouse = Register(new AttractionType("WildMouse", RectArea(3, 2), Attraction.Texture[2, 1, 3, 2], 50, 24000, FastCars));
public static readonly AttractionType LogFlume = Register(new AttractionType("LogFlume", new[,] {{true, true, false}, {true, true, true}}, Attraction.Texture[0, 3, 3, 2], 75, 38000)); public static readonly AttractionType LogFlume = Register(new AttractionType("LogFlume", new[,] {{true, true, false}, {true, true, true}}, Attraction.Texture[0, 3, 3, 2], 75, 38000, FastCars));
public static readonly AttractionType WoodCoaster = Register(new AttractionType("WoodCoaster", RectArea(3, 3), Attraction.Texture[0, 5, 3, 3], 140, 60000)); public static readonly AttractionType WoodCoaster = Register(new AttractionType("WoodCoaster", RectArea(3, 3), Attraction.Texture[0, 5, 3, 3], 140, 60000, FastCars));
public readonly string Name; public readonly string Name;
public readonly bool[,] Area; public readonly bool[,] Area;
@ -28,19 +29,19 @@ namespace TouchyTickets.Attractions {
public readonly TextureRegion TextureRegion; public readonly TextureRegion TextureRegion;
private readonly float generationPerSecond; private readonly float generationPerSecond;
public readonly long InitialPrice; public readonly long InitialPrice;
private readonly Constructor create; public readonly AttractionFlags Flags;
public AttractionType(string name, bool[,] area, TextureRegion texture, float generationPerSecond, long initialPrice, Constructor constructor = null) { public AttractionType(string name, bool[,] area, TextureRegion texture, float generationPerSecond, long initialPrice, AttractionFlags flags) {
this.Name = name; this.Name = name;
this.Area = area; this.Area = area;
this.TextureRegion = texture; this.TextureRegion = texture;
this.generationPerSecond = generationPerSecond; this.generationPerSecond = generationPerSecond;
this.InitialPrice = initialPrice; this.InitialPrice = initialPrice;
this.create = constructor ?? (t => new Attraction(t)); this.Flags = flags;
} }
public Attraction Create() { public Attraction Create() {
return this.create(this); return new Attraction(this);
} }
public float GetGenerationRate() { public float GetGenerationRate() {
@ -48,11 +49,9 @@ namespace TouchyTickets.Attractions {
if (this == FerrisWheel && Upgrade.FerrisWheelModifier.IsActive()) if (this == FerrisWheel && Upgrade.FerrisWheelModifier.IsActive())
genRate *= 4; genRate *= 4;
// this should contain all car-based coasters that are fast if (this.Flags.HasFlag(FastCars) && Upgrade.RollerCoasterModifier.IsActive())
if ((this == Carousel || this == WildMouse || this == WoodCoaster || this == FreefallCoaster) && Upgrade.RollerCoasterModifier.IsActive())
genRate *= 2; genRate *= 2;
// this should contain all coasters where people just walk around on their own if (this.Flags.HasFlag(Walking) && Upgrade.ManualRideModifier.IsActive())
if ((this == SpiralSlide || this == HedgeMaze || this == MirrorHouse) && Upgrade.ManualRideModifier.IsActive())
genRate *= 3; genRate *= 3;
return genRate; return genRate;

View file

@ -54,5 +54,7 @@
"ManualRideModifier": "Push and Shove", "ManualRideModifier": "Push and Shove",
"ManualRideModifierDescription": "Increases the amount of people allowed on manual (walking-based) rides, tripling their ticket sales.", "ManualRideModifierDescription": "Increases the amount of people allowed on manual (walking-based) rides, tripling their ticket sales.",
"SpiralSlideModifier": "Sightseeing", "SpiralSlideModifier": "Sightseeing",
"SpiralSlideModifierDescription": "New binoculars allow spiral slide visitors to check out adjacent rides whose ticket sales are doubled as a result." "SpiralSlideModifierDescription": "New binoculars allow spiral slide visitors to check out adjacent rides whose ticket sales are doubled as a result.",
"HauntedHouseModifier": "Spooky, Scary",
"HauntedHouseModifierDescription": "Haunted houses become even scarier, causing riders to seek relaxation immediately. Triples ticket sales for all adjacent relaxed rides."
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -15,7 +15,8 @@ namespace TouchyTickets {
public static readonly Upgrade RollerCoasterModifier = Register(new Upgrade("RollerCoasterModifier", 2, Ui.Texture[3, 3])); public static readonly Upgrade RollerCoasterModifier = Register(new Upgrade("RollerCoasterModifier", 2, Ui.Texture[3, 3]));
public static readonly Upgrade ManualRideModifier = Register(new Upgrade("ManualRideModifier", 2, Ui.Texture[4, 3])); public static readonly Upgrade ManualRideModifier = Register(new Upgrade("ManualRideModifier", 2, Ui.Texture[4, 3]));
public static readonly Upgrade SpiralSlideModifier = Register(new Upgrade("SpiralSlideModifier", 2, Ui.Texture[5, 3])); public static readonly Upgrade SpiralSlideModifier = Register(new Upgrade("SpiralSlideModifier", 2, Ui.Texture[5, 3]));
public static readonly Upgrade HauntedHouseModifier = Register(new Upgrade("HauntedHouseModifier", 2, Ui.Texture[7, 3]));
public readonly string Name; public readonly string Name;
public readonly int Price; public readonly int Price;
public readonly TextureRegion Texture; public readonly TextureRegion Texture;