//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Sunday, April 28, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using UnityEngine.Events;
|
|
namespace vnxbqy.UI
|
{
|
|
|
public class OneLevelWin : Window
|
{
|
protected Image m_TitleIcon;
|
protected FunctionButtonGroup m_Group;
|
protected Button m_Left;
|
protected Button m_Right;
|
protected Button m_Close;
|
|
protected Text m_Copper;
|
protected Text m_Diamond;
|
protected Text m_BindDiamond;
|
|
protected RectTransform m_SubWindowContainer;
|
public RectTransform subWindowContainer { get { return m_SubWindowContainer; } }
|
|
PositionTween positionTween;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
positionTween = this.AddMissingComponent<PositionTween>();
|
|
positionTween.curve = BuiltInLoader.LoadScriptableObject<TweenCurve>("Linear");
|
positionTween.delayMode = Tween.DelayMode.TwiceFrame;
|
positionTween.duration = 0.3f;
|
positionTween.from = new Vector3(0, 750, 0);
|
positionTween.to = Vector3.zero;
|
positionTween.trigger = Tween.Trigger.Manual;
|
positionTween.wrapMode = Tween.WrapMode.Once;
|
|
windowInfo.tween = positionTween;
|
|
m_TitleIcon = this.GetComponent<Image>("Pivot/Container_BackGround/Img_Title");
|
m_Group = this.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions");
|
m_Left = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left");
|
m_Right = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right");
|
m_Close = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close");
|
|
m_Copper = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/SilverCountBG/CountText");
|
if (m_Copper != null)
|
m_Diamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldCountBG/CountText");
|
m_BindDiamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldPaperCountBG/CountText");
|
|
m_SubWindowContainer = this.GetComponent<RectTransform>("Pivot/Container_SubWindow");
|
|
var name = this.gameObject.name;
|
var infos = WindowConfig.GetWindowFunctionInfos(name);
|
foreach (var info in infos)
|
{
|
var title = Language.Get(info.titleKey);
|
if (title.Length == 2)
|
{
|
title = title.Insert(1, " ");
|
}
|
m_Group.AddFunction("FunctionButton_Pattern_1", info.order, info.functionId, title, info.redPointId);
|
}
|
|
m_TitleIcon.SetSprite(WindowConfig.GetTitleIconKey(name));
|
m_TitleIcon.SetNativeSize();
|
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.SetListener(() => { WindowCenter.Instance.Close(this.gameObject.name); });
|
m_Left.SetListener(() => { m_Group.TriggerLast(); });
|
m_Right.SetListener(() => { m_Group.TriggerNext(); });
|
}
|
|
protected override void OnPreOpen()
|
{
|
if (m_Copper == null)
|
m_Copper = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/SilverCountBG/CountText");
|
m_Diamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldCountBG/CountText");
|
m_BindDiamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldPaperCountBG/CountText");
|
|
|
UpdateMoney();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
CloseSubWindows();
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
PlayerDatas.Instance.playerDataRefreshEvent += OnPlayerDataUpdate;
|
m_Group.TriggerByOrder(functionOrder);
|
m_Group.GotoOrder(functionOrder);
|
m_Left.SetActive(m_Group.unLockedCount > 1);
|
m_Right.SetActive(m_Group.unLockedCount > 1);
|
}
|
|
#endregion
|
|
protected virtual void CloseSubWindows()
|
{
|
var subWindows = WindowConfig.GetChildWindows(this.gameObject.name);
|
foreach (var window in subWindows)
|
{
|
WindowCenter.Instance.Close(window);
|
}
|
}
|
|
public void SetFunctionListener(int order, UnityAction callBack)
|
{
|
m_Group.SetFunctionListener(order, callBack);
|
}
|
|
public void SetFunctionButtonActive(int order, bool isShow)
|
{
|
m_Group.SetFunctionButtonActive(order, isShow);
|
}
|
|
public RedPointState GetFunctionButtonRedPointState(int order)
|
{
|
return m_Group.GetFunctionButtonRedPointState(order);
|
}
|
|
public void FunctionButtonInvoke(int order)
|
{
|
m_Group.TriggerByOrder(order);
|
m_Group.GotoOrder(order);
|
}
|
|
private void OnPlayerDataUpdate(PlayerDataType type)
|
{
|
switch (type)
|
{
|
case PlayerDataType.Gold:
|
case PlayerDataType.GoldPaper:
|
case PlayerDataType.Silver:
|
case PlayerDataType.ExAttr6:
|
case PlayerDataType.default5:
|
case PlayerDataType.default6:
|
UpdateMoney();
|
break;
|
}
|
}
|
|
void UpdateMoney()
|
{
|
if (m_Copper == null)
|
return;
|
m_Copper.text = ItemLogicUtility.Instance.OnChangeCoinsUnit(PlayerDatas.Instance.baseData.allCopper);
|
m_Diamond.text = UIHelper.GetMoneyCntEx(1).ToString();
|
if (PlayerDatas.Instance.baseData.bindDiamond > 0)
|
m_BindDiamond.text = ItemLogicUtility.Instance.OnChangeCoinsUnit(PlayerDatas.Instance.baseData.bindDiamond);
|
else
|
m_BindDiamond.text = UIHelper.GetMoneyCntEx(2).ToString();
|
}
|
}
|
|
}
|