//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, April 22, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using LitJson;
|
|
namespace vnxbqy.UI
|
{
|
|
public class RealmPromoteWin : Window
|
{
|
[SerializeField] Text m_FightPoint;
|
[SerializeField] PropertyBehaviour[] m_Propertys;
|
[SerializeField] Text m_ReikiPoint;
|
[SerializeField] Text m_ReikiText;
|
[SerializeField] Text m_SkillName;
|
[SerializeField] Text m_SkillText;
|
[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.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.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].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 = string.Empty;
|
m_ReikiText.text = string.Empty;
|
m_SkillName.text = string.Empty;
|
m_SkillText.text = string.Empty;
|
if (currentConfig.AddFreePoint != 0)
|
{
|
m_ReikiPoint.text = currentConfig.AddFreePoint.ToString();
|
m_ReikiText.text = Language.Get("Z2007");
|
}
|
|
var config = RealmConfig.Get(realmLevel);
|
if (config.LearnSkillIDInfo.Length > 4)
|
{
|
var json = JsonMapper.ToObject(config.LearnSkillIDInfo);
|
var array = JsonMapper.ToObject<int[]>(json[PlayerDatas.Instance.baseData.Job.ToString()].ToJson());
|
var skillConfig = SkillConfig.Get(array[0]);
|
|
m_SkillName.text = skillConfig.SkillName;
|
m_SkillText.text = Language.Get("Z2008");
|
}
|
|
|
m_RealmIcon.SetSprite(currentConfig.Img);
|
|
var effectId = model.GetRealmCoverEffect(realmLevel);
|
m_Effect.StopImediatly();
|
m_Effect.effect = effectId;
|
m_Effect.Play();
|
}
|
|
}
|
|
}
|
|
|
|
|