//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, January 15, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
//坐骑的弹框
|
namespace Snxxz.UI
|
{
|
|
public class AutoTrainTipsWin : 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 horseID = 0;
|
public static int _Lvnumber = 0;//标记需要升到所需的阶数
|
public static int DomesticateNumber = 0;//驯养次数
|
private MountWin moutwin = new MountWin();
|
private bool isBool = true;
|
public static bool IsFairy = false;
|
List<HorseSkillClass> MountSkills = new List<HorseSkillClass>();
|
MountModel m_MountModel;
|
MountModel mountModel { get { return m_MountModel ?? (m_MountModel = ModelCenter.Instance.GetModel<MountModel>()); } }
|
protected override void BindController()
|
{
|
moutwin = WindowCenter.Instance.Get<MountWin>();
|
}
|
|
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;
|
horseID = moutwin.signHorseID;
|
m_NowLevelTxt.text = string.Format(Language.Get("Z1031"), mountModel._DicHorse[horseID].Lv);
|
GetMountSkills(horseID);
|
PropertyEntries(horseID);//默认自动选择
|
int GetLvNow = mountModel._DicHorse[horseID].Lv;
|
int MaxLv = HorseConfig.Get(horseID).MaxLV;
|
_NumKeyBoard.min = (uint)(GetLvNow + 1);
|
_NumKeyBoard.max = (uint)MaxLv;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
private void GetMountSkills(int MountID)//获取坐骑的技能
|
{
|
MountSkills.Clear();
|
foreach (var key in mountModel.GetMountSkillAndItem.Keys)
|
{
|
if (mountModel.GetMountSkillAndItem[key].HorseID == MountID)
|
{
|
MountSkills.Add(mountModel.GetMountSkillAndItem[key]);
|
}
|
}
|
}
|
private void PropertyEntries(int MountID)//默认自动选择
|
{
|
int NextMountLv = 0;
|
int getLv = mountModel._DicHorse[MountID].Lv;
|
HorseConfig horseconfig = HorseConfig.Get(MountID);
|
bool IsBool = true;
|
for (int i = 0; i < MountSkills.Count; i++)
|
{
|
if (MountSkills[i].HorseLV > getLv && IsBool)
|
{
|
NextMountLv = MountSkills[i].HorseLV;
|
IsBool = false;
|
}
|
}
|
if (IsBool)
|
{
|
NextMountLv = horseconfig.MaxLV;
|
}
|
_Lvnumber = NextMountLv;
|
int NowHorseExp = HorseUpConfig.GetHorseIDAndLV(MountID, getLv).NeedExpTotal + mountModel._DicHorse[MountID].Exp;//当前等级的经验
|
int NeedNumber = Mathf.CeilToInt((float)(HorseUpConfig.GetHorseIDAndLV(MountID, NextMountLv).NeedExpTotal - NowHorseExp) / 100);//所需要的颗数
|
DomesticateNumber = NeedNumber;
|
NeedNumberText.text = NeedNumber.ToString();
|
NextToLvText.text = NextMountLv + Language.Get("Z1041");
|
}
|
|
private void SetMountSelectionInformation(int MountID, int LV)
|
{
|
int getLv = mountModel._DicHorse[MountID].Lv;
|
int NowHorseExp = HorseUpConfig.GetHorseIDAndLV(MountID, getLv).NeedExpTotal + mountModel._DicHorse[MountID].Exp;//当前等级的经验
|
int NeedNumber = Mathf.CeilToInt((float)(HorseUpConfig.GetHorseIDAndLV(MountID, 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;
|
moutwin.FairyJadeDomesticate();
|
Close();
|
}
|
else
|
{
|
if (VersionConfig.Get().isBanShu)
|
{
|
SysNotifyMgr.Instance.ShowTip("GoldErr");
|
return;
|
}
|
WindowCenter.Instance.Open<RechargeTipWin>();
|
}
|
|
}
|
private void OnClickReduceButton()//减
|
{
|
int getLvNow = mountModel._DicHorse[horseID].Lv;
|
if (_Lvnumber - 1 < getLvNow + 1)
|
{
|
ScrollTip.ShowTip(Language.Get("BelowCultureLevel_Z"));
|
}
|
else
|
{
|
_Lvnumber -= 1;
|
SetMountSelectionInformation(horseID, _Lvnumber);
|
}
|
|
}
|
private void OnClickPlusButton()//加
|
{
|
int MaxLv = HorseConfig.Get(horseID).MaxLV;
|
if (_Lvnumber + 1 <= MaxLv)
|
{
|
_Lvnumber += 1;
|
SetMountSelectionInformation(horseID, _Lvnumber);
|
}
|
else
|
{
|
ScrollTip.ShowTip(Language.Get("MoreThanDomestication_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 = mountModel._DicHorse[horseID].Lv;
|
int MaxLv = HorseConfig.Get(horseID).MaxLV;
|
if (int.Parse(_NumKeyBoard.Value) < GetLvNow + 1)
|
{
|
_Lvnumber = GetLvNow + 1;
|
SetMountSelectionInformation(horseID, _Lvnumber);
|
ScrollTip.ShowTip(Language.Get("LessThanTheDomesticated_Z"));
|
}
|
else if (int.Parse(_NumKeyBoard.Value) > MaxLv)
|
{
|
_Lvnumber = MaxLv;
|
SetMountSelectionInformation(horseID, _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(horseID, _Lvnumber);
|
}
|
|
}
|
private void onConfirm(bool _bool)
|
{
|
if (_bool)
|
{
|
NumKeyBoardValueChange();
|
_NumKeyBoardBGM.gameObject.SetActive(false);
|
}
|
}
|
}
|
|
}
|
|
|
|
|