private void OnChangedCurrency(int newValue, int oldValue, CurrencyTypes currencyType) { if (_identifyButton == null || currencyType != CurrencyTypes.SCROLLS_IDENTIFY) { return; } _currentLootCrateItem.UpdateIdentifiedIcon(); _identifyButton.SetEnabledState(false); }
public void Initialize(LootCrate crate, System.Action callback = null, System.Action callbackOnComplete = null, bool fromStory = false) { this.crate = crate; List <Item> items = crate.GenerateItems(); this.callbackOnComplete = callbackOnComplete; noMenuManagerRef = fromStory; Debug.Log("Adding " + items.Count + " items."); /* * foreach(Item i in items) { * Debug.Log(" --- --- [Item] " + i.Name); * }*/ // NOTE-TO-SELF: DO call this API method! (Instead of one-by-one, batch-calls adds all generated items) API.Items.AddMany(items) .Catch(err => traceError("Something went wrong while adding newly generated items to server-side: " + err.Message)); //.Then(res => trace("Added " + items.Count + " items server-side...")) DataManager.Instance.allItemsList.AddRange(items); if (!fromStory) { RemoveCrateFromPlayerData(callback); } // Crate Sequence TimelineTween.Create( (next) => { AudioManager.Instance.Play(SFX_UI.Earthquake); //btnGoBack.transform.DOScale(Vector2.zero, 0.5f * speedScale); btnGoBack.GetComponent <RectTransform>().DOAnchorPosY(0f, 0.5f * speedScale); crateBtn.transform.SetParent(this.transform); // Background Shadow here backgroundShadow.DOColor(new Color(0f, 0f, 0f, 0.7f), timeScrollerSlides * speedScale); crateBtn.transform.TweenMoveByY(50, timeScrollerSlides * speedScale) .SetEase(Ease.InOutSine) .OnComplete(() => next()); }, (next) => { // If on crate screen reset the crate list positions crateBtn.transform .DOShakePosition(timeCrateShake * speedScale, 10, 30, 90, false, false) .OnComplete(() => next()); }, (next) => { AudioManager.Instance.Stop(SFX_UI.Earthquake); AudioManager.Instance.Play(SFX_UI.Explosion); GameObject itemPrefab = GetPrefab("SubItems/LootCrateItem"); var canvasSize = GetScreenSize(); float itemSize = canvasSize.x / 3f; for (int i = 0; i < items.Count; i++) { Item itemData = items[i]; GameObject itemGO = GameObject.Instantiate(itemPrefab); LootCrateItem item = itemGO.GetComponent <LootCrateItem>(); Button itemBtn = itemGO.GetComponent <Button>(); TextMeshProUGUI itemLabel = itemGO.GetComponentInChildren <TextMeshProUGUI>(); RectTransform itemTrans = (RectTransform)itemGO.transform; itemTrans.SetParent(this.transform); itemTrans.localPosition = Vector2.zero; itemTrans.SetWidthAndHeight(itemSize); item.itemData = itemData; item.UpdateIdentifiedIcon(); _crateItems.Add(item); itemBtn.onClick.AddListener(() => BtnOnItemClick(item, fromStory)); } LayoutUpdate(); TimelineTween.Scatter(0.08f, _crateItems, (item, id) => { return(TimelineTween.Pulsate(item.transform, 1.3f, timeItemsExplode * speedScale)); }); Color c = crateBtn.GetComponent <Image>().color; c.a = 0; crateBtn.GetComponent <Image>().DOColor(c, 0.3f).OnComplete(() => { Destroy(crateBtn.gameObject); }); /*CanvasGroup cg = crateBtn.GetComponent<CanvasGroup>(); * cg.DOFade(0, 0.3f) * .OnComplete(() => { * Destroy(crateBtn.gameObject); * });*/ crateBtn.transform .DOScale(2.0f, timeCrateExplode * speedScale) .SetEase(Ease.OutQuint); this.Wait(timeItemsExplode * 2.0f * speedScale, next); }, (next) => { TimelineTween.Scatter(0.1f, _crateItems, (item, id) => { return(item.filler.DOFade(0, 1 * speedScale)); }); this.Wait(timeItemsFormCircle * 1.0f * speedScale, next); } ); }