// Use this for initialization void Start() { Debug.Log("in PopulationManager start"); homeless = population; workforce = (int)(population * workforcePercentage); employed = 0; unfilledWorkerRequests = 0; startTile = new IntPoint2D(citizenEntryX, citizenEntryY); houseCollection = new Dictionary <IntPoint2D, HouseManager> (); homelessCollection = new Queue <CitizenManager> (); walkerPool = gameObject.GetComponent("WalkerPool") as WalkerPool; ScenarioMgr scenMgr = gameObject.GetComponent("ScenarioMgr") as ScenarioMgr; scenario = scenMgr.GetInfo(); StartCoroutine("InitPopulation"); }
private IEnumerator StartRetrieval() { GameObject gameController = GameObject.FindWithTag("GameController"); ScenarioMgr scenarioMgr = gameController.GetComponent("ScenarioMgr") as ScenarioMgr; ScenarioData scenarioInfo = scenarioMgr.GetInfo(); // first lets find the possible places to go GameObject[] stores = GameObject.FindGameObjectsWithTag("Store"); if (stores.Length > 0) { //Debug.Log("found some stores"); List <IntPoint2D> startTiles = scenarioInfo.GetAdjacentRoadTiles(myData.GetLoc()); List <IntPoint2D> endTiles; //bestPath;// = new Stack<IntPoint2D>(); StoreManager bestmgr = null; foreach (GameObject store in stores) { // get the store manager StoreManager mgr = store.GetComponent("StoreManager") as StoreManager; // see if there's available capacity if (mgr.GetGoodsAmt() > 0) { // get adjacent roads endTiles = scenarioInfo.GetAdjacentRoadTiles(mgr.GetLoc()); Stack <IntPoint2D> path = scenarioInfo.ShortestPath(startTiles, endTiles); if (path.Count > 0 && (bestPath.Count == 0 || path.Count < bestPath.Count)) { bestPath = path; bestmgr = mgr; } } yield return(null); } gettingResource2 = false; if (bestPath.Count > 0) { IntPoint2D start = bestPath.Pop(); GetGoods(start, bestPath, bestmgr, scenarioInfo); gettingResource2 = true; } } yield return(null); }