public void ActivateXpPanel() { int currentLevel = XPManager.CalculateLevel(xpBeforeGame, XPManager.MAP_XP_BOUNDARIES); DisplayMapTeaser(currentLevel); XpPanel.SetActive(true); mapLevel.OnDone += OnMapLevelUpDone; mapLevel.OnLevelUp += DisplayMapTeaser; if (xpBeforeGame < XPManager.MAP_LEVEL_CAP) { Invoke("OnXpPanelActive", 0.4f); } else { OnMapLevelUpDone(); } currentLevel = XPManager.CalculateLevel(xpBeforeGame, XPManager.SKIN_XP_BOUNDARIES); DisplaySkinTeaser(currentLevel); }
// Start is called before the first frame update void Start() { switch (progressionType) { case XpTypes.Maps: boundary = XPManager.MAP_XP_BOUNDARIES; break; case XpTypes.Skins: boundary = XPManager.SKIN_XP_BOUNDARIES; break; } int level = XPManager.CalculateLevel(XPManager.GetStoredXP(), boundary); for (int i = 0; i < progression.Length; ++i) { progression[i].item.gameObject.SetActive(level >= i); if (progression[i].lockedPlaceholder != null) { progression[i].lockedPlaceholder.gameObject.SetActive(level < i); } } }
IEnumerator LevelUp(int starting, int ending, int boundaries, int maxXP) { rootObject.transform.localPosition = new Vector3(2000, rootObject.transform.localPosition.y, rootObject.transform.localPosition.z); LeanTween.moveLocal(rootObject, Vector3.zero, 0.5f); yield return(new WaitForSeconds(0.6f)); yield return(null); int endLevel = XPManager.CalculateLevel(ending, boundaries); int maxLevel = XPManager.CalculateLevel(maxXP, boundaries); if (endLevel >= maxLevel) { endLevel = maxLevel - 1; } int curXP = starting; int level; do { level = XPManager.CalculateLevel(curXP, boundaries); int b = level * boundaries + boundaries - 1; int target = Mathf.Min(b, ending); float sliderTarget = (float)(target % boundaries) / (float)boundaries * 100; barAudio.Play(); float waitTime = Mathf.Max(0.2f, (sliderTarget - xpSlider.value) / speed); LeanTween.value(gameObject, SetSliderValue, xpSlider.value, sliderTarget, waitTime / 2f); yield return(new WaitForSeconds(waitTime / 2)); barAudio.Pause(); if (target != ending) { //LEVEL UP if (levelupSpawn != null) { Instantiate(levelupSpawn); } yield return(new WaitForSeconds(levelupPause)); if (OnLevelUp != null) { OnLevelUp(level + 1); } ++target; } if (ending > target) { xpSlider.value = 0; } curXP = target; } while (level != endLevel); yield return(new WaitForSeconds(1f)); Vector3 targetPos = new Vector3(-2500, rootObject.transform.localPosition.y, rootObject.transform.localPosition.z); LeanTween.moveLocal(rootObject, targetPos, 0.5f).setEaseInBack(); yield return(new WaitForSeconds(0.5f)); if (OnDone != null) { OnDone(); } rootObject.SetActive(false); }