public void SetQuest(ActiveQuestBase currentQuest) { RemoveListeners(previous); if (currentQuest is ActiveWalkingQuest) { ActiveWalkingQuest awq = currentQuest as ActiveWalkingQuest; awq.AmountSoFar.OnChange.AddListener(OnChange); } else if (currentQuest is ActiveQuest <int, IntVariable, UnityEventInt> ) { ActiveQuest <int, IntVariable, UnityEventInt> awq = currentQuest as ActiveQuest <int, IntVariable, UnityEventInt>; awq.AmountSoFar.OnChange.AddListener(OnChange); } else if (currentQuest is ReachValueQuest) { var awq = currentQuest as ReachValueQuest; awq.TotalAmount.OnChange.AddListener(OnChange); } var prog = currentQuest.GetProgress(); ProgressText.text = $"{prog.current} / {prog.max}"; ProgressFill.rectTransform.anchorMax = ProgressFill.rectTransform.anchorMax.SetX(Mathf.Clamp01((float)(prog.current / prog.max))); QuestTitle.text = currentQuest.DisplayName; previous = currentQuest; }
void OnChange(int val) { if (prevVal != -1 && val > prevVal) { SmoothPopUpManager.ShowPopUp(SpawnPointOfNumberIncreasePopUp.position, "+" + (val - prevVal), Color.green, true); } prevVal = val; var prog = previous.GetProgress(); ProgressText.text = $"{prog.current} / {prog.max}"; ProgressFill.rectTransform.anchorMax = ProgressFill.rectTransform.anchorMax.SetX(Mathf.Clamp01((float)(prog.current / prog.max))); }