// Convert XXX Pollen (should be Nectar, but unimplemented) to YYY Honey // and WWW Water + ZZZ Pollen to RoyalJelly private ResourceSet refineResources(Cell.RefinedResource what) { var res = new ResourceSet(); // Ensure the player has all the due resources. bool refiningRJ = (what & Cell.RefinedResource.RoyalJelly) != 0, refiningHoney = (what & Cell.RefinedResource.Honey) != 0; int pollen = rm.GetResource(ResourceType.Pollen), water = rm.GetResource(ResourceType.Water); if (refiningHoney && pollen >= PollenForHoney && water >= WaterForHoney) { rm.RemoveResource(ResourceType.Pollen, PollenForHoney); rm.RemoveResource(ResourceType.Water, WaterForHoney); res += new ResourceSet().With(ResourceType.Honey, RefinedHoneyYield); } if (refiningRJ && pollen >= PollenForRoyalJelly && water >= WaterForRoyalJelly) { rm.RemoveResource(ResourceType.Pollen, PollenForRoyalJelly); rm.RemoveResource(ResourceType.Water, WaterForRoyalJelly); res += new ResourceSet().With(ResourceType.RoyalJelly, RefinedRoyalJellyYield); } return res; }
public override Status Process() { ActivateIfInactive(); timeFromLastTheft += Time.deltaTime; if (warehouse.IsEmpty) { status = Status.Completed; } else if (timeFromLastTheft >= stats.LoadTime) { ResourceSet toSteal = new ResourceSet() .With(ResourceType.Beeswax, 10) .With(ResourceType.Honey, 5) .With(ResourceType.Nectar, 10) .With(ResourceType.Pollen, 10) .With(ResourceType.RoyalJelly, 2) .With(ResourceType.Water, 10); warehouse.RemoveResources(toSteal); if (!warningGiven) { TextController.Instance.Add("Your resources are being stolen!"); SoundEffects.Instance.Play(SoundEffects.Sound.Attacked); warningGiven = true; } timeFromLastTheft = 0.0f; } return status; }
public static ResourceSet operator -(ResourceSet rs1, ResourceSet rs2) { ResourceSet result = new ResourceSet(); foreach (ResourceType type in Enum.GetValues(typeof(ResourceType))) { result[type] = Mathf.Max(0, rs1[type] - rs2[type]); } return result; }
public static ResourceSet operator *(ResourceSet rs1, float mult) { ResourceSet result = new ResourceSet(); foreach (ResourceType type in Enum.GetValues(typeof(ResourceType))) { result[type] = (int)(rs1[type] * mult); } return result; }
public override Status Process() { ActivateIfInactive(); timeFromLastExtraction += Time.deltaTime; if (load.IsFull) { status = Status.Completed; } else if (yielder.IsDepleted) { status = Status.Failed; } else if (timeFromLastExtraction > stats.LoadTime) { ResourceSet requestAmount = new ResourceSet() .With(ResourceType.Nectar, yielder.defaultNectarYield) .With(ResourceType.Pollen, yielder.defaultPollenYield) .With(ResourceType.Water, yielder.defaultWaterYield) .With(ResourceType.Beeswax, yielder.defaultBeeswaxYield) .With(ResourceType.Honey, yielder.defaultHoneyYield) .With(ResourceType.RoyalJelly, yielder.defaultRoyalJellyYield); ResourceSet result = yielder.Yield(requestAmount); if (result.IsEmpty()) { return Status.Failed; } load.AddResources(result); if (agent.GetComponent<Selectable>().IsSelected) UIController.Instance.SetBeeLoadText(agent); timeFromLastExtraction = 0.0f; if (ResourceExtracted != null) { ResourceExtracted(agent, yielder.gameObject); } } return status; }
void Start() { Load = new ResourceSet(); stats = gameObject.GetComponent<Stats>(); }
public void AddResources(ResourceSet amount) { Load += amount; }
void Start() { Load = new ResourceSet(); stats = gameObject.GetComponent <Stats>(); }
public void RemoveResources(ResourceSet resources) { rm.RemoveResources(resources); }
public void AddResources(ResourceSet resources) { rm.AddResources(resources); }