using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using UnityEngine.EventSystems;
|
|
using System;
|
using System.Text;
|
using System.Text.RegularExpressions;
|
|
namespace Snxxz.UI
|
{
|
public class RolePanel : Window
|
{
|
[SerializeField] FunctionButtonGroup buttonGroup;
|
[SerializeField] FunctionButton functionButtonRole;
|
[SerializeField] FunctionButton functionButtonMagician;
|
[SerializeField] FunctionButton m_ReikiRoot;
|
[SerializeField] FunctionButton m_GatherSoul;
|
[SerializeField] FunctionButton m_FashionDress;
|
|
[SerializeField] RectTransform m_RoleInfoRt;
|
[SerializeField] Text m_PropertyAtk;
|
[SerializeField] Text m_PropertyHp;
|
[SerializeField] Text m_PropertyHit;
|
[SerializeField] Text m_PropertyDef;
|
[SerializeField] Text m_PropertyDodge;
|
[SerializeField] Text m_PropertyLuck;
|
|
[SerializeField] Text m_PropertyAtkSpeed;
|
[SerializeField] Text m_PropertyMoveSpeed;
|
[SerializeField] Text m_PropertyRealHurt;
|
[SerializeField] Text m_PropertyRealDef;
|
[SerializeField] Text m_PropertyExtraHurt;
|
[SerializeField] Text m_PropertyReduceHurt;
|
[SerializeField] Text m_PropertyCritOdd;
|
[SerializeField] Text m_PropertyCritHurt;
|
[SerializeField] Text m_PropertyCritHurtOdd;
|
[SerializeField] Text m_PropertyCritHitHurt;
|
[SerializeField] Text m_PlayerExp;
|
[SerializeField] Text m_PlayerLv;
|
[SerializeField] Text m_PlayerName;
|
[SerializeField] Text m_PlayerFightPower;
|
[SerializeField] RawImage m_PlayerShowModel;
|
[SerializeField] RectTransform m_ContainerExp;
|
[SerializeField] Slider m_ExpSlider;
|
[SerializeField] Text m_WorldExp;
|
[SerializeField] Button m_PlayerPropertyBtn;
|
[SerializeField] Button m_TitleBtn;
|
[SerializeField] Button m_RenameBtn;
|
[SerializeField] Image m_RoleTitleIcon;
|
[SerializeField] Image m_RoleRealmIcon;
|
[SerializeField] Button m_LeftBtn;
|
[SerializeField] Button m_RightBtn;
|
[SerializeField] Button m_CloseBtn;
|
[SerializeField] Button m_Btn_Elixir;
|
|
RoleModel m_Model;
|
RoleModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<RoleModel>());
|
}
|
}
|
|
TitleModel m_TitleModel;
|
TitleModel titleModel
|
{
|
get
|
{
|
return m_TitleModel ?? (m_TitleModel = ModelCenter.Instance.GetModel<TitleModel>());
|
}
|
}
|
|
PackModel packModel
|
{
|
get { return ModelCenter.Instance.GetModel<PackModel>(); }
|
}
|
|
private void OnRefreshTitle()
|
{
|
TitleData titleData = titleModel.GetTitleEquip();
|
if (titleData != null && titleModel.IsTitleGain(titleData.id))
|
{
|
m_RoleTitleIcon.gameObject.SetActive(true);
|
DienstgradConfig cfg = DienstgradConfig.Get(titleData.id);
|
if (cfg != null)
|
{
|
m_RoleTitleIcon.SetSprite(cfg.Image);
|
}
|
}
|
else
|
{
|
m_RoleTitleIcon.gameObject.SetActive(false);
|
}
|
}
|
private void OnRefreshRealm()
|
{
|
int realmlv = PlayerDatas.Instance.baseData.realmLevel;
|
RealmConfig presentCfg = RealmConfig.Get(realmlv);
|
if (presentCfg != null && presentCfg.Lv > 0)
|
{
|
m_RoleRealmIcon.SetSprite(presentCfg.Img);
|
m_RoleRealmIcon.gameObject.SetActive(true);
|
}
|
else
|
{
|
m_RoleRealmIcon.gameObject.SetActive(false);
|
}
|
}
|
private void OnRenameClick()
|
{
|
//SysNotifyMgr.Instance.ShowTip("JadeInvestmentLimit1");
|
WindowCenter.Instance.Open<RoleRenameWin>();
|
}
|
|
private void OnElixirClick()
|
{
|
//WindowCenter.Instance.Open<RoleElixirTipWin>();
|
}
|
private void OnDesignationClick()
|
{
|
if (FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Title))
|
{
|
WindowCenter.Instance.Open<RoleTitle>();
|
}
|
else
|
{
|
FuncOpen.Instance.ProcessorFuncErrorTip((int)FuncOpenEnum.Title);
|
}
|
}
|
private void OnAttrExplainClick()
|
{
|
WindowCenter.Instance.Open<RoleAttrWin>();
|
}
|
|
private void OnRefreshPlayerInfo(PlayerDataType refreshType)
|
{
|
switch (refreshType)
|
{
|
case PlayerDataType.FightPower:
|
m_PlayerFightPower.text = PlayerDatas.Instance.baseData.FightPoint.ToString();
|
break;
|
case PlayerDataType.MAXATK:
|
case PlayerDataType.MINATK:
|
case PlayerDataType.MaxHP:
|
case PlayerDataType.HIT:
|
case PlayerDataType.DEF:
|
case PlayerDataType.Miss:
|
case PlayerDataType.LuckValue:
|
{
|
OnUpdateBasicAttr();
|
}
|
break;
|
case PlayerDataType.RealmLevel:
|
{
|
OnRefreshRealm();
|
}
|
break;
|
case PlayerDataType.LV:
|
case PlayerDataType.TotalExp:
|
case PlayerDataType.ExpPoint:
|
{
|
OnUpdateLvExp();
|
OnRefreshWorldLv();
|
}
|
break;
|
}
|
}
|
|
private void RefreshPlayerInfoEvent()
|
{
|
OnUpdateSpecialAttr();
|
}
|
|
void InitRole()
|
{
|
OnUpdateBasicAttr();
|
OnUpdateSpecialAttr();
|
OnUpdateLvExp();
|
m_PlayerFightPower.text = PlayerDatas.Instance.baseData.FightPoint.ToString();
|
DisplayModel();
|
OnRefreshRealm();
|
OnRefreshWorldLv();
|
}
|
|
void DisplayModel()
|
{
|
UI3DModelExhibition.Instance.ShowPlayer(m_PlayerShowModel, PlayerDatas.Instance.baseData.Job);
|
}
|
|
void OnUpdateLvExp()
|
{
|
int lv = PlayerDatas.Instance.baseData.LV;
|
if (PlayerLVConfig.Get(lv + 1) == null)
|
{
|
m_ExpSlider.maxValue = 1;
|
m_ExpSlider.minValue = 0;
|
m_ExpSlider.value = 1;
|
m_PlayerExp.text = Language.Get("L1055");
|
}
|
else
|
{
|
m_ExpSlider.minValue = 0;
|
m_ExpSlider.maxValue = PlayerLVConfig.GetExpByPlayerLv(lv);
|
m_ExpSlider.value = (ulong)PlayerDatas.Instance.baseData.TotalExp + (ulong)PlayerDatas.Instance.baseData.ExpPoint * 100000000;
|
m_PlayerExp.text = string.Format("{0}/{1}", UIHelper.ReplaceLargeNum((ulong)PlayerDatas.Instance.baseData.TotalExp + (ulong)PlayerDatas.Instance.baseData.ExpPoint * 100000000), UIHelper.ReplaceLargeNum((ulong)PlayerLVConfig.GetExpByPlayerLv(lv)));
|
}
|
m_PlayerLv.text = Language.Get("Z1024", lv);
|
m_PlayerName.text = PlayerDatas.Instance.baseData.PlayerName;
|
OnRefreshTitle();
|
}
|
|
void OnUpdateBasicAttr()
|
{
|
m_PropertyAtk.text = StringUtility.Contact(ReplaceLargeNum((ulong)PlayerDatas.Instance.extersion.MINATK), "-", ReplaceLargeNum((ulong)PlayerDatas.Instance.extersion.MAXATK));
|
m_PropertyHp.text = GetAttrStr(PropertyType.HP);
|
m_PropertyHit.text = GetAttrStr(PropertyType.HIT);
|
m_PropertyDef.text = GetAttrStr(PropertyType.DEF);
|
m_PropertyDodge.text = GetAttrStr(PropertyType.MISS);
|
m_PropertyLuck.text = GetAttrStr(PropertyType.Luck);
|
}
|
|
void OnUpdateSpecialAttr()
|
{
|
m_PropertyAtkSpeed.text = GetAttrStr(PropertyType.ATKSPEED);
|
m_PropertyMoveSpeed.text = GetAttrStr(PropertyType.MoveSpeed);
|
m_PropertyRealHurt.text = GetAttrStr(PropertyType.RealHurt);
|
m_PropertyRealDef.text = GetAttrStr(PropertyType.RealResis);
|
m_PropertyExtraHurt.text = GetAttrStr(PropertyType.AddHurt);
|
m_PropertyReduceHurt.text = GetAttrStr(PropertyType.ReduceHurt);
|
m_PropertyCritOdd.text = GetAttrStr(PropertyType.CritChance);
|
m_PropertyCritHurt.text = GetAttrStr(PropertyType.CritHurt);
|
m_PropertyCritHurtOdd.text = GetAttrStr(PropertyType.HeartHit);
|
m_PropertyCritHitHurt.text = GetAttrStr(PropertyType.HeartHurt);
|
}
|
|
private string GetAttrStr(PropertyType type)
|
{
|
PlayerPropertyConfig cfg = PlayerPropertyConfig.Get((int)type);
|
float value = UIHelper.GetPropertyValue(type);
|
return StringUtility.Contact(UIHelper.ReplaceLargeNum(UIHelper.ReplacePercentage(value, cfg.ISPercentage)), cfg.ISPercentage == 1 ? "%" : string.Empty);
|
}
|
|
void OnDisableRole()
|
{
|
UI3DModelExhibition.Instance.StopShow();
|
}
|
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
functionButtonRole.onClick.AddListener(OnFuncRole);
|
functionButtonMagician.onClick.AddListener(OnFuncMagician);
|
m_GatherSoul.onClick.AddListener(GatherSoul);
|
m_ReikiRoot.onClick.AddListener(ReikiRoot);
|
m_FashionDress.onClick.AddListener(OpenFashionDress);
|
m_PlayerPropertyBtn.onClick.AddListener(OnAttrExplainClick);
|
m_TitleBtn.onClick.AddListener(OnDesignationClick);
|
m_RenameBtn.onClick.AddListener(OnRenameClick);
|
m_Btn_Elixir.onClick.AddListener(OnElixirClick);
|
m_LeftBtn.onClick.AddListener(buttonGroup.TriggerLast);
|
m_RightBtn.onClick.AddListener(buttonGroup.TriggerNext);
|
m_CloseBtn.onClick.AddListener(CloseClick);
|
}
|
|
private void ReikiRoot()
|
{
|
CloseChild();
|
WindowCenter.Instance.Open<ReikiRootWin>();
|
functionOrder = m_ReikiRoot.order;
|
}
|
|
private void GatherSoul()
|
{
|
CloseChild();
|
WindowCenter.Instance.Open<GatherSoulWin>();
|
functionOrder = m_GatherSoul.order;
|
}
|
|
private void OpenFashionDress()
|
{
|
CloseChild();
|
WindowCenter.Instance.Open<FashionDressWin>();
|
functionOrder = m_FashionDress.order;
|
}
|
|
private void OnFuncMagician()
|
{
|
CloseChild();
|
WindowCenter.Instance.Open<MagicianWin>();
|
functionOrder = functionButtonMagician.order;
|
}
|
|
private void OnFuncRole()
|
{
|
CloseChild();
|
m_RoleInfoRt.gameObject.SetActive(true);
|
InitRole();
|
functionOrder = 0;
|
}
|
|
protected override void OnPreOpen()
|
{
|
PlayerDatas.Instance.playerDataUpdateEvent += OnUpdateLvExp;
|
PlayerDatas.Instance.playerDataRefreshEvent += OnRefreshPlayerInfo;
|
titleModel.OnRefreshGainTitle += OnRefreshTitle;
|
PlayerDatas.Instance.worldLevelUpdateEvent += OnRefreshWorldLv;
|
PlayerDatas.Instance.playerDataUpdateEvent += RefreshPlayerInfoEvent;
|
packModel.refreshItemCountEvent += RefreshItemCountAct;
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
buttonGroup.TriggerByOrder(functionOrder);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
|
}
|
protected override void OnPreClose()
|
{
|
}
|
protected override void OnAfterClose()
|
{
|
PlayerDatas.Instance.playerDataUpdateEvent -= OnUpdateLvExp;
|
PlayerDatas.Instance.playerDataRefreshEvent -= OnRefreshPlayerInfo;
|
titleModel.OnRefreshGainTitle -= OnRefreshTitle;
|
PlayerDatas.Instance.worldLevelUpdateEvent -= OnRefreshWorldLv;
|
packModel.refreshItemCountEvent -= RefreshItemCountAct;
|
if (!WindowJumpMgr.Instance.IsJumpState)
|
{
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
}
|
PlayerDatas.Instance.playerDataUpdateEvent -= RefreshPlayerInfoEvent;
|
CloseChild();
|
}
|
|
private void RefreshItemCountAct(PackType packType, int index, int arg3)
|
{
|
if (packType == PackType.Equip)
|
{
|
DisplayModel();
|
}
|
}
|
|
private void OnRefreshWorldLv()
|
{
|
int limit = FuncOpenLVConfig.Get((int)FuncOpenEnum.WorldLv).LimitLV;
|
if (PlayerDatas.Instance.baseData.LV >= limit)
|
{
|
m_WorldExp.gameObject.SetActive(true);
|
m_WorldExp.text = Language.Get("WordExpText", PlayerDatas.Instance.worldLv, Mathf.FloorToInt(UIHelper.ReplacePercentage((int)PlayerDatas.Instance.worldExpRate, 2)) + "%");
|
}
|
else
|
{
|
m_WorldExp.gameObject.SetActive(false);
|
}
|
}
|
|
private void CloseChild()
|
{
|
if (m_RoleInfoRt.gameObject.activeSelf)
|
{
|
OnDisableRole();
|
m_RoleInfoRt.gameObject.SetActive(false);
|
}
|
var children = WindowConfig.Get().FindChildWindows("RolePanel");
|
foreach (var window in children)
|
{
|
WindowCenter.Instance.Close(window);
|
}
|
}
|
|
public StringBuilder m_StringBuilder = new StringBuilder();
|
|
public string ReplaceLargeNum(float num)
|
{
|
m_StringBuilder.Length = 0;
|
float hm = (float)Math.Round(num / 100000000, 2);
|
if (hm >= 1)
|
{
|
int _value = (int)hm;
|
var _length = 3 - _value.ToString().Length;
|
_length = Mathf.Max(0, _length);
|
if (_length > 0)
|
{
|
hm = (float)Math.Round(num / 100000000, _length);
|
}
|
decimal _checkValue = ((decimal)hm * 1000 - _value * 1000) / 1000;
|
var _decimal = Mathf.Max(0, _checkValue.ToString().Length - 2);
|
m_StringBuilder.Append(hm.ToString(StringUtility.Contact("f", _decimal > _length ? _length : _decimal)));
|
m_StringBuilder.Append(Language.Get("L1070"));
|
return m_StringBuilder.ToString();
|
}
|
float tt = (float)Math.Round(num / 10000, 2);
|
if (tt >= 1)
|
{
|
int _value = (int)tt;
|
var _length = 3 - _value.ToString().Length;
|
if (_length > 0)
|
{
|
tt = (float)Math.Round(num / 10000, _length);
|
}
|
_length = Mathf.Max(0, _length);
|
decimal _checkValue = ((decimal)tt * 1000 - _value * 1000) / 1000;
|
var _decimal = Mathf.Max(0, _checkValue.ToString().Length - 2);
|
m_StringBuilder.Append(tt.ToString(StringUtility.Contact("f", _decimal > _length ? _length : _decimal)));
|
m_StringBuilder.Append(Language.Get("L1071"));
|
return m_StringBuilder.ToString();
|
}
|
if (m_StringBuilder.Length == 0)
|
{
|
num = (float)Math.Round(num, 2);
|
int _value = (int)num;
|
var _length = 3 - _value.ToString().Length;
|
if (_length > 0)
|
{
|
num = (float)Math.Round(num, _length);
|
}
|
_length = Mathf.Max(0, _length);
|
decimal _checkValue = ((decimal)num * 1000 - _value * 1000) / 1000;
|
var _decimal = Mathf.Max(0, _checkValue.ToString().Length - 2);
|
m_StringBuilder.Append(num.ToString(StringUtility.Contact("f", _decimal > _length ? _length : _decimal)));
|
}
|
return m_StringBuilder.ToString();
|
}
|
}
|
}
|
|
|