using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class GatherSoulItemBehaviour : MonoBehaviour
|
{
|
[SerializeField] Button m_Func;
|
[SerializeField] Image m_IconBG;
|
[SerializeField] Image m_Icon;
|
[SerializeField] ScaleTween m_IconTween;
|
[SerializeField] Text m_Level;
|
[SerializeField] Slider m_ExpSlider;
|
[SerializeField] Text m_Count;
|
[SerializeField] Image m_Redpoint;
|
|
|
GatheringSoulModel model
|
{
|
get { return ModelCenter.Instance.GetModel<GatheringSoulModel>(); }
|
}
|
|
int m_SoulID;
|
|
|
private void Awake()
|
{
|
if (m_Func != null)
|
{
|
m_Func.AddListener(OnFunc);
|
}
|
}
|
|
|
public void Display(int soulID)
|
{
|
m_SoulID = soulID;
|
var config = GatherTheSoulConfig.Get(soulID);
|
if (config == null)
|
{
|
return;
|
}
|
|
if (config.HoleNum == model.selectEmptyHole && Time.time - model.selectSoulTime < 0.1)
|
{
|
m_IconTween.Play();
|
}
|
|
m_Icon.SetSprite(string.Format("FuncSoul_{0}", soulID));
|
m_IconBG.SetItemBackGround(config.SoulColor);
|
m_Level.text = Language.Get("PlayerDetail_Level", model.GetSoulLevel(soulID));
|
var nextLVConfig = GatherTheSoulLVConfig.GetSoulLVConfig(soulID, model.GetSoulLevel(soulID) + 1);
|
if (nextLVConfig == null)
|
{
|
m_ExpSlider.SetActive(false);
|
m_Redpoint.SetActive(false);
|
}
|
else
|
{
|
m_ExpSlider.SetActive(true);
|
var itemCount = model.GetSoulItemCount(soulID);
|
m_ExpSlider.value = model.GetSoulItemCount(soulID) / (float)nextLVConfig.NeedPiece;
|
m_Count.text = string.Format("{0}/{1}", itemCount, nextLVConfig.NeedPiece);
|
|
m_Redpoint.SetActive(nextLVConfig.NeedSoulValue <= 0 && itemCount >= nextLVConfig.NeedPiece);
|
}
|
}
|
|
|
void OnFunc()
|
{
|
if (m_SoulID == 0) return;
|
|
model.selectSoulID = m_SoulID;
|
WindowCenter.Instance.Open<GatherSoulLevelUpWin>();
|
}
|
}
|
}
|
|