//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, April 22, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class RealmPromoteWin : Window
|
{
|
[SerializeField] Text m_FightPoint;
|
[SerializeField] PropertyBehaviour[] m_Propertys;
|
[SerializeField] Text m_ReikiPoint;
|
[SerializeField] Image m_RealmIcon;
|
[SerializeField] UIEffect m_Effect;
|
[SerializeField] Button m_Close;
|
|
[SerializeField] Transform m_CloseRemind;
|
|
public static int realmLevel = 0;
|
|
static Dictionary<int, int> propertys = new Dictionary<int, int>();
|
|
float timer = 0f;
|
|
RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.AddListener(OnClickClose);
|
}
|
|
protected override void OnPreOpen()
|
{
|
timer = 0f;
|
m_CloseRemind.gameObject.SetActive(false);
|
Dispaly();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void LateUpdate()
|
{
|
timer += Time.deltaTime;
|
if (timer >= 2f)
|
{
|
if (!m_CloseRemind.gameObject.activeSelf)
|
{
|
m_CloseRemind.gameObject.SetActive(true);
|
}
|
}
|
}
|
#endregion
|
|
private void OnClickClose()
|
{
|
if (timer >= 2f)
|
{
|
CloseClick();
|
}
|
}
|
|
void Dispaly()
|
{
|
propertys.Clear();
|
|
var currentConfig = RealmConfig.Get(realmLevel);
|
var lastConfig = RealmConfig.Get(realmLevel - 1);
|
|
for (int i = 0; i < currentConfig.AddAttrType.Length; i++)
|
{
|
propertys.Add(currentConfig.AddAttrType[i], currentConfig.AddAttrNum[i]);
|
}
|
if (lastConfig.AddAttrType != null && lastConfig.AddAttrType.Length > 0)
|
{
|
for (int i = 0; i < lastConfig.AddAttrType.Length; i++)
|
{
|
var property = lastConfig.AddAttrType[i];
|
if (propertys.ContainsKey(property))
|
{
|
propertys[property] -= lastConfig.AddAttrNum[i];
|
}
|
}
|
}
|
|
var fightPoint = UIHelper.GetFightPower(propertys);
|
m_FightPoint.text = fightPoint.ToString();
|
|
for (int i = 0; i < m_Propertys.Length; i++)
|
{
|
m_Propertys[i].gameObject.SetActive(i < currentConfig.AddAttrType.Length);
|
if (i < currentConfig.AddAttrType.Length)
|
{
|
var property = currentConfig.AddAttrType[i];
|
m_Propertys[i].DisplayRealm(property, currentConfig.AddAttrNum[i] - propertys[property], currentConfig.AddAttrNum[i]);
|
}
|
}
|
|
m_ReikiPoint.text = model.realmLevelUpReikiPoint.ToString();
|
|
m_RealmIcon.SetSprite(currentConfig.Img);
|
|
var effectId = model.GetRealmCoverEffect(realmLevel);
|
m_Effect.StopImediatly();
|
m_Effect.effect = effectId;
|
m_Effect.Play();
|
}
|
|
}
|
|
}
|
|
|
|
|