238 lines
7.9 KiB
C#
238 lines
7.9 KiB
C#
|
|
// using FGUI.A000_common;
|
||
|
|
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using FairyGUI;
|
||
|
|
using FGUI.P03_SignIn;
|
||
|
|
using Spine.Unity;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace FlowerPower
|
||
|
|
{
|
||
|
|
public class SignInViewUI : BaseUI
|
||
|
|
{
|
||
|
|
private SignInViewUICtrl ctrl;
|
||
|
|
private SignInViewModel model;
|
||
|
|
private SignDailyRewardModel signModel;
|
||
|
|
|
||
|
|
private FGUI.P03_SignIn.com_sign_in ui;
|
||
|
|
|
||
|
|
private List<btn_sign> signBtnList = new List<btn_sign>();
|
||
|
|
|
||
|
|
public SignInViewUI(SignInViewUICtrl ctrl) : base(ctrl)
|
||
|
|
{
|
||
|
|
uiName = UIConst.SignInViewUI;
|
||
|
|
this.ctrl = ctrl;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
||
|
|
{
|
||
|
|
uiInfo.packageName = "P03_SignIn";
|
||
|
|
uiInfo.assetName = "com_sign_in";
|
||
|
|
uiInfo.layerType = UILayerType.Popup;
|
||
|
|
uiInfo.isNeedOpenAnim = false;
|
||
|
|
uiInfo.isNeedCloseAnim = false;
|
||
|
|
uiInfo.isNeedUIMask = true;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
#region 生命周期
|
||
|
|
protected override void OnInit()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnClose()
|
||
|
|
{
|
||
|
|
GameHelper.showGameUI = true;
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.RefreshRedDot);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnBind()
|
||
|
|
{
|
||
|
|
ui = baseUI as FGUI.P03_SignIn.com_sign_in;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnOpenBefore(object args)
|
||
|
|
{
|
||
|
|
if (Screen.safeArea.y != 0)
|
||
|
|
{
|
||
|
|
ui.com_gold.y += Screen.safeArea.y;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
signBtnList.Add(ui.day1);
|
||
|
|
signBtnList.Add(ui.day2);
|
||
|
|
signBtnList.Add(ui.day3);
|
||
|
|
signBtnList.Add(ui.day4);
|
||
|
|
signBtnList.Add(ui.day5);
|
||
|
|
signBtnList.Add(ui.day6);
|
||
|
|
signBtnList.Add(ui.day7);
|
||
|
|
|
||
|
|
signModel = ConfigSystem.GetConfig<SignDailyRewardModel>();
|
||
|
|
|
||
|
|
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
|
||
|
|
|
||
|
|
//初始化页面逻辑
|
||
|
|
private void InitView()
|
||
|
|
{
|
||
|
|
var fx_coin = FXManager.Instance.SetFx<SkeletonAnimation>(ui.com_gold.GetChild("ani_node") as GGraph, Fx_Type.fx_coin, ref closeCallback);
|
||
|
|
fx_coin.state.SetAnimation(0, "animation", true);
|
||
|
|
|
||
|
|
var signList = signModel.dataList;
|
||
|
|
|
||
|
|
// Debug.Log($"signList.Count:{signList.Count}");
|
||
|
|
for (int i = 0; i < signList.Count; i++)
|
||
|
|
{
|
||
|
|
if (i < 7)
|
||
|
|
{
|
||
|
|
RefreshView(signBtnList[i], signList[i], i);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
ui.com_gold.GetChild("text_gold").text = $"{PreferencesMgr.Instance.Currency101:N0}";
|
||
|
|
ui.btn_close.SetClick(CtrlCloseUI);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void RefreshView(btn_sign btnSign, SignDailyReward reward, int index)
|
||
|
|
{
|
||
|
|
// if (index == 0) {
|
||
|
|
// var fx_coin = FXManager.Instance.SetFx<SkeletonAnimation>(btnSign.GetChild("ani_node") as GGraph, Fx_Type.fx_sign, ref closeCallback);
|
||
|
|
// fx_coin.state.SetAnimation(0, "daiji", true);
|
||
|
|
// } else if (index == 1) {
|
||
|
|
// var fx_coin = FXManager.Instance.SetFx<SkeletonAnimation>(btnSign.GetChild("ani_node") as GGraph, Fx_Type.fx_sign, ref closeCallback);
|
||
|
|
// fx_coin.state.SetAnimation(0, "lingqu", true);
|
||
|
|
// } else if (index == 2) {
|
||
|
|
// var fx_coin = FXManager.Instance.SetFx<SkeletonAnimation>(btnSign.GetChild("ani_node") as GGraph, Fx_Type.fx_sign, ref closeCallback);
|
||
|
|
// fx_coin.state.SetAnimation(0, "lingqudaiji", true);
|
||
|
|
// }
|
||
|
|
var fx_sign = FXManager.Instance.SetFx<SkeletonAnimation>(btnSign.GetChild("ani_node") as GGraph, Fx_Type.fx_sign, ref closeCallback);
|
||
|
|
// fx_sign.SetActive(false);
|
||
|
|
|
||
|
|
|
||
|
|
btnSign.title = "0" + reward.id;
|
||
|
|
btnSign.reward_num.text = GameHelper.Get101Str(reward.quantity[0]);
|
||
|
|
|
||
|
|
|
||
|
|
var signDays = PreferencesMgr.Instance.SignState.Count;
|
||
|
|
var isToday = true;
|
||
|
|
if (signDays > 0)
|
||
|
|
isToday = GameHelper.InToday(PreferencesMgr.Instance.SignState[signDays - 1], 0, true);
|
||
|
|
if (index < signDays)
|
||
|
|
{
|
||
|
|
btnSign.status.selectedIndex = btn_sign.Status_unreward;
|
||
|
|
}
|
||
|
|
else if (index == signDays)
|
||
|
|
{
|
||
|
|
if (signDays > 0 && isToday)
|
||
|
|
{
|
||
|
|
btnSign.GetChild("ani_node").visible = false;
|
||
|
|
btnSign.status.selectedIndex = btn_sign.Status_reward;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
fx_sign.state.SetAnimation(0, "daiji", true);
|
||
|
|
btnSign.status.selectedIndex = 2;
|
||
|
|
// btnSign.t0.Play();
|
||
|
|
btnSign.isCloseClickAnim = true;
|
||
|
|
// btnSign.status.selectedIndex = btn_sign.State_today;
|
||
|
|
|
||
|
|
btnSign.SetClick(() =>
|
||
|
|
{
|
||
|
|
fx_sign.state.SetAnimation(0, "lingqu", false);
|
||
|
|
fx_sign.state.Complete += (a) => {
|
||
|
|
btnSign.GetChild("ani_node").visible = false;
|
||
|
|
btnSign.status.selectedIndex = btn_sign.Status_unreward;
|
||
|
|
|
||
|
|
var startPos = GameHelper.GetUICenterPosition(btnSign);
|
||
|
|
btnSign.onClick.Clear();
|
||
|
|
btnSign.touchable = false;
|
||
|
|
|
||
|
|
|
||
|
|
GetSignInReward(reward, startPos, btnSign, index);
|
||
|
|
};
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
btnSign.GetChild("ani_node").visible = false;
|
||
|
|
btnSign.status.selectedIndex = btn_sign.Status_reward;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private Action closeCallback;
|
||
|
|
|
||
|
|
private void GetSignInReward(SignDailyReward vo, Vector2 startPos, GButton btnDay, int index)
|
||
|
|
{
|
||
|
|
|
||
|
|
var rewardModel = new RewardData();
|
||
|
|
for (var i = 0; i < vo.item1.Length; i++)
|
||
|
|
{
|
||
|
|
var rewardData = new RewardSingleData(101, vo.quantity[i], RewardOrigin.SignIn, index)
|
||
|
|
{
|
||
|
|
startPosition = startPos,
|
||
|
|
endPosition = new Vector2(ui.point.x - 150, ui.point.y - 136)
|
||
|
|
|
||
|
|
};
|
||
|
|
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)
|
||
|
|
{
|
||
|
|
PreferencesMgr.Instance.SignState.Add(GameHelper.GetNowTime());
|
||
|
|
PreferencesMgr.Instance.SaveSignState();
|
||
|
|
|
||
|
|
InitView();
|
||
|
|
|
||
|
|
btnDay.onClick.Clear();
|
||
|
|
AudioManager.Instance.PlayDynamicEffect(AudioConst.DailyBonusCollect);
|
||
|
|
|
||
|
|
// 用来刷新todo界面的一些信息,如红点等
|
||
|
|
// GameDispatcher.Instance.Dispatch(GameMsg.UpdateTodoView);
|
||
|
|
CommonHelper.ShowNumAnim(ui.com_gold.GetChild("text_gold") as GTextField, vo.quantity[0], 101);
|
||
|
|
|
||
|
|
|
||
|
|
// CtrlCloseUI();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardModel);
|
||
|
|
// ui.visible = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|