private void doWork(Work nextAiWork) { //Debug.Log("Updating ai resource display"); //foreach (ResourceType rt in aiCurrentGameState.getAllResourceTypes()) //{ // Debug.Log("RT: " + rt + ", " + aiCurrentGameState.getStockpile(rt)); // aiResourceDisplay.updateCountAndRPT(rt, aiCurrentGameState.getStockpile(rt), aiCurrentGameState.getChangePerTick(rt)); //} Debug.Log("Doing work: " + nextAiWork.workType); switch (nextAiWork.workType) { case EWork.BuildBuilding: startBuildBuilding(BuildingFactory.buildNew(nextAiWork.buildingType, -1, -1), nextAiWork.frameWait); break; case EWork.BuyAndAssignWorker: Debug.Log("Worker for: " + nextAiWork.buildingType); if (aiCurrentGameState.canBuyWorker()) { Debug.Log("can buy worker"); aiCurrentGameState.buyAndAssignWorker(nextAiWork.buildingType); aiResourceDisplay.workerAssigned(); aiResourceDisplay.addTotalWorker(); switch (nextAiWork.buildingType) { case BuildingType.Bank: bank++; break; case BuildingType.SilverMine: silver++; break; case BuildingType.StoneMason: stone++; break; case BuildingType.WoodCutter: wood++; break; } } else { Debug.Log("cannot buy worker"); } doNextWorkAi(); break; case EWork.Wait: StartCoroutine(aiWait(nextAiWork.frameWait)); break; default: doNextWorkAi(); break; } }
////////////////////////////////////////////////// public static QGameState buyWorker(QGameState qGS, BuildingType bt) { BuildingGS newGameState = waitGameState(qGS.gameState, 1); newGameState.buyAndAssignWorker(bt); int costToGetHere = qGS.costToGetHere + 3; Work newWork = new Work(EWork.BuyAndAssignWorker, bt, 3); return(new QGameState(newGameState, qGS, newWork, costToGetHere)); }