private BuildingDto ConvertToBuildingDto(IBuilding building)
 {
     return(new BuildingDto()
     {
         Type = building.GetType().Name,
         Location = new LocationDto(building.Position.X, building.Position.Y),
         Direction = (Direction)Enum.Parse(typeof(Direction), building.Direction.ToString()),
         Material = (Material)Enum.Parse(typeof(Material), building.Material.Value.ToString())
     });
 }
示例#2
0
        /// <summary>
        /// Redirige l'ajout d'un bouton de building vers la méthode appropriée
        /// </summary>
        /// <param name="building"></param>
        private void AddBuildingToUI(IBuilding building)
        {
            if (building == null)
            {
                return;
            }

            switch (building.GetType().Name)
            {
            case "Farm":
                AddFarmToUI(building as Farm);
                break;

            case "TownHall":
                AddTownHallToUI(building as TownHall);
                break;

            default: break;
            }
        }
示例#3
0
        public bool DoSelectBuildingToBuild(IBuilding building, bool isHasPrivilage)
        {
            if (building == null)
            {
                return true;
            }

            var buildingToBuild =
                _mainBoardController.Status.Buildings.Single(x => x.Key.GetType() == building.GetType());
            var totalDiscount = _playerStatus.Board.Quarries.Count(x => x.CurrentColonistsCount > 0);
            var realCost = buildingToBuild.Key.Cost - totalDiscount - (isHasPrivilage ? 1 : 0);

            if (buildingToBuild.Value > 0 && realCost <= _playerStatus.Doubloons && _playerStatus.Board.CanBuildBuilding(buildingToBuild.Key.Size))
            {
                _playerStatus.Board.BuildBuilding(buildingToBuild.Key);
                _mainBoardController.Status.Buildings[buildingToBuild.Key]--;

                _mainBoardController.ReceiveDoubloons(_playerStatus.PayDoubloons(realCost));

                var param = new BuilderParameters();
                _playerStatus.Board.Buildings.OfType<BuildingBase<BuilderParameters>>()
                    .Where(x => x.IsActive)
                    .ToList()
                    .ForEach(x => x.DoAction(ref param));

                if (param.TakeAdditionalColonist)
                {
                    _mainBoardController.Status.Colonists.Move(buildingToBuild.Key);
                }

                return true;
            }

            return false;
        }