public void Transfer(ResourceContainer _targetResourceContainer) { foreach (KeyValuePair <string, int> kvp in Resources) { _targetResourceContainer.Add(kvp.Key, kvp.Value); } }
private void BuildOnTile(BuildData buildData) { if (ActivityEnergy >= 50f) { ConsumeEnergy(50f); var provider = mapController.BuildOnTile(CurrentGridLocation, CharacterGuid, CharacterColor); resources.Add(provider); } }
void Start() { this.container = this.GetComponent <ResourceContainer> (); var initialStock = this.minInitialStock; if (this.minInitialStock != this.maxInitialStock) { initialStock = this.minInitialStock + Random.Range(0, this.maxInitialStock - this.minInitialStock); } container.Add(this.resourceType, initialStock); }
private void OnTick(object sender, float e) { if (CurrentType == TileType.Resource) { if (Resources < 100) { // regenerate some resources Resources += Rate; // get the number of harvesters and remove one for each // harvester. float harvesters = OnResource.GetInvocationList().Length; Resources -= (harvesters - 1); // send one resource to each harvester OnResource.Invoke(this, 1f); } } ; UpdateVisualMode(); // if this is currently a city tile and there are less than // 4 providers, try to get more. if (myTile is City city) { OnResource.Invoke(this, 50f); if (providers.Length < 4) { var x = city.xPos; var y = city.yPos; var neighbors = controller.GetNeighbors(x, y, city.Owner); foreach (var neighbor in neighbors) { // doesn't add if it is already in there providers.Add(neighbor); } } Resources -= 2; if (Resources <= 0) { Change(TileType.Resource); } } }