2026-04-22 09:52:55 +08:00
|
|
|
// using FGUI.A000_common;
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2026-04-22 11:13:16 +08:00
|
|
|
using DG.Tweening;
|
2026-04-22 09:52:55 +08:00
|
|
|
using FairyGUI;
|
2026-04-22 11:13:16 +08:00
|
|
|
using FGUI.ZM_Sign_06;
|
2026-04-22 09:52:55 +08:00
|
|
|
using Spine.Unity;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
namespace LoveLegend
|
2026-04-22 09:52:55 +08:00
|
|
|
{
|
|
|
|
|
public class SignInViewUI : BaseUI
|
|
|
|
|
{
|
|
|
|
|
private SignInViewUICtrl ctrl;
|
|
|
|
|
private SignInViewModel model;
|
2026-04-22 11:13:16 +08:00
|
|
|
private FGUI.ZM_Sign_06.com_sign_in ui;
|
2026-04-22 09:52:55 +08:00
|
|
|
|
2026-04-23 10:25:32 +08:00
|
|
|
private int _signNum = 15;
|
2026-04-22 09:52:55 +08:00
|
|
|
|
|
|
|
|
public SignInViewUI(SignInViewUICtrl ctrl) : base(ctrl)
|
|
|
|
|
{
|
|
|
|
|
uiName = UIConst.SignInViewUI;
|
|
|
|
|
this.ctrl = ctrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
uiInfo.packageName = "ZM_Sign_06";
|
2026-04-22 09:52:55 +08:00
|
|
|
uiInfo.assetName = "com_sign_in";
|
|
|
|
|
uiInfo.layerType = UILayerType.Popup;
|
2026-04-22 11:13:16 +08:00
|
|
|
uiInfo.isNeedOpenAnim = true;
|
|
|
|
|
uiInfo.isNeedCloseAnim = true;
|
2026-04-22 09:52:55 +08:00
|
|
|
uiInfo.isNeedUIMask = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 生命周期
|
|
|
|
|
protected override void OnInit()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnClose()
|
|
|
|
|
{
|
|
|
|
|
GameHelper.showGameUI = true;
|
2026-04-22 11:13:16 +08:00
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnBind()
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
ui = baseUI as FGUI.ZM_Sign_06.com_sign_in;
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
private List<btn_sign> btnSignList = new List<btn_sign>();
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
protected override void OnOpenBefore(object args)
|
|
|
|
|
{
|
|
|
|
|
if (Screen.safeArea.y != 0)
|
|
|
|
|
{
|
|
|
|
|
ui.com_gold.y += Screen.safeArea.y;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
for (var i = 0; i < _signNum; i++)
|
|
|
|
|
{
|
|
|
|
|
btnSignList.Add(ui.GetChild($"btn_{i+1}") as btn_sign);
|
|
|
|
|
}
|
2026-04-22 09:52:55 +08:00
|
|
|
|
|
|
|
|
InitView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
//初始化动画列表
|
|
|
|
|
private void SetListHasAnimation(List<SkeletonAnimation> animList, int index, GGraph parent, Fx_Type fxType)
|
|
|
|
|
{
|
|
|
|
|
int realIndex = index;
|
|
|
|
|
|
|
|
|
|
// 扩展列表到目标索引
|
|
|
|
|
while (realIndex >= animList.Count)
|
|
|
|
|
{
|
|
|
|
|
animList.Add(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果目标位置没有动画,则设置
|
|
|
|
|
if (animList[realIndex] == null)
|
|
|
|
|
{
|
|
|
|
|
animList[realIndex] = FXManager.Instance.SetFx<SkeletonAnimation>(parent, fxType, ref closeCallback);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
//初始化页面逻辑
|
2026-04-22 11:13:16 +08:00
|
|
|
private readonly List<SignDailyReward> signList = ConfigSystem.GetConfig<SignDailyReward>();
|
|
|
|
|
private List<SkeletonAnimation> sign_anims = new List<SkeletonAnimation>();
|
|
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
private void InitView()
|
|
|
|
|
{
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
Debug.Log($"signList.Count:{signList.Count}");
|
2026-04-22 09:52:55 +08:00
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
for (var i = 0; i < _signNum; i++)
|
2026-04-22 09:52:55 +08:00
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
RefreshView(i);
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
ui.com_gold.GetChild("text_gold").text = $"{DataMgr.Coin.Value:N0}";
|
|
|
|
|
ui.close.SetClick(CtrlCloseUI);
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
private void RefreshView(int index)
|
2026-04-22 09:52:55 +08:00
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
Debug.Log($" index ========== :{index}");
|
|
|
|
|
btn_sign btnSign = btnSignList[index];;
|
2026-04-23 10:25:32 +08:00
|
|
|
btnSign.state.selectedIndex = 0;
|
|
|
|
|
btnSign.title = signList[index].id + "";
|
2026-04-27 10:11:52 +08:00
|
|
|
|
2026-04-23 10:25:32 +08:00
|
|
|
btnSign.touchable = false;
|
2026-04-22 11:13:16 +08:00
|
|
|
btnSign.reward_num.text = GameHelper.Get101Str(signList[index].quantity[0]);
|
|
|
|
|
|
|
|
|
|
var animName = "appear2";
|
2026-04-23 10:25:32 +08:00
|
|
|
if (index % 5 == 4)
|
2026-04-22 11:13:16 +08:00
|
|
|
{
|
2026-04-23 10:25:32 +08:00
|
|
|
btnSign.state.selectedIndex = 2;
|
2026-04-22 11:13:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var signDays = DataMgr.SignState.Value.Count;
|
2026-04-22 09:52:55 +08:00
|
|
|
var isToday = true;
|
|
|
|
|
if (signDays > 0)
|
2026-04-22 11:13:16 +08:00
|
|
|
isToday = GameHelper.InToday(DataMgr.SignState.Value[signDays - 1], 0, true);
|
2026-04-27 10:11:52 +08:00
|
|
|
|
|
|
|
|
ui.btn_collect.state.selectedIndex = index == signDays && !(signDays > 0 && isToday)? 0 : 1;
|
|
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
if (index < signDays)
|
|
|
|
|
{
|
2026-04-23 10:25:32 +08:00
|
|
|
btnSign.state.selectedIndex = 3;
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
|
|
|
|
else if (index == signDays)
|
|
|
|
|
{
|
|
|
|
|
if (signDays > 0 && isToday)
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
|
|
|
|
|
// btnSign.status.selectedIndex = btn_sign.Status_reward;
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2026-04-23 10:25:32 +08:00
|
|
|
btnSign.state.selectedIndex = 1;
|
2026-04-22 11:13:16 +08:00
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
btnSign.isCloseClickAnim = true;
|
|
|
|
|
// btnSign.status.selectedIndex = btn_sign.State_today;
|
|
|
|
|
|
2026-04-23 10:25:32 +08:00
|
|
|
ui.btn_collect.SetClick(() =>
|
2026-04-22 09:52:55 +08:00
|
|
|
{
|
2026-04-23 10:25:32 +08:00
|
|
|
SetBtnClick(index);
|
2026-04-22 09:52:55 +08:00
|
|
|
});
|
2026-04-23 10:25:32 +08:00
|
|
|
// btnSign.SetClick(() =>
|
|
|
|
|
// {
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// });
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
// btnSign.status.selectedIndex = btn_sign.Status_reward;
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-23 10:25:32 +08:00
|
|
|
private void SetBtnClick(int index)
|
|
|
|
|
{
|
|
|
|
|
ui.btn_collect.onClick.Clear();
|
|
|
|
|
ui.btn_collect.touchable = false;
|
|
|
|
|
var startPos = GameHelper.GetUICenterPosition( ui.btn_collect);
|
|
|
|
|
DOVirtual.DelayedCall(0.3f, () =>
|
|
|
|
|
{
|
|
|
|
|
ui.btn_collect.state.selectedIndex = 1;
|
|
|
|
|
GetSignInReward(signList[index], startPos, ui.btn_collect,index);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
private Action closeCallback;
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
private void GetSignInReward(SignDailyReward vo, Vector2 startPos, GButton btnDay,int index)
|
2026-04-22 09:52:55 +08:00
|
|
|
{
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
GameHelper.addInterAdnumber();
|
|
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
var rewardModel = new RewardData();
|
|
|
|
|
for (var i = 0; i < vo.item1.Length; i++)
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
var rewardData = new RewardSingleData(101, vo.quantity[i], RewardOrigin.SignIn,index)
|
2026-04-22 09:52:55 +08:00
|
|
|
{
|
|
|
|
|
startPosition = startPos,
|
2026-04-22 11:13:16 +08:00
|
|
|
endPosition = new Vector2(ui.com_gold.x - 150, ui.com_gold.y - 136)
|
2026-04-22 09:52:55 +08:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
rewardModel.AddReward(rewardData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (vo.is_com_reward)
|
|
|
|
|
rewardModel.displayType = RewardDisplayType.RewardFly | RewardDisplayType.Dialog |
|
|
|
|
|
RewardDisplayType.ValueChange;
|
|
|
|
|
else
|
|
|
|
|
rewardModel.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
|
|
|
|
|
|
|
|
|
if (vo.is_double) rewardModel.condition = RewardCondition.None;
|
|
|
|
|
|
|
|
|
|
rewardModel.AddCompleted(isSuccess =>
|
|
|
|
|
{
|
|
|
|
|
if (isSuccess)
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
DataMgr.SignState.Value.Add(GameHelper.GetNowTime());
|
|
|
|
|
DataMgr.SignState.Save();
|
2026-04-22 09:52:55 +08:00
|
|
|
|
|
|
|
|
InitView();
|
2026-04-23 10:25:32 +08:00
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
AudioManager.Instance.PlayDynamicEffect(AudioConst.DailyBonusCollect);
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
// 用来刷新todo界面的一些信息,如红点等
|
2026-04-22 09:52:55 +08:00
|
|
|
// GameDispatcher.Instance.Dispatch(GameMsg.UpdateTodoView);
|
|
|
|
|
CommonHelper.ShowNumAnim(ui.com_gold.GetChild("text_gold") as GTextField, vo.quantity[0], 101);
|
2026-04-22 11:13:16 +08:00
|
|
|
GameDispatcher.Instance.Dispatch(GameMsg.RefreshRedDot);
|
2026-04-22 09:52:55 +08:00
|
|
|
|
|
|
|
|
// CtrlCloseUI();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardModel);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-22 11:13:16 +08:00
|
|
|
}
|