public void depositResource(ResourceAmount resourceAmount) { var currentResourceAmount = resourceStorage.get(resourceAmount.resourceEnum); currentResourceAmount.amount += resourceAmount.amount; resourceStorage.set(currentResourceAmount); InfoPopupController.Create(infoPopupPrefab, Utils.getTopPosition(transform, HEIGHT, 0.2f), "+" + resourceAmount.amount); }
private void Update() { Utils.waitAndDo(createHuman, countdownBeforeCreateHuman, countdownBeforeCreateHumanDuration, doCreateHuman); if (resourceStorage.get(ResourceEnum.WOOD).amount >= 10 && !countdownBeforeCreateHuman.isCountingDown) { InfoPopupController.Create(infoPopupPrefab, Utils.getTopPosition(transform, HEIGHT, 0.7f), "Création d'un humain"); var currentResourceAmount = resourceStorage.get(ResourceEnum.WOOD); currentResourceAmount.amount -= 10; resourceStorage.set(currentResourceAmount); doCreateHuman = true; } Utils.waitAndDo(() => { spriteRenderer.sprite = door_close; }, countdownKeepDoorOpen, countdownKeepDoorOpenDuration, spriteRenderer.sprite == door_open); }
public ResourceAmount RetrieveResourceAmount() { if (_currentTreeState != TreeStateEnum.FULL) { throw new Exception("Trying to cut a Berry Tree not full"); } var resourceAmountToRetrieve = resourceAmount.copy(); resourceAmount = new ResourceAmount(0, ResourceEnum.FOOD); setCurrentState(TreeStateEnum.CUT); spriteRenderer.sprite = berryEmpty; InfoPopupController.Create(infoPopupPrefab, Utils.getTopPosition(transform, HEIGHT, 0.2f), "-" + resourceAmountToRetrieve.amount); return(resourceAmountToRetrieve); }
private void depositFoodInto(TownHall townHallController) { void depositResource() { humanAnimationController.isDoing = false; var resourceAmount = humanController.humanResourceController.resourceStorage.get(ResourceEnum.FOOD); townHallController.depositResource(resourceAmount); humanController.humanResourceController.resourceStorage.set(new ResourceAmount(0, ResourceEnum.FOOD)); InfoPopupController.Create(humanController.infoPopupPrefab, humanMovementController.getTopPosition(0.2f), "-" + resourceAmount.amount); } humanAnimationController.isDoing = true; Utils.waitAndDo(depositResource, timeToDepositCountdown, durationTimeToDeposit, true); }
private void cutBerryTree(BerryTreeController berryTreeController) { void getResource() { humanAnimationController.isDoing = false; berryTreeController.setWhoIsCurrentlyCutting(null); currentlyCuttingBerryTree = null; var resourceAmount = berryTreeController.RetrieveResourceAmount(); humanController.humanResourceController.resourceStorage.set(resourceAmount); InfoPopupController.Create(humanController.infoPopupPrefab, humanMovementController.getTopPosition(0.2f), "+" + resourceAmount.amount); } humanAnimationController.isDoing = true; berryTreeController.setWhoIsCurrentlyCutting(this); currentlyCuttingBerryTree = berryTreeController; Utils.waitAndDo(getResource, timeToGatherCountdown, durationTimeToGather, true); }