示例#1
0
 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);
 }
示例#2
0
 public SettlementBuiltArgs(ILocationPoint settlementBuildPoint)
 {
     settlement = settlementBuildPoint;
 }
示例#3
0
 public CityBuiltArgs(ILocationPoint cityBuildPoint)
 {
     city = cityBuildPoint;
 }
示例#4
0
 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;
 }
示例#5
0
 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;
 }
示例#6
0
 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];
 }