// called when honeyEmptyButton is clicked (honeyFullImage has Raycast Target disabled) public void OnUnitClick() { // TODO sound // if foggy background is active, change the the unit that is clicked on if (!gameManager.foggyBackground.activeSelf) { // if unit is being bought if (!isActivated) { // then the empty sprite is being displayed //Debug.Log(this.name + " has not been activated"); // TODO if enough money, buy if (honeyCurrency.currency >= COMB_PRICE) { honeyCurrency.ChangeCurrencyValue(-1 * COMB_PRICE); honeyEmpty.sprite = Resources.Load <Sprite>("Sprites/" + honeyFull.sprite.name + "Empty"); isActivated = true; gameManager.DisplayUnpurchasedHoney(); } else { gameManager.ActivateInfoText("Not enough money"); } } // if unit is being harvested else if (!isEmpty) { //Debug.Log("HARVEST"); isEmpty = true; fullForTime = 0f; honeyFull.enabled = false; honeyScore.ChangeHarvestedHoneyValue(1); honeyCurrency.ChangeCurrencyValue(points); pushSound.Play(); } else if (isEmpty) { //Debug.Log("Unit is empty"); } } else if (gameManager.foggyBackground.activeSelf && isActivated) { if (honeyCurrency.currency >= gameManager.currentPrice) { // make so that color cannot be bought if unit is already of this color if (honeyFull.sprite != gameManager.currentSprite) { // for undo gameManager.lastUnitUpgraded = this; gameManager.lastSprite = honeyFull.sprite; gameManager.lastTransparentSprite = honeyEmpty.sprite; gameManager.lastPrice = price; gameManager.lastTime = fillTime; gameManager.lastPoints = points; gameManager.foggyUndoButton.interactable = true; // activate the undo button // then honey color is being changed honeyFull.sprite = gameManager.currentSprite; honeyEmpty.sprite = gameManager.currentTransparentSprite; fillTime = gameManager.currentTime; // TODO change for time, not price points = gameManager.currentPoints; price = gameManager.currentPrice; // reset filling time isEmpty = true; fullForTime = 0f; honeyFull.enabled = false; // decrease honeycurrency honeyCurrency.ChangeCurrencyValue(-1 * (int)gameManager.currentPrice); } else { Debug.Log("ABORT: you have already bought this"); } } else { // not enough harvested honey to buy this color gameManager.ActivateInfoText("Not enough money"); } } // save data if dataController is being used (used when going through mainmenu scene first) if (dataController != null) { dataController.SaveData(this.name); } }