152 lines
3.8 KiB
C#
152 lines
3.8 KiB
C#
namespace RedHotRoast
|
|
{
|
|
public class BuyPropUI : BaseUI
|
|
{
|
|
private BuyPropUICtrl ctrl;
|
|
private BuyPropModel model;
|
|
private FGUI.ZM_Prop_09.com_prop ui;
|
|
private int state_ = 0;
|
|
|
|
public BuyPropUI(BuyPropUICtrl ctrl) : base(ctrl)
|
|
{
|
|
uiName = UIConst.BuyPropUI;
|
|
this.ctrl = ctrl;
|
|
}
|
|
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
|
{
|
|
uiInfo.packageName = "ZM_Prop_09";
|
|
uiInfo.assetName = "com_prop";
|
|
uiInfo.layerType = UILayerType.Popup;
|
|
uiInfo.isNeedOpenAnim = false;
|
|
uiInfo.isNeedCloseAnim = false;
|
|
uiInfo.isNeedUIMask = false;
|
|
}
|
|
|
|
#region 生命周期
|
|
protected override void OnInit()
|
|
{
|
|
//model = ModuleManager.Instance.GetModel(ModelConst.BuyPropModel) as BuyPropModel;
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
GameHelper.showGameUI = true;
|
|
|
|
}
|
|
|
|
protected override void OnBind()
|
|
{
|
|
ui = baseUI as FGUI.ZM_Prop_09.com_prop;
|
|
}
|
|
|
|
protected override void OnOpenBefore(object args)
|
|
{
|
|
state_ = (int)args;
|
|
ui.prop.selectedIndex = state_;
|
|
ui.btn_buy.GetChild("text_gold").text = GameHelper.Get101Str(ConfigSystem.GetCommonConf().Purchaseprops);
|
|
ui.btn_buy.SetClick(buyItem);
|
|
setBtnState(state_);
|
|
InitView();
|
|
|
|
}
|
|
void buyItem()
|
|
{
|
|
if (state_ == 0)
|
|
{
|
|
|
|
}
|
|
else if (state_ == 1)
|
|
{
|
|
|
|
|
|
}
|
|
else if (state_ == 2)
|
|
{
|
|
|
|
|
|
}
|
|
if (GameHelper.CheckGoldNumber(ConfigSystem.GetCommonConf().Purchaseprops))
|
|
{
|
|
GameHelper.AddGoldNumber(-ConfigSystem.GetCommonConf().Purchaseprops);
|
|
int numbers = GameHelper.GetItemNumber(state_);
|
|
numbers++;
|
|
GameHelper.SetItemNumber(state_, numbers);
|
|
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
|
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
|
GameHelper.ShowTips("purchase_succ", true);
|
|
CtrlCloseUI();
|
|
}
|
|
else
|
|
{
|
|
GameHelper.ShowTips("no_enough_gold", true);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
protected override void OnOpen(object args)
|
|
{
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
}
|
|
|
|
protected override void OnDisplay(object args)
|
|
{
|
|
}
|
|
#endregion
|
|
|
|
#region 消息
|
|
protected override void AddListener()
|
|
{
|
|
|
|
}
|
|
protected override void RemoveListener()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
//初始化页面逻辑
|
|
private void InitView()
|
|
{
|
|
ui.btn_back.SetClick(() =>
|
|
{
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Close);
|
|
});
|
|
|
|
// ui.btn_buy0.SetClick(() =>
|
|
// {
|
|
// state_ = 0;
|
|
// ui.prop.selectedIndex = 0;
|
|
// setBtnState(0);
|
|
// });
|
|
// ui.btn_buy1.SetClick(() =>
|
|
// {
|
|
// state_ = 1;
|
|
|
|
// ui.prop.selectedIndex = 1;
|
|
// setBtnState(1);
|
|
|
|
// });
|
|
// ui.btn_buy2.SetClick(() =>
|
|
// {
|
|
// state_ = 2;
|
|
|
|
// ui.prop.selectedIndex = 2;
|
|
// setBtnState(2);
|
|
|
|
// });
|
|
}
|
|
|
|
private void setBtnState(int index)
|
|
{
|
|
// ui.btn_buy0.tab_choose.selectedIndex = index == 0 ? 1 : 0;
|
|
// ui.btn_buy1.tab_choose.selectedIndex = index == 1 ? 1 : 0;
|
|
// ui.btn_buy2.tab_choose.selectedIndex = index == 2 ? 1 : 0;
|
|
}
|
|
}
|
|
}
|