//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, November 01, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using TableConfig;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class SkillClass
|
{
|
public int PetID;
|
public int SkillID;
|
public int Lv;
|
|
}
|
|
public class AutoTrainTipsPWin : Window
|
{
|
|
#region Built-in
|
[SerializeField] Button m_CloseBtn;//关闭
|
[SerializeField] Button m_CancelBtn;//取消
|
[SerializeField] Button m_ConfirmBtn;//确定
|
[SerializeField] Button m_BtnReduce;//减
|
[SerializeField] Button m_BtnPlus;//加
|
|
[SerializeField] Button _DotText1Btn;//计算器按钮
|
[SerializeField] Button _NumKeyBoardBGM;//计算机面板按钮
|
[SerializeField] NumKeyBoard _NumKeyBoard;//计算机
|
|
[SerializeField] Text NextToLvText;//需要驯养等级
|
[SerializeField] Text NeedNumberText;//所需购买的颗数
|
[SerializeField] Text m_NowLevelTxt;//当前等级
|
private int PetID = 0;
|
public static int _Lvnumber = 0;//标记需要升到所需的阶数
|
public static int DomesticateNumber = 0;//驯养次数
|
private PetAttributeWin PetWin = new PetAttributeWin();
|
private bool isBool = true;
|
public static bool IsFairy = false;
|
List<SkillClass> PetSkills = new List<SkillClass>();
|
PlayerPetDatas m_petModel;
|
PlayerPetDatas PetModel { get { return m_petModel ?? (m_petModel = ModelCenter.Instance.GetModel<PlayerPetDatas>()); } }
|
protected override void BindController()
|
{
|
PetWin = WindowCenter.Instance.Get<PetAttributeWin>();
|
}
|
|
protected override void AddListeners()
|
{
|
m_CloseBtn.AddListener(OnClickCloseButton);
|
m_CancelBtn.AddListener(OnClickCancelButton);
|
m_ConfirmBtn.AddListener(OnClickConfirmButton);
|
m_BtnReduce.AddListener(OnClickReduceButton);
|
m_BtnPlus.AddListener(OnClickPlusButton);
|
_DotText1Btn.AddListener(OnClickDotText1);
|
_NumKeyBoardBGM.AddListener(OnClickNumKeyBoardBGM);
|
_NumKeyBoard.onValueChange.AddListener(OnClickNumKeyBoardValueChange);
|
_NumKeyBoard.onConfirm.AddListener(onConfirm);
|
}
|
|
protected override void OnPreOpen()
|
{
|
IsFairy = false;
|
_NumKeyBoardBGM.gameObject.SetActive(false);
|
isBool = true;
|
PetID = PetModel.SigPetId;
|
m_NowLevelTxt.text = string.Format(Language.Get("PetZ1031"), PetModel._DicPetBack[PetID].PetClass);
|
GetMountSkills(PetID);
|
PropertyEntries(PetID);//默认自动选择
|
int GetLvNow = PetModel._DicPetBack[PetID].PetClass;
|
int MaxLv = Config.Instance.Get<PetInfoConfig>(PetID).MaxRank;
|
_NumKeyBoard.min = (uint)(GetLvNow + 1);
|
_NumKeyBoard.max = (uint)MaxLv;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
private void GetMountSkills(int petId)//获取坐骑的技能
|
{
|
PetSkills.Clear();
|
var PetInfo = Config.Instance.Get<PetInfoConfig>(petId);
|
int[] SKillID = ConfigParse.GetMultipleStr<int>(PetInfo.SkillID);
|
int[] SkillUnLock = ConfigParse.GetMultipleStr<int>(PetInfo.SkillUnLock);
|
for (int i = 0; i < SKillID.Length; i++)
|
{
|
SkillClass skillClass = new SkillClass();
|
skillClass.PetID = petId;
|
skillClass.SkillID = SKillID[i];
|
skillClass.Lv = SkillUnLock[i];
|
PetSkills.Add(skillClass);
|
}
|
}
|
private void PropertyEntries(int _petID)//默认自动选择
|
{
|
int NextMountLv = 0;
|
int getLv = PetModel._DicPetBack[_petID].PetClass;
|
var PetInfo = Config.Instance.Get<PetInfoConfig>(_petID);
|
bool IsBool = true;
|
for (int i = 0; i < PetSkills.Count; i++)
|
{
|
if (PetSkills[i].Lv > getLv && IsBool)
|
{
|
NextMountLv = PetSkills[i].Lv;
|
IsBool = false;
|
}
|
}
|
if (IsBool)
|
{
|
NextMountLv = PetInfo.MaxRank;
|
}
|
_Lvnumber = NextMountLv;
|
int NowHorseExp = PetClassCostConfig.GetPetIdAndRank(_petID, getLv).NeedExpTotal + PetModel._DicPetBack[_petID].petExp;//当前等级的经验
|
int NeedNumber = Mathf.CeilToInt((float)(PetClassCostConfig.GetPetIdAndRank(_petID, NextMountLv).NeedExpTotal - NowHorseExp) / 100);//所需要的颗数
|
DomesticateNumber = NeedNumber;
|
NeedNumberText.text = NeedNumber.ToString();
|
NextToLvText.text = NextMountLv + Language.Get("Z1041");
|
}
|
private void SetMountSelectionInformation(int _PetID, int LV)
|
{
|
int getLv = PetModel._DicPetBack[_PetID].PetClass;
|
int NowHorseExp = PetClassCostConfig.GetPetIdAndRank(_PetID, getLv).NeedExpTotal + PetModel._DicPetBack[_PetID].petExp;//当前等级的经验
|
|
int NeedNumber = Mathf.CeilToInt((float)(PetClassCostConfig.GetPetIdAndRank(_PetID, LV).NeedExpTotal - NowHorseExp) / 100);//所需要的颗数
|
DomesticateNumber = NeedNumber;
|
NextToLvText.text = LV + Language.Get("Z1041");
|
NeedNumberText.text = NeedNumber.ToString();
|
}
|
|
private void OnClickCloseButton()
|
{
|
Close();
|
}
|
private void OnClickCancelButton()
|
{
|
Close();
|
}
|
private void OnClickConfirmButton()//确定
|
{
|
int NeedFairyJade = DomesticateNumber * 10;
|
|
int gold = (int)UIHelper.GetMoneyCnt(1);
|
if (NeedFairyJade > 0 && gold >= NeedFairyJade)
|
{
|
IsFairy = true;
|
PetWin.FairyJadeDomesticate();
|
Close();
|
}
|
else
|
{
|
if (VersionConfig.Get().isBanShu)
|
{
|
SysNotifyMgr.Instance.ShowTip("GoldErr");
|
return;
|
}
|
WindowCenter.Instance.Open<RechargeTipWin>();
|
}
|
|
}
|
private void OnClickReduceButton()//减
|
{
|
int getLvNow = PetModel._DicPetBack[PetID].PetClass;
|
if (_Lvnumber - 1 < getLvNow + 1)
|
{
|
ScrollTip.ShowTip(Language.Get("PetBelowCultureLevel_"));
|
}
|
else
|
{
|
_Lvnumber -= 1;
|
SetMountSelectionInformation(PetID, _Lvnumber);
|
}
|
|
}
|
private void OnClickPlusButton()//加
|
{
|
int MaxLv = Config.Instance.Get<PetInfoConfig>(PetID).MaxRank;
|
if (_Lvnumber + 1 <= MaxLv)
|
{
|
_Lvnumber += 1;
|
SetMountSelectionInformation(PetID, _Lvnumber);
|
}
|
else
|
{
|
ScrollTip.ShowTip(Language.Get("PetMoreThanDomestication_Z"));
|
}
|
}
|
private void OnClickDotText1()//中间点击
|
{
|
if (!_NumKeyBoardBGM.gameObject.activeSelf)
|
{
|
_NumKeyBoardBGM.gameObject.SetActive(true);
|
}
|
}
|
private void OnClickNumKeyBoardBGM()//关闭面板
|
{
|
if (_NumKeyBoardBGM.gameObject.activeSelf)
|
{
|
_NumKeyBoardBGM.gameObject.SetActive(false);
|
}
|
}
|
|
private void OnClickNumKeyBoardValueChange()
|
{
|
if (int.Parse(_NumKeyBoard.Value) > 999)
|
{
|
NextToLvText.text = 999 + Language.Get("Z1041");
|
}
|
else
|
{
|
NextToLvText.text = int.Parse(_NumKeyBoard.Value) + Language.Get("Z1041");
|
}
|
|
|
}
|
private void NumKeyBoardValueChange()
|
{
|
int GetLvNow = PetModel._DicPetBack[PetID].PetClass;
|
int MaxLv = Config.Instance.Get<PetInfoConfig>(PetID).MaxRank;
|
if (int.Parse(_NumKeyBoard.Value) < GetLvNow + 1)
|
{
|
_Lvnumber = GetLvNow + 1;
|
SetMountSelectionInformation(PetID, _Lvnumber);
|
ScrollTip.ShowTip(Language.Get("LessThanTheDomesticated_Z"));
|
}
|
else if (int.Parse(_NumKeyBoard.Value) > MaxLv)
|
{
|
_Lvnumber = MaxLv;
|
SetMountSelectionInformation(PetID, _Lvnumber);
|
ScrollTip.ShowTip(Language.Get("MoreThanDomestication_Z"));
|
}
|
else if (int.Parse(_NumKeyBoard.Value) >= GetLvNow + 1 && int.Parse(_NumKeyBoard.Value) <= MaxLv)
|
{
|
_Lvnumber = int.Parse(_NumKeyBoard.Value);
|
SetMountSelectionInformation(PetID, _Lvnumber);
|
}
|
|
}
|
private void onConfirm(bool _bool)
|
{
|
if (_bool)
|
{
|
NumKeyBoardValueChange();
|
_NumKeyBoardBGM.gameObject.SetActive(false);
|
}
|
}
|
#endregion
|
|
}
|
|
}
|