fix:1、添加项目
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
// using FGUI.G002_main;
|
||||
using Spine.Unity;
|
||||
using DG.Tweening;
|
||||
using FGUI.P06_Hall;
|
||||
using FGUI.P01_Common;
|
||||
|
||||
namespace FlowerPower
|
||||
{
|
||||
public class FirstRewardUI : BaseUI
|
||||
{
|
||||
private FirstRewardUICtrl ctrl;
|
||||
private FirstRewardModel model;
|
||||
private FGUI.P06_Hall.com_first_award ui;
|
||||
private Action closeCallback;
|
||||
private Action open_sign;
|
||||
private bool is_get = false;
|
||||
public FirstRewardUI(FirstRewardUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.FirstRewardUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "P06_Hall";
|
||||
uiInfo.assetName = "com_first_award";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
model = ModuleManager.Instance.GetModel(ModelConst.FirstRewardModel) as FirstRewardModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
closeCallback();
|
||||
//open_sign();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.P06_Hall.com_first_award;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
if (Screen.safeArea.y != 0)
|
||||
{//刘海屏
|
||||
ui.money.y += Screen.safeArea.y;
|
||||
}
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
//open_sign = (System.Action)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.money.GetChild("text_gold").text = $"{PreferencesMgr.Instance.Currency101:N0}";
|
||||
ui.money.GetChild("btn_ch").visible = false;
|
||||
com_money money = ui.money as com_money;
|
||||
money.btn_ch.visible = false;
|
||||
money.number_text.text = GameHelper.Get102Str();
|
||||
|
||||
ui.text_num.text = GameHelper.Get102Str(ConfigSystem.GetConfig<CommonModel>().InitialNum);
|
||||
var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.spine_parent, Fx_Type.fx_first_reward, ref closeCallback);
|
||||
sk.state.SetAnimation(0, "newbie_reward_an01", false);
|
||||
sk.state.Complete += (a) =>
|
||||
{
|
||||
sk.state.SetAnimation(0, "newbie_reward_an02", true);
|
||||
ui.btn_getreward.SetClick(() =>
|
||||
{
|
||||
ui.btn_getreward.visible = false;
|
||||
sk.state.SetAnimation(0, "newbie_reward_an03", false);
|
||||
sk.state.Complete += (a) =>
|
||||
{
|
||||
ui.state.selectedIndex = com_first_award.State_page;
|
||||
};
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
ui.btn_get.SetClick(GetReward);
|
||||
ui.btn_close.SetClick(GetReward);
|
||||
}
|
||||
private void GetReward()
|
||||
{
|
||||
|
||||
com_money money = ui.money as com_money;
|
||||
|
||||
if (is_get) return;
|
||||
is_get = true;
|
||||
|
||||
|
||||
var start = GameHelper.GetUICenterPosition(ui.img_money);
|
||||
var end = GameHelper.GetUICenterPosition(ui.money.GetChild("icon"));
|
||||
|
||||
int awardNum = ConfigSystem.GetConfig<CommonModel>().InitialNum;
|
||||
|
||||
var rewardData = new RewardData();
|
||||
|
||||
var rewardSingleData = new RewardSingleData(102, awardNum, RewardOrigin.AdTask)
|
||||
{
|
||||
startPosition = start,
|
||||
endPosition = new Vector2(end.x - 150, end.y - 136)
|
||||
};
|
||||
|
||||
rewardData.AddReward(rewardSingleData);
|
||||
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
rewardData.AddCompleted(success =>
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
var startNum = PreferencesMgr.Instance.Currency102 - awardNum;
|
||||
DOVirtual.Float((float)startNum, (float)PreferencesMgr.Instance.Currency102, 1,
|
||||
value => { money.number_text.text = GameHelper.Get102Str((decimal)value); });
|
||||
SaveData.GetSaveobject().isGetFirstGift = 1;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UpdateCurrency102);
|
||||
DOVirtual.DelayedCall(1.5f, () =>
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.FirstRewardUI_Close);
|
||||
});
|
||||
}
|
||||
});
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user