public LocationPointVM(ILocationPoint pointModel, double x, double y) { locationPoint = pointModel; offsetX = x - (ElipseSize/2.0); offsetY = y - (ElipseSize/2.0); BuildingInterface.Instance.CityWasBuilt += new CityBuiltHandler(CityWasBuilt); BuildingInterface.Instance.SettlementWasBuilt += new SettlementBuiltHandler(SettlementWasBuilt); }
public SettlementBuiltArgs(ILocationPoint settlementBuildPoint) { settlement = settlementBuildPoint; }
public CityBuiltArgs(ILocationPoint cityBuildPoint) { city = cityBuildPoint; }
public bool BuildSettlement(ILocationPoint locationPoint, Player player) { // if the point is already owned by someone if (locationPoint.PlayerOwner != 0) return false; // verify that at least one of our neighboring edges is the players if (!locationPoint.Edges.Any((edge) => edge.PlayerOwner == player.PlayerNumber)) return false; // check if the point is two edges away from all settlements players if (locationPoint.Edges.Any((edge) => edge.GetOppositePoint(locationPoint).PlayerOwner != 0)) return false; if (player.TakeResource(SettlementCost)) { ((LocationPoint)locationPoint).PlayerOwner = player.PlayerNumber; this.SettlementWasBuilt(this, new SettlementBuiltArgs(locationPoint)); return true; } return false; }
public bool BuildCity(ILocationPoint locationPoint, Player player) { // if the spot is owned by another player if (locationPoint.PlayerOwner != player.PlayerNumber) return false; // if the spot is already a city, you can't build another city if (locationPoint.IsACity) return false; if (player.TakeResource(CityCost)) { ((LocationPoint)locationPoint).IsACity = true; this.CityWasBuilt(this, new CityBuiltArgs(locationPoint)); return true; } return false; }
public ILocationPoint GetOppositePoint(ILocationPoint point) { if (point == null) return null; if (!ConnectingPoints.Contains(point)) return null; if (ConnectingPoints[0] == point) return connectingPoints[1]; else return connectingPoints[0]; }