1
This commit is contained in:
32
unity/Assets/Script/UI/UILevel.cs
Normal file
32
unity/Assets/Script/UI/UILevel.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public class UILevel : MonoBehaviour
|
||||
{
|
||||
public Text level;
|
||||
public Scrollbar exp;
|
||||
float needExp;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
PlayerInfo.Instance.OnUpdateLevel += UpdateLevel;
|
||||
UpdateLevel();
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
PlayerInfo.Instance.OnUpdateLevel -= UpdateLevel;
|
||||
}
|
||||
public void UpdateLevel()
|
||||
{
|
||||
needExp = PlayerInfo.Instance.NeedExp();
|
||||
level.text = "Lv " + PlayerInfo.Instance.info.Level.ToString();
|
||||
|
||||
exp.size = (float)PlayerInfo.Instance.info.exp / needExp;
|
||||
if(exp.size==1)
|
||||
{
|
||||
needExp = PlayerInfo.Instance.NeedExp();
|
||||
exp.size = PlayerInfo.Instance.info.exp / needExp;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user