TouchyTickets/TouchyTickets/Upgrades/NeighborModifierUpgrade.cs
2020-07-10 20:45:23 +02:00

26 lines
No EOL
1.1 KiB
C#

using System.Linq;
using Microsoft.Xna.Framework;
using TouchyTickets.Attractions;
namespace TouchyTickets.Upgrades {
public class NeighborModifierUpgrade : Upgrade {
private readonly AttractionType requiredNeighbor;
private readonly AttractionFlags requiredFlag;
private readonly float modifier;
public NeighborModifierUpgrade(string name, int price, Point texture, AttractionType requiredNeighbor, float modifier, AttractionFlags requiredFlag = AttractionFlags.None, params Upgrade[] dependencies) :
base(name, price, texture, dependencies) {
this.requiredNeighbor = requiredNeighbor;
this.requiredFlag = requiredFlag;
this.modifier = modifier;
}
public float GetCurrentMultiplier(Attraction attraction, ParkMap map, Point position) {
if (this.IsActive() && attraction.Type.Flags.HasFlag(this.requiredFlag) && attraction.GetSurrounding(map, position, this.requiredNeighbor).Any())
return this.modifier;
return 1;
}
}
}