Пример #1
0
        private void DrawBuilding(Graphics gfx, HexPoint point, Building building)
        {
            var centerPoint = HexPointToAbsolutePoint(point);
            if (centerPoint != PointF.Empty) // Should never draw a building at (0,0)...
            {
                Brush b = new SolidBrush(PlayerToColor(building.Player));
                Pen p = new Pen(Color.Black, 1f);

                var relativeSize = (building.Type == BuildingTypes.Settlement) ? (RelativeTileWidth)*(1/5f) : (RelativeTileWidth)*(2/5f);
                var width = this.Width*relativeSize/100f;
                var height = this.Height*relativeSize/100f;
                var rect = centerPoint.GetRect(width, height);

                gfx.FillRectangle(b, rect);
                gfx.DrawRectangle(p, rect.X, rect.Y, rect.Width, rect.Height);

                b.Dispose();
                p.Dispose();
            }
        }
Пример #2
0
 /// <summary>
 /// Places a new building onto the board. A player is allowed to upgrade a settlement to a city.
 /// </summary>
 public ActionResult PlaceBuilding(int player, BuildingTypes buildingType, HexPoint point, bool startOfGame)
 {
     var validationResult = ValidateBuildingPlacement(player, buildingType, point, startOfGame);
     if (validationResult.Failed) return validationResult;
     _buildings[point] = new Building(player, buildingType);
     return ActionResult.CreateSuccess();
 }