public void ShowAffectedHexes() { if (selectedUnit == null) { return; } ITileAffector affector = selectedUnit.GetComponent <ITileAffector>(); if (affector == null) { return; } RemoveAllHexes(HexMode.AFFECTED); List <Key> affectedTiles = affector.GetAffectedTiles(currentHoveredHex); foreach (Key hexPosition in affectedTiles) { Key key = new Key(hexPosition.x, hexPosition.y); Hex hex; if (grid.TryGetValue(key, out hex)) { hex.SetHexMode(HexMode.AFFECTED); } } }
public void CheckCropNeeds() { // Clear all needs first foreach (Hex cropHex in cropHexes) { cropHex.crop.ResetNeeds(); } // Go through all workers and add resources to crop foreach (Worker worker in workers) { // Don't bother if not deployed if (worker.hex == null) { continue; } // Some workers might not affect tiles ITileAffector affector = worker.GetComponent <ITileAffector>(); if (affector == null) { continue; } List <Key> affectedTiles = affector.GetAffectedTiles(worker.hex); foreach (Key hexPosition in affectedTiles) { Key key = new Key(hexPosition.x, hexPosition.y); Hex hex; if (grid.TryGetValue(key, out hex)) { Crop crop = hex.crop; // If crop exists in hex, apply resources if (crop != null) { crop.ApplyResources(worker.GetComponent <ResourceProducer>().GetProductionMap()); } } } } }