//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Friday, September 15, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
//口粮兑换
|
namespace Snxxz.UI
|
{
|
|
public class ConvertItemTipsWin : Window
|
{
|
public Image _EquipBG;//背景图
|
public Image _ItemIcon;//图标
|
public Text _TitleText;//物品名称
|
public Text _TextContent;//可提升的数值
|
public Text _TheIntegral;//所需的兑换积分
|
public Text _DotText1;//兑换数量
|
public Button _AddsButton1;//增加按钮
|
public Button _MinusButton1;//减少按钮
|
public Button _ConvertBtn;//兑换按钮
|
public Button _CloseBtn;//关闭按钮
|
public Button _DotText1Btn;//计算器按钮
|
public Button _NumKeyBoardBGM;//计算机面板按钮
|
public NumKeyBoard _NumKeyBoard;//计算机
|
private int _TreasureIntegral = 0;//用于获取宝库积分
|
private int _CurrentNumber = 1;//获取当前数量
|
|
private int _NumberID = 0, _Number = 0, _Integral = 0, _BiggestLimit = 0, _ExperienceAdd = 0;//获取物品ID,数量,所需积分,做大上限,经验的增加
|
FairyAuTreasureModel m_PlayerFairyAuTreasureData;
|
FairyAuTreasureModel playerFairyAuTreasureData { get { return m_PlayerFairyAuTreasureData ?? (m_PlayerFairyAuTreasureData = ModelCenter.Instance.GetModel<FairyAuTreasureModel>()); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
FuncConfigConfig _PetFoodExchange = FuncConfigConfig.Get("PetFoodExchange");
|
_NumberID = int.Parse(_PetFoodExchange.Numerical1);
|
_TitleText.text = ItemConfig.Get(_PetFoodExchange.Numerical1).ItemName;
|
_ExperienceAdd = ItemConfig.Get(_PetFoodExchange.Numerical1).EffectValueA1;
|
_Number = int.Parse(_PetFoodExchange.Numerical2);
|
_Integral = int.Parse(_PetFoodExchange.Numerical3);
|
_BiggestLimit = ItemConfig.Get(_PetFoodExchange.Numerical1).PackCount;
|
_EquipBG.SetItemBackGround(ItemConfig.Get(_PetFoodExchange.Numerical1).ItemColor);
|
_TextContent.text = ItemConfig.Get(_NumberID).Description;
|
_ItemIcon.SetSprite(ItemConfig.Get(_NumberID).IconKey);
|
}
|
|
protected override void AddListeners()
|
{
|
|
_AddsButton1.onClick.AddListener(AddsButton);
|
_MinusButton1.onClick.AddListener(MinusButton);
|
|
_ConvertBtn.onClick.AddListener(ConvertButton);
|
_CloseBtn.onClick.AddListener(CloseButton);
|
_DotText1Btn.AddListener(DotText1Button);
|
_NumKeyBoardBGM.AddListener(NumKeyBoardBGMButton);
|
_NumKeyBoard.onValueChange.AddListener(NumKeyBoardValueChange);
|
_NumKeyBoard.onConfirm.AddListener(onConfirm);
|
|
}
|
|
protected override void OnPreOpen()
|
{
|
_NumKeyBoardBGM.gameObject.SetActive(false);
|
_TreasureIntegral = playerFairyAuTreasureData._FairyAuIntegral;
|
_DotText1.text = "1";
|
_CurrentNumber = 1;
|
_TheIntegral.text = (_CurrentNumber * _Integral).ToString();
|
if (_TreasureIntegral >= _CurrentNumber * _Integral)
|
{
|
_TheIntegral.color = new Color(255,239,71);
|
}
|
else
|
{
|
_TheIntegral.color = UIHelper.GetUIColor(5, false);
|
}
|
_DotText1.text = _CurrentNumber.ToString();
|
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
|
|
void AddsButton()//增加按钮
|
{
|
if (_CurrentNumber >= _BiggestLimit)
|
return;
|
_CurrentNumber += 1 * _Number;
|
if (_TreasureIntegral >= _CurrentNumber * _Integral)
|
{
|
_TheIntegral.color = new Color(255, 239, 71);
|
}
|
else
|
{
|
_TheIntegral.color = UIHelper.GetUIColor(5, false);
|
}
|
_DotText1.text = _CurrentNumber.ToString();
|
_TheIntegral.text = (_CurrentNumber * _Integral).ToString();
|
}
|
|
void MinusButton()//减少按钮
|
{
|
if (_CurrentNumber <= 1)
|
return;
|
_CurrentNumber -= 1 * _Number;
|
if (_TreasureIntegral >= _CurrentNumber * _Integral)
|
{
|
_TheIntegral.color = new Color(255, 239, 71);
|
}
|
else
|
{
|
_TheIntegral.color = UIHelper.GetUIColor(5, false);
|
}
|
_DotText1.text = _CurrentNumber.ToString();
|
_TheIntegral.text = (_CurrentNumber * _Integral).ToString();
|
}
|
|
void ConvertButton()//兑换按钮
|
{
|
var playerPackModel = ModelCenter.Instance.GetModel<PackModel>();
|
if (playerPackModel.GetEmptyGridCount(PackType.Item) < 1)
|
{
|
SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_998371");
|
Close();
|
return;
|
}
|
|
if (_TreasureIntegral >= _CurrentNumber * _Integral)
|
{
|
CA610_tagCMFamilyStoreExchange _CA610 = new CA610_tagCMFamilyStoreExchange();
|
_CA610.StoreItemIndex = 0;
|
_CA610.ItemID = (uint)_NumberID;
|
_CA610.ExcangeCount = (ushort)_CurrentNumber;
|
GameNetSystem.Instance.SendInfo(_CA610);
|
DebugEx.Log("兑换成功");
|
Close();
|
}
|
else
|
{
|
ScrollTip.ShowTip(Language.Get("Z1058"));
|
Close();
|
}
|
}
|
|
void DotText1Button()//就算器按钮弹出按钮
|
{
|
_NumKeyBoardBGM.gameObject.SetActive(true);
|
|
}
|
|
void CloseButton()//关闭按钮
|
{
|
Close();
|
}
|
|
void NumKeyBoardValueChange()
|
{
|
_CurrentNumber = int.Parse(_NumKeyBoard.Value);
|
if (_TreasureIntegral >= _CurrentNumber * _Integral)
|
{
|
_TheIntegral.color = new Color(255, 239, 71);
|
}
|
else
|
{
|
_TheIntegral.color = UIHelper.GetUIColor(5, false);
|
}
|
_DotText1.text = _CurrentNumber.ToString();
|
_TheIntegral.text = (_CurrentNumber * _Integral).ToString();
|
}
|
void NumKeyBoardBGMButton()
|
{
|
_NumKeyBoardBGM.gameObject.SetActive(false);
|
|
}
|
|
void onConfirm(bool _bool)
|
{
|
if (_bool)
|
_NumKeyBoardBGM.gameObject.SetActive(false);
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|