コード例 #1
0
    public void CreatePromo(CropAssets targetCrop, float multiplier)
    {
        ResetCrop();

        bannerImage.gameObject.SetActive(true);
        targetCrop.priceMultiplier = multiplier;
        int percentChange = Mathf.Abs(Mathf.RoundToInt((multiplier - 1f) * 100f));

        if (multiplier > 1.0f)
        {
            if (notifManager == null)
            {
                notifManager = (UI_TextNotif)FindObjectOfType(typeof(UI_TextNotif));
            }
            notifManager.Notify("Monthly Promo: " + percentChange.ToString() +
                                "% Markup for", targetCrop.cropSprite);
            bannerImage.sprite = overpriceBanner;
            bannerText.text    = percentChange.ToString() + "% Markup";
        }
        else if (multiplier < 1.0f)
        {
            if (notifManager == null)
            {
                notifManager = (UI_TextNotif)FindObjectOfType(typeof(UI_TextNotif));
            }
            notifManager.Notify("Monthly Promo: " + percentChange.ToString() +
                                "% Off for", targetCrop.cropSprite);
            bannerImage.sprite = saleBanner;
            bannerText.text    = percentChange.ToString() + "% Off";
        }
        else
        {
            promoCooldown = 4;
            bannerImage.gameObject.SetActive(false);
            UpdateShop();
            return;
        }
        itemImage.sprite = targetCrop.cropSprite;
        promoCooldown    = 4;
        UpdateShop();
    }
コード例 #2
0
 private void HarvestCrop()
 {
     if (this.overlayObj != null && crop != null && crop.HasCrop())
     {
         float moneyReceive = crop.CalculateCost();
         if (notifManager == null)
         {
             notifManager = (UI_TextNotif)FindObjectOfType(typeof(UI_TextNotif));
         }
         notifManager.Notify("Got $ " + moneyReceive + " from selling ", crop.asset.cropSprite);
         PlayerManager.Instance.AddMoney(moneyReceive);
         //Destroy(this.overlayObj);
         crop = new Crop(null);
         this.overlayObj.GetComponent <SpriteRenderer>().sprite = null;
         SoundManager.Instance.sfxManager.PlayFromSFXObjectLibrary("Sell");
     }
 }