Files
RedHotRoast-ios/Assets/Scripts/ModuleUI/TuJian/TuJianViewUI.cs
T
2026-04-22 09:52:55 +08:00

180 lines
4.5 KiB
C#

// using FGUI.A000_common;
using System;
using System.Collections.Generic;
using FairyGUI;
using FGUI.P23_Tujian;
using Spine.Unity;
using UnityEngine;
namespace FlowerPower
{
public class TuJianViewUI : BaseUI
{
private TuJianViewUICtrl ctrl;
private SignInViewModel model;
private SignDailyRewardModel signModel;
private FGUI.P23_Tujian.com_tujian ui;
private Action closeCallback;
public TuJianViewUI(TuJianViewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.TuJianViewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "P23_Tujian";
uiInfo.assetName = "com_tujian";
uiInfo.layerType = UILayerType.Normal;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = false;
}
#region 生命周期
protected override void OnInit()
{
}
protected override void OnClose()
{
GameHelper.showGameUI = true;
}
protected override void OnBind()
{
ui = baseUI as FGUI.P23_Tujian.com_tujian;
}
protected override void OnOpenBefore(object args)
{
if (Screen.safeArea.y != 0)
{
ui.gold.y += Screen.safeArea.y-15;
}
InitView();
}
protected override void OnOpen(object args)
{
ui.visible = false;
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region 消息
protected override void AddListener()
{
}
protected override void RemoveListener()
{
}
#endregion
//初始化页面逻辑
private void InitView()
{
var fx_coin = FXManager.Instance.SetFx<SkeletonAnimation>(ui.gold.GetChild("ani_node") as GGraph, Fx_Type.fx_coin, ref closeCallback);
fx_coin.state.SetAnimation(0, "animation", true);
var fx_tujian = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_node, Fx_Type.fx_tujian, ref closeCallback);
fx_tujian.state.SetAnimation(0, "animation", true);
ui.list.itemRenderer = setRemaintime;
ui.list.numItems = 3;
}
private void setRemaintime(int index, GObject obj) {
com_tujian_item item = (com_tujian_item)obj;
item.page.selectedIndex = index;
int level = GameHelper.GetLevel();
if (index == 0) {
if (level >= 10) {
item.gril_9.state.selectedIndex = 10;
} else {
item.gril_9.state.selectedIndex = level - 1;
}
item.lab_progress.text = (level - 1) + "/9";
item.pb.max = 9;
item.pb.value = level - 1;
} else if (index == 1) {
int value = level - 9 - 1;
value = value > 0 ? value : 0;
if (level >= 26) {
item.gril_16.state.selectedIndex = 17;
} else {
item.gril_16.state.selectedIndex = value;
}
item.lab_progress.text = value + "/16";
item.pb.max = 16;
item.pb.value = value;
}
}
public void onShowAnim(object show)
{
ui.gold.GetChild("text_gold").text = $"{PreferencesMgr.Instance.Currency101:N0}";
if (show != null)
{
ui.visible = true;
if ((bool)show)
{
ui.show1.Play();
}
else
{
ui.show2.Play();
}
isHide = true;
}
}
private bool isHide = true;
public void onHideAnim(object hide)
{
if (hide != null && isHide)
{
if ((bool)hide)
{
ui.hide1.Play();
}
else
{
ui.hide2.Play();
}
isHide = false;
}
}
}
}