public void BtnAction_Summon(SummonButtonContainer summonChoice) { if (!GameManager.Instance.isSummonComplete) { return; } _currentChoice = summonChoice; _summonButtons.ForEach(choice => choice.btn.interactable = false); try { GameManager.Instance.SummonHeroAction(summonChoice.summonType, OnSummonComplete); } catch (Exception err) { TimelineTween.ShakeError(_currentChoice.gameObject); AudioManager.Instance.Play(SFX_UI.Invalid); traceError("Error summoning hero: " + err.Message); traceError(err); OnSummonComplete(null); GameManager.Instance.isSummonComplete = true; } }
// Use this for initialization void Start() { foreach (var kv in scrollsSprite) { CurrencyTypes currency = kv.Key; SummonInfo info = kv.Value; SummonButtonContainer summonChoice = this.Clone <SummonButtonContainer>(BtnSummonTemplate); summonChoice.btn.onClick.AddListener(() => BtnAction_Summon(summonChoice)); summonChoice.label.text = info.label + " SUMMON"; summonChoice.icon.sprite = info.sprite; summonChoice.currency = currency; summonChoice.summonType = CurrencyManager.ConvertCurrencyToSummonType(currency); summonChoice.UpdateCounter(); _summonButtons.Add(summonChoice); } BtnSummonTemplate.SetActive(false); PlayerManager.signals.OnChangedCurrency += OnChangedCurrency; }