wild mouse and no brakes

This commit is contained in:
Ellpeck 2020-06-02 15:49:46 +02:00
parent a53070ba4d
commit bef7885124
11 changed files with 53 additions and 33 deletions

View file

@ -25,21 +25,12 @@ namespace TouchyTickets.Attractions {
this.Type = type; this.Type = type;
} }
public IEnumerable<Point> 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 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! // only apply dynamic upgrades here, static ones go into the type
if (Upgrade.FoodCourtModifier.IsActive() && this.GetSurrounding(map, position, AttractionType.FoodCourt).Any()) if (Upgrade.FoodCourtModifier.IsActive() && this.GetSurrounding(map, position, AttractionType.FoodCourt).Any())
genRate *= 3; genRate *= 2;
this.ticketPercentage += genRate * (float) passed.TotalSeconds; this.ticketPercentage += genRate * (float) passed.TotalSeconds;
var amount = this.ticketPercentage.Floor(); var amount = this.ticketPercentage.Floor();
@ -52,7 +43,7 @@ namespace TouchyTickets.Attractions {
} }
public IEnumerable<Attraction> GetSurrounding(ParkMap map, Point position, AttractionType type) { public IEnumerable<Attraction> GetSurrounding(ParkMap map, Point position, AttractionType type) {
foreach (var tile in this.GetCoveredTiles()) { foreach (var tile in this.Type.GetCoveredTiles()) {
foreach (var dir in Direction2Helper.Adjacent) { foreach (var dir in Direction2Helper.Adjacent) {
var other = map.GetAttractionAt(position + tile + dir.Offset()); var other = map.GetAttractionAt(position + tile + dir.Offset());
if (other != null && other != this && other.Type == type) if (other != null && other != this && other.Type == type)

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Xna.Framework;
using MLEM.Textures; using MLEM.Textures;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -8,9 +9,10 @@ namespace TouchyTickets.Attractions {
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", new[,] {{true}}, 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));
public static readonly AttractionType FoodCourt = Register(new AttractionType("FoodCourt", new[,] {{true, true}}, Attraction.Texture[1, 0, 2, 1], 1.1F, 300)); public static readonly AttractionType FoodCourt = Register(new AttractionType("FoodCourt", RectArea(2, 1), Attraction.Texture[1, 0, 2, 1], 1.1F, 300));
public static readonly AttractionType FerrisWheel = Register(new AttractionType("FerrisWheel", new[,] {{true, true}, {true, true}}, Attraction.Texture[0, 1, 2, 2], 3.5F, 2000)); public static readonly AttractionType FerrisWheel = Register(new AttractionType("FerrisWheel", RectArea(2, 2), Attraction.Texture[0, 1, 2, 2], 3.5F, 2000));
public static readonly AttractionType WildMouse = Register(new AttractionType("WildMouse", RectArea(3, 2), Attraction.Texture[2, 1, 3, 2], 10, 5000));
public readonly string Name; public readonly string Name;
public readonly bool[,] Area; public readonly bool[,] Area;
@ -39,15 +41,36 @@ 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
if ((this == Carousel || this == WildMouse) && Upgrade.RollerCoasterModifier.IsActive())
genRate *= 2;
return genRate; return genRate;
} }
public IEnumerable<Point> GetCoveredTiles() {
for (var x = 0; x < this.Width; x++) {
for (var y = 0; y < this.Height; y++) {
if (this.Area[y, x])
yield return new Point(x, y);
}
}
}
private static AttractionType Register(AttractionType type) { private static AttractionType Register(AttractionType type) {
Attractions.Add(type.Name, type); Attractions.Add(type.Name, type);
return type; return type;
} }
private static bool[,] RectArea(int width, int height) {
var ret = new bool[height, width];
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++)
ret[y, x] = true;
}
return ret;
}
public delegate Attraction Constructor(AttractionType type); public delegate Attraction Constructor(AttractionType type);
public class Converter : JsonConverter<AttractionType> { public class Converter : JsonConverter<AttractionType> {

View file

@ -6,18 +6,21 @@
"Carousel": "Carousel", "Carousel": "Carousel",
"FoodCourt": "Food Court", "FoodCourt": "Food Court",
"FerrisWheel": "Ferris Wheel", "FerrisWheel": "Ferris Wheel",
"WildMouse": "Wild Mouse",
"MapSize1": "Big Park", "MapSize1": "Big Park",
"MapSize1Description": "Increases your park's buildable area", "MapSize1Description": "Increases your park's buildable area.",
"MapSize2": "Bigger Park", "MapSize2": "Bigger Park",
"MapSize2Description": "Increases your park's buildable area more", "MapSize2Description": "Increases your park's buildable area more.",
"MapSize3": "Biggest Park", "MapSize3": "Biggest Park",
"MapSize3Description": "Increases your park's buildable area even more", "MapSize3Description": "Increases your park's buildable area even more.",
"MapSize4": "Biggester Park", "MapSize4": "Biggester Park",
"MapSize4Description": "Increases your park's buildable area even more", "MapSize4Description": "Increases your park's buildable area even more.",
"MapSize5": "Biggestest Park", "MapSize5": "Biggestest Park",
"MapSize5Description": "Increases your park's buildable area to the maximum", "MapSize5Description": "Increases your park's buildable area to the maximum.",
"FoodCourtModifier": "Tasty Treats", "FoodCourtModifier": "Tasty Treats",
"FoodCourtModifierDescription": "Triples ticket sales for all attractions adjacent to food courts", "FoodCourtModifierDescription": "Doubles ticket sales for all attractions adjacent to food courts.",
"FerrisWheelModifier": "Crowded Pods", "FerrisWheelModifier": "Crowded Pods",
"FerrisWheelModifierDescription": "Quadruples ticket sales for ferris wheels. Who cares about fire safety?" "FerrisWheelModifierDescription": "Quadruples ticket sales for ferris wheels. Who cares about fire safety?",
"RollerCoasterModifier": "No Brakes",
"RollerCoasterModifierDescription": "Increases the speed of all car-based attractions, doubling their ticket sales."
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -78,7 +78,7 @@ namespace TouchyTickets {
} }
public BigInteger GetStarPrice() { public BigInteger GetStarPrice() {
return BigInteger.Pow(1000000, this.TimesRestarted / 2 + 1); return 1000000 * BigInteger.Pow(10, this.TimesRestarted / 2);
} }
} }

View file

@ -90,7 +90,9 @@ namespace TouchyTickets {
if (this.draggingAttraction) { if (this.draggingAttraction) {
// move the current placing position // move the current placing position
var nextPos = (camera.ToWorldPos(drag.Position + drag.Delta) / Attraction.TileSize).ToPoint(); var nextPos = (camera.ToWorldPos(drag.Position + drag.Delta) / Attraction.TileSize).ToPoint();
if (this.PlacingAttraction.GetCoveredTiles().Select(p => nextPos + p).All(p => p.X >= 0 && p.Y >= 0 && p.X < this.Width && p.Y < this.Height)) // drag the center of the attraction
nextPos -= new Point(this.PlacingAttraction.Type.Width / 2, this.PlacingAttraction.Type.Height / 2);
if (this.PlacingAttraction.Type.GetCoveredTiles().Select(p => nextPos + p).All(p => p.X >= 0 && p.Y >= 0 && p.X < this.Width && p.Y < this.Height))
this.PlacingPosition = nextPos; this.PlacingPosition = nextPos;
} else { } else {
// move the camera // move the camera
@ -102,7 +104,7 @@ namespace TouchyTickets {
continue; continue;
// when first pressing down, go into attraction drag mode if we're touching the place location // when first pressing down, go into attraction drag mode if we're touching the place location
var offset = (camera.ToWorldPos(touch.Position) / Attraction.TileSize).ToPoint(); var offset = (camera.ToWorldPos(touch.Position) / Attraction.TileSize).ToPoint();
this.draggingAttraction = this.PlacingAttraction.GetCoveredTiles() this.draggingAttraction = this.PlacingAttraction.Type.GetCoveredTiles()
.Any(p => this.PlacingPosition + p == offset); .Any(p => this.PlacingPosition + p == offset);
} }
} }
@ -137,14 +139,14 @@ namespace TouchyTickets {
// placing attraction // placing attraction
if (this.PlacingAttraction != null) { if (this.PlacingAttraction != null) {
var placingPos = position + this.PlacingPosition.ToVector2() * tileSize; var placingPos = position + this.PlacingPosition.ToVector2() * tileSize;
foreach (var pos in this.PlacingAttraction.GetCoveredTiles()) foreach (var pos in this.PlacingAttraction.Type.GetCoveredTiles())
batch.Draw(batch.GetBlankTexture(), new RectangleF(placingPos + pos.ToVector2() * tileSize, tileSize), Color.Black * 0.15F * alpha); batch.Draw(batch.GetBlankTexture(), new RectangleF(placingPos + pos.ToVector2() * tileSize, tileSize), Color.Black * 0.15F * alpha);
batch.Draw(this.PlacingAttraction.Type.TextureRegion, placingPos, Color.White * alpha * 0.5F, 0, Vector2.Zero, scale, SpriteEffects.None, 0); batch.Draw(this.PlacingAttraction.Type.TextureRegion, placingPos, Color.White * alpha * 0.5F, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
} }
} }
public bool CanPlace(Point position, Attraction attraction) { public bool CanPlace(Point position, Attraction attraction) {
foreach (var offset in attraction.GetCoveredTiles()) { foreach (var offset in attraction.Type.GetCoveredTiles()) {
if (this.GetAttractionAt(position + offset) != null) if (this.GetAttractionAt(position + offset) != null)
return false; return false;
} }
@ -152,7 +154,7 @@ namespace TouchyTickets {
} }
public void Place(Point position, Attraction attraction) { public void Place(Point position, Attraction attraction) {
foreach (var (x, y) in attraction.GetCoveredTiles()) foreach (var (x, y) in attraction.Type.GetCoveredTiles())
this.attractionGrid[position.X + x, position.Y + y] = attraction; this.attractionGrid[position.X + x, position.Y + y] = attraction;
this.attractions.Add((position, attraction)); this.attractions.Add((position, attraction));
} }

View file

@ -46,7 +46,7 @@ namespace TouchyTickets {
if (rainingTickets[i].Update()) if (rainingTickets[i].Update())
rainingTickets.RemoveAt(i); rainingTickets.RemoveAt(i);
} }
while (rainingTickets.Count < Math.Min(GameImpl.Instance.Map.TicketsPerSecond / 10, 500)) while (rainingTickets.Count < Math.Min(GameImpl.Instance.Map.TicketsPerSecond / 10, 200))
rainingTickets.Add(new RainingTicket()); rainingTickets.Add(new RainingTicket());
}, },
OnDrawn = (e, time, batch, alpha) => { OnDrawn = (e, time, batch, alpha) => {
@ -120,7 +120,7 @@ namespace TouchyTickets {
map.PlacingAttraction = attraction.Value.Create(); map.PlacingAttraction = attraction.Value.Create();
// set placing position to center of camera's view // set placing position to center of camera's view
var (posX, posY) = (GameImpl.Instance.Camera.LookingPosition / Attraction.TileSize).ToPoint(); var (posX, posY) = (GameImpl.Instance.Camera.LookingPosition / Attraction.TileSize).ToPoint();
map.PlacingPosition = new Point(MathHelper.Clamp(posX, 0, map.Width), MathHelper.Clamp(posY, 0, map.Height)); map.PlacingPosition = new Point(MathHelper.Clamp(posX, 0, map.Width - attraction.Value.Width), MathHelper.Clamp(posY, 0, map.Height - attraction.Value.Height));
var yesNoUi = new Group(Anchor.BottomLeft, new Vector2(1)); var yesNoUi = new Group(Anchor.BottomLeft, new Vector2(1));
yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 40), Localization.Get("Back")) { yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 40), Localization.Get("Back")) {

View file

@ -11,6 +11,7 @@ namespace TouchyTickets {
public static readonly Upgrade[] MapSize = RegisterTiers("MapSize", 5, 1, 0.5F, Ui.Texture[0, 3]); public static readonly Upgrade[] MapSize = RegisterTiers("MapSize", 5, 1, 0.5F, Ui.Texture[0, 3]);
public static readonly Upgrade FoodCourtModifier = Register(new Upgrade("FoodCourtModifier", 1, Ui.Texture[1, 3])); public static readonly Upgrade FoodCourtModifier = Register(new Upgrade("FoodCourtModifier", 1, Ui.Texture[1, 3]));
public static readonly Upgrade FerrisWheelModifier = Register(new Upgrade("FerrisWheelModifier", 1, Ui.Texture[2, 3])); public static readonly Upgrade FerrisWheelModifier = Register(new Upgrade("FerrisWheelModifier", 1, Ui.Texture[2, 3]));
public static readonly Upgrade RollerCoasterModifier = Register(new Upgrade("RollerCoasterModifier", 1, Ui.Texture[3, 3]));
public readonly string Name; public readonly string Name;
public readonly int Price; public readonly int Price;