private ResourceYield CreateRandomResourceYield(ResourceCategory resCategory, SystemDesirability desirability) {
        float minYield;
        float maxYield;
        int minNumberOfResources;
        switch (resCategory) {
            case ResourceCategory.Common:
                switch (desirability) {
                    case SystemDesirability.Desirable:
                        minNumberOfResources = 2;
                        minYield = 1F;
                        maxYield = 5F;
                        break;
                    case SystemDesirability.Normal:
                        minNumberOfResources = 1;
                        minYield = 1F;
                        maxYield = 4F;
                        break;
                    case SystemDesirability.Challenged:
                        minNumberOfResources = 1;
                        minYield = 0F;
                        maxYield = 3F;
                        break;
                    case SystemDesirability.None:
                    default:
                        throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(desirability));
                }
                break;
            case ResourceCategory.Strategic:
                switch (desirability) {
                    case SystemDesirability.Desirable:
                        minNumberOfResources = 1;
                        minYield = 1F;
                        maxYield = 3F;
                        break;
                    case SystemDesirability.Normal:
                        minNumberOfResources = 0;
                        minYield = 1F;
                        maxYield = 2F;
                        break;
                    case SystemDesirability.Challenged:
                        minNumberOfResources = 0;
                        minYield = 0F;
                        maxYield = 2F;
                        break;
                    case SystemDesirability.None:
                    default:
                        throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(desirability));
                }
                break;
            case ResourceCategory.Luxury:   // No Luxury Resources yet
            case ResourceCategory.None:
            default:
                throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(resCategory));
        }

        var categoryResources = Enums<ResourceID>.GetValues(excludeDefault: true).Where(res => res.GetResourceCategory() == resCategory);
        int categoryResourceCount = categoryResources.Count();
        D.Assert(categoryResourceCount > minNumberOfResources);
        int numberOfResourcesToCreate = RandomExtended.Range(minNumberOfResources, categoryResourceCount);

        IList<ResourceYield.ResourceValuePair> resValuePairs = new List<ResourceYield.ResourceValuePair>(numberOfResourcesToCreate);
        var resourcesChosen = categoryResources.Shuffle().Take(numberOfResourcesToCreate);
        resourcesChosen.ForAll(resID => {
            var rvp = new ResourceYield.ResourceValuePair(resID, UnityEngine.Random.Range(minYield, maxYield));
            resValuePairs.Add(rvp);
        });
        return new ResourceYield(resValuePairs.ToArray());
    }
示例#2
0
 //TODO Acquire resource values this starbase has access too, ala SettlementCmdData approach
 private void __PopulateResourcesFromSector() {
     Capacity = 10;
     var resources = new ResourceYield.ResourceValuePair[] {
         new ResourceYield.ResourceValuePair(ResourceID.Organics, 0.3F),
         new ResourceYield.ResourceValuePair(ResourceID.Particulates, 0.5F),
         new ResourceYield.ResourceValuePair(ResourceID.Energy, 1.2F),
         new ResourceYield.ResourceValuePair(ResourceID.Titanium, 0.5F),
         new ResourceYield.ResourceValuePair(ResourceID.Duranium, 1.1F),
         new ResourceYield.ResourceValuePair(ResourceID.Unobtanium, 0.1F)
     };
     Resources = new ResourceYield(resources);
 }
示例#3
0
    private ResourceYield CreateRandomResourceYield(ResourceCategory resCategory) {
        float maxYield = Constants.OneF;
        int minNumberOfResources = Constants.Zero;
        switch (resCategory) {
            case ResourceCategory.Common:
                minNumberOfResources = Constants.One;
                maxYield = 5F;
                break;
            case ResourceCategory.Strategic:
                maxYield = 2F;
                break;
            case ResourceCategory.Luxury:   // No Luxury Resources yet
            case ResourceCategory.None:
            default:
                throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(resCategory));
        }

        var categoryResources = Enums<ResourceID>.GetValues(excludeDefault: true).Where(res => res.GetResourceCategory() == resCategory);
        int categoryResourceCount = categoryResources.Count();
        int numberOfResourcesToCreate = RandomExtended.Range(minNumberOfResources, categoryResourceCount);

        IList<ResourceYield.ResourceValuePair> resValuePairs = new List<ResourceYield.ResourceValuePair>(numberOfResourcesToCreate);
        var resourcesChosen = categoryResources.Shuffle().Take(numberOfResourcesToCreate);
        resourcesChosen.ForAll(resID => {
            var rvp = new ResourceYield.ResourceValuePair(resID, UnityEngine.Random.Range(Constants.ZeroF, maxYield));
            resValuePairs.Add(rvp);
        });
        return new ResourceYield(resValuePairs.ToArray());
    }