コード例 #1
0
    private void UpgradeEmpire(SectorDetails sector)
    {
        if (LogManager.Instance.logsEnabled)
        {
            if (LogManager.Instance.empireUpgradeLogs)
            {
                Debug.Log($"Upgrading {Name}'s {sector.sectorName} in space year {GameManager.Instance.spaceYear}.");
            }
        }
        switch (sector.sectorName)
        {
        case "Economy":
            GrowGEP();
            break;

        case "Exploration":
            ExploreStar();
            break;

        case "Colonization":
            //TODO May want to eventually have individual planets with their own bonuses that roll here
            if (discoveredPlanets > 0)
            {
                colonizedPlanets++;
                discoveredPlanets--;
                if (isPlayer)
                {
                    string colonizedPlanetNotification = $"A {race.raceAdjective} colony ship has just landed on a new world. \n" +
                                                         $"Your empire's GEP will increase at a slightly faster rate from now on, as the population grows, \n " +
                                                         $"the colony develops infrastructure, and trade flourishes with your other worlds. \n \n" +
                                                         $"(Each economic upgrade going forward will be {MagicNumbers.Instance.planetGrossEmpireProductContribution} larger.)";
                    AddNotificationToList(colonizedPlanetNotification);
                }
            }
            else
            {
                colonyShips++;
            }

            break;

        case "Military":
            if (LogManager.Instance.logsEnabled)
            {
                if (LogManager.Instance.fleetUpgradeLogs)
                {
                    Debug.Log($"Upgrading fleet - from {militaryCapacity} to {(militaryCapacity + 1)}.");
                }
            }

            militaryCapacity++;
            //TODO Multiply by a value - say 1.08 - rounding up if less than 1?
            break;

        case "Science":
            int selectedSector = UnityEngine.Random.Range(1, 7);
            switch (selectedSector)
            {
            case 1:
                economy.sectorScienceMultiplier += 0.1f;
                break;

            case 2:
                exploration.sectorScienceMultiplier += 0.1f;
                break;

            case 3:
                colonization.sectorScienceMultiplier += 0.1f;
                break;

            case 4:
                military.sectorScienceMultiplier += 0.1f;
                break;

            case 5:
                science.sectorScienceMultiplier += 0.1f;
                break;

            case 6:
                diplomacy.sectorScienceMultiplier += 0.1f;
                if (diplomacy.sectorScienceMultiplier == 5 || diplomacy.sectorScienceMultiplier == 10 || diplomacy.sectorScienceMultiplier == 30)
                {
                    string diplomacyCongratulations = $"Recent scientific breakthroughs will allow {race.raceName} diplomats to reach out \n " +
                                                      "to less welcoming aliens and improve our relations with them. The galaxy became a more peaceful place today.";
                    AddNotificationToList(diplomacyCongratulations);
                }
                break;
            }
            break;

        case "Diplomacy":
            yearlyDiplomaticCapacity++;
            break;
        }
    }
コード例 #2
0
        public async Task <ApiResponse> Handle(AddSectorDetailsCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response     = new ApiResponse();
            long        LatestCodeId = 0;

            if (request != null && !string.IsNullOrWhiteSpace(request.SectorName))
            {
                var code = string.Empty;

                try
                {
                    var data = _dbContext.SectorDetails.FirstOrDefault(x => x.IsDeleted == false && x.SectorName.Trim().ToLower() == request.SectorName.Trim().ToLower());

                    if (data == null)
                    {
                        SectorDetails obj          = new SectorDetails();
                        var           sectorDetail = _dbContext.SectorDetails
                                                     .OrderByDescending(x => x.SectorId)
                                                     .FirstOrDefault(x => x.IsDeleted == false);
                        if (sectorDetail == null)
                        {
                            LatestCodeId = 1;
                            code         = ProjectUtility.GenerateCode(LatestCodeId);
                        }
                        else
                        {
                            LatestCodeId = sectorDetail.SectorId + 1;
                            code         = ProjectUtility.GenerateCode(LatestCodeId);
                        }
                        obj.SectorName  = request.SectorName;
                        obj.IsDeleted   = false;
                        obj.SectorCode  = code;
                        obj.CreatedById = request.CreatedById;
                        obj.CreatedDate = DateTime.UtcNow;
                        await _dbContext.SectorDetails.AddAsync(obj);

                        await _dbContext.SaveChangesAsync();

                        if (obj.SectorId != 0)
                        {
                            ProjectSectorModel projectSectorModel = new ProjectSectorModel()
                            {
                                SectorId        = obj.SectorId,
                                ProjectId       = request.ProjectId,
                                ProjectSectorId = 0
                            };


                            var addEditProjectSector = await _iProjectServices.AddEditProjectSector(projectSectorModel, request.CreatedById);

                            if (addEditProjectSector.StatusCode == 200)
                            {
                                response.StatusCode         = StaticResource.successStatusCode;
                                response.data.SectorDetails = obj;
                                response.Message            = "Success";
                            }
                            else
                            {
                                throw new Exception("Project Sector could not be saved");
                            }
                        }
                    }
                    else
                    {
                        response.StatusCode = StaticResource.NameAlreadyExist;
                        response.Message    = StaticResource.ListNameAlreadyExist;
                    }
                }
                catch (Exception ex)
                {
                    response.StatusCode = StaticResource.failStatusCode;
                    response.Message    = StaticResource.SomethingWrong + ex.Message;
                }
            }
            else if (request != null && string.IsNullOrWhiteSpace(request.SectorName)) //check for emptystring
            {
                response.StatusCode = StaticResource.notValid;
                response.Message    = StaticResource.validData;
            }
            else if (request == null)
            {
                response.StatusCode = StaticResource.NameAlreadyExist;
            }
            return(response);
        }