/// <summary> /// Creates a new GridResourceNode with resources that are scaled to the complexity of the /// node's tags. /// </summary> public static GridResourceNode New(int maximumTagSize, int minResources, int maxResources) { if (maximumTagSize <= 0) throw new ArgumentOutOfRangeException("maximumTagSize"); if (minResources < 0) throw new ArgumentOutOfRangeException("minResources"); if (maxResources < minResources) throw new ArgumentOutOfRangeException("maxResources", "maxResources cannot be less than minResources"); var grn = new GridResourceNode(maximumTagSize); int resourceRange = maxResources - minResources; double maxStrength = (maximumTagSize / 3.0) + maximumTagSize; // Offense tag counts for 1/3 strength int nodeSize = (int)((double)(grn.Strength / maxStrength) * resourceRange) + minResources; var resources = new List<Resource>(); for (int j = 0; j < nodeSize; j++) { resources.Add(Resource.Random(false)); } grn.RenewableResources.AddRange(resources); grn.RefreshReservoir(); return grn; }
public static GridResourceNode New(List<Resource> resources, int maximumTagSize) { var grn = new GridResourceNode(maximumTagSize); grn.RenewableResources.AddRange(resources); grn.RefreshReservoir(); return grn; }