public void GatherResources() { HashSet <PlayerIdentity> remainingIdentities = new HashSet <PlayerIdentity>(FindObjectsOfType <PlayerIdentity>()); foreach (KeyValuePair <int, HashSet <int> > entry in dependencyMap.Where(e => e.Key >= 0 && e.Key != PlayerIdentity.LocalInstance.id)) { PlayerIdentity identity = PlayerIdentity.FindById(entry.Key); remainingIdentities.Remove(identity); identity.TransferResources(); } foreach (PlayerIdentity identity in remainingIdentities) { identity.ready = true; identity.transferProgress = 1f; identity.LocalRobotFileCount = Directory.GetFiles(identity.RobotFolder).Length; } }
public void DistributeResources() { foreach (PlayerIdentity identity in FindObjectsOfType <PlayerIdentity>()) { if (dependants.Contains(identity.id)) { identity.transferProgress = 0f; } else { identity.transferProgress = 1f; identity.ready = true; } } foreach (KeyValuePair <int, HashSet <int> > entry in dependencyMap.Where(e => e.Key >= 0)) { PlayerIdentity hostIdentity = PlayerIdentity.FindById(entry.Key); foreach (PlayerIdentity dependant in FindObjectsOfType <PlayerIdentity>() .Where(p => entry.Value.Contains(p.id))) { dependant.dependencyCount += hostIdentity.LocalRobotFileCount; } } if (dependencyMap.ContainsKey(-1)) { DistributeField(dependencyMap[-1]); } foreach (KeyValuePair <int, HashSet <int> > entry in dependencyMap.Where(e => e.Key >= 0)) { PlayerIdentity.FindById(entry.Key).DistributeResources(entry.Value); } }