444 lines
17 KiB
C#
444 lines
17 KiB
C#
using UnityEngine;
|
|||
|
|
using DG.Tweening;
|
||
|
|
using System;
|
||
|
|
using FGUI.ZM_Common_01;
|
||
|
|
using FairyGUI;
|
||
|
|
using System.Linq;
|
||
|
|
using Spine.Unity;
|
||
|
|
using IgnoreOPS;
|
||
|
|
|
||
|
|
namespace ZooMatch
|
||
|
|
{
|
||
|
|
public class GameResultUI : BaseUI
|
||
|
|
{
|
||
|
|
private GameResultUICtrl ctrl;
|
||
|
|
private GameResultModel model;
|
||
|
|
private FGUI.ZM_GameResult_08.com_end ui;
|
||
|
|
private bool IsWin;
|
||
|
|
private bool IsLevelSuccess;
|
||
|
|
private bool IsH5Reward;
|
||
|
|
|
||
|
|
private float AwardGoldNum = 20;
|
||
|
|
private Action closeCallback;
|
||
|
|
|
||
|
|
private int AwardRate = 1;
|
||
|
|
|
||
|
|
public GameResultUI(GameResultUICtrl ctrl) : base(ctrl)
|
||
|
|
{
|
||
|
|
uiName = UIConst.GameResultUI;
|
||
|
|
this.ctrl = ctrl;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
||
|
|
{
|
||
|
|
uiInfo.packageName = "ZM_GameResult_08";
|
||
|
|
uiInfo.assetName = "com_end";
|
||
|
|
uiInfo.layerType = UILayerType.Popup;
|
||
|
|
uiInfo.isNeedOpenAnim = false;
|
||
|
|
uiInfo.isNeedCloseAnim = false;
|
||
|
|
uiInfo.isNeedUIMask = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
#region 生命周期
|
||
|
|
protected override void OnInit()
|
||
|
|
{
|
||
|
|
//model = ModuleManager.Instance.GetModel(ModelConst.GameResultModel) as GameResultModel;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnClose()
|
||
|
|
{
|
||
|
|
GameHelper.SetCloseResult(false);
|
||
|
|
closeCallback?.Invoke();
|
||
|
|
HallManager.Instance.UpdateSecondEvent -= timeEvent;
|
||
|
|
if (IsLevelSuccess && !GameHelper.is_first_login) UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open, IsWin);
|
||
|
|
if (IsH5Reward)
|
||
|
|
{
|
||
|
|
WebviewManager.Instance.ShowH5View(true);
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.resetH5progress);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
//
|
||
|
|
protected override void OnBind()
|
||
|
|
{
|
||
|
|
ui = baseUI as FGUI.ZM_GameResult_08.com_end;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnOpenBefore(object args)
|
||
|
|
{
|
||
|
|
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1) (ui.btn_mult.GetChild("img_saveingpot") as GImage).visible = true;
|
||
|
|
var data = args as SuccessData;
|
||
|
|
IsH5Reward = data.IsH5Reward;
|
||
|
|
IsLevelSuccess = data.IsLevelSuccess;
|
||
|
|
|
||
|
|
if (GameHelper.IsGiftSwitch() && IsLevelSuccess && !IsH5Reward) {
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Open);
|
||
|
|
|
||
|
|
GameHelper.PlayGameTimeEvent(1, () => {
|
||
|
|
GameHelper.RequestGameConfig();
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
GameHelper.SetCloseResult(true);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if (Screen.safeArea.y != 0)
|
||
|
|
{
|
||
|
|
// ui.btn_gold.y += Screen.safeArea.y;
|
||
|
|
ui.top_money.y += Screen.safeArea.y;
|
||
|
|
ui.tips.y += Screen.safeArea.y;
|
||
|
|
}
|
||
|
|
|
||
|
|
HallManager.Instance.UpdateSecondEvent += timeEvent;
|
||
|
|
|
||
|
|
if (GameHelper.IsGiftSwitch())
|
||
|
|
{
|
||
|
|
ui.switchgift.selectedIndex = 1;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ui.switchgift.selectedIndex = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// AwardNum = data.cash_number;
|
||
|
|
IsWin = data.IsWin;
|
||
|
|
if (IsWin)
|
||
|
|
{
|
||
|
|
if (AudioManager.Instance.IsOpenEffect)
|
||
|
|
{
|
||
|
|
AudioManager.Instance.PlayDynamicEffect(AudioConst.Victoriously);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
if (IsWin)
|
||
|
|
{
|
||
|
|
ui.win_lose.selectedIndex = ui._Win_lose_win;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ui.win_lose.selectedIndex = ui._Win_lose_lose;
|
||
|
|
}
|
||
|
|
|
||
|
|
ui.btn_restart.SetClick(() =>
|
||
|
|
{
|
||
|
|
if (!GameHelper.GetCloseResult()) return;
|
||
|
|
|
||
|
|
GameHelper.addInterAdnumber();
|
||
|
|
if (!IsWin) GameHelper.SetLevelstate(3);
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Close);
|
||
|
|
});
|
||
|
|
ui.top_money.GetChild("number_text").text = GameHelper.Get102Str();
|
||
|
|
ui.top_money.GetChild("btn_cash").visible = false;
|
||
|
|
|
||
|
|
float cash_number = data.cash_number;
|
||
|
|
|
||
|
|
if (IsWin)
|
||
|
|
{
|
||
|
|
AwardRate = data.rate;
|
||
|
|
ui.btn_mult.GetChild("title").text = "Claim X" + AwardRate;
|
||
|
|
var sk0 = FXManager.Instance.SetFx<SkeletonAnimation>(baseUI.GetChild("congra_parent") as GGraph, Fx_Type.fx_wins, ref closeCallback);
|
||
|
|
sk0.state.SetAnimation(0, "7rihuodong2", false);
|
||
|
|
|
||
|
|
var sk = FXManager.Instance.SetFx<SkeletonAnimation>(baseUI.GetChild("bg_parent") as GGraph, Fx_Type.fx_win, ref closeCallback);
|
||
|
|
sk.state.SetAnimation(0, "out", true);
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
InitView();
|
||
|
|
|
||
|
|
if (GameHelper.IsGiftSwitch())
|
||
|
|
{
|
||
|
|
if (IsWin) ui.text_award.text = GameHelper.Get102Str((decimal)cash_number);
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ui.text_award.text = GameHelper.Get102Str(PreferencesMgr.Instance.Currency102);
|
||
|
|
ui.top_money.visible = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
ui.btn_mult.SetClick(() =>
|
||
|
|
{
|
||
|
|
if (!GameHelper.GetCloseResult()) return;
|
||
|
|
|
||
|
|
GameHelper.ShowVideoAd("reward_lobby", isSuccess =>
|
||
|
|
{
|
||
|
|
if (isSuccess)
|
||
|
|
|
||
|
|
{
|
||
|
|
ui.com_cash.btn_cash.SetClick(() => { });
|
||
|
|
ui.btn_claim.SetClick(() => { });
|
||
|
|
ui.btn_mult.SetClick(() => { });
|
||
|
|
float reward = cash_number * AwardRate;
|
||
|
|
GetReward(reward);
|
||
|
|
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.RefreshMakeupData);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|
||
|
|
ui.btn_claim.SetClick(() =>
|
||
|
|
{
|
||
|
|
if (!GameHelper.GetCloseResult()) return;
|
||
|
|
|
||
|
|
ui.com_cash.btn_cash.SetClick(() => { });
|
||
|
|
ui.btn_claim.SetClick(() => { });
|
||
|
|
ui.btn_mult.SetClick(() => { });
|
||
|
|
DOVirtual.DelayedCall(2f, () =>
|
||
|
|
{
|
||
|
|
GameHelper.addInterAdnumber();
|
||
|
|
});
|
||
|
|
GetReward(cash_number);
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.RefreshMakeupData);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
var name_index = UnityEngine.Random.Range(0, ConfigSystem.GetConfig<exBrPoolModel>().config_name_list.Count);
|
||
|
|
var money_index = UnityEngine.Random.Range(0, ConfigSystem.GetConfig<exBrPoolModel>().config_money_list.Count);
|
||
|
|
|
||
|
|
System.DateTime oldtime = System.DateTime.Now.AddSeconds(-UnityEngine.Random.Range(1 * 3600, 2 * 3600));
|
||
|
|
// Debug.Log(ConfigSystem.GetConfig<exBrPoolModel>().config_name_list[name_index]);
|
||
|
|
ui.com_cash.broad.cast_text.text = string.Format("Congratulations, [color=#e3a13a]{0}[/color] withdraw [color=#83c93c]{1} [/color]dollars", ConfigSystem.GetConfig<exBrPoolModel>().config_name_list[name_index],
|
||
|
|
ConfigSystem.GetConfig<exBrPoolModel>().config_money_list[money_index]);
|
||
|
|
|
||
|
|
var makeupTaskData = PreferencesMgr.Instance.MakeupTaskHistory.Last();
|
||
|
|
var vo = ConfigSystem.GetConfig<MakeupModel>().GetData(makeupTaskData.tableId);
|
||
|
|
|
||
|
|
|
||
|
|
ui.com_cash.btn_cash.SetClick(() =>
|
||
|
|
{
|
||
|
|
if (!GameHelper.GetCloseResult()) return;
|
||
|
|
|
||
|
|
ui.com_cash.btn_cash.SetClick(() => { });
|
||
|
|
ui.btn_claim.SetClick(() => { });
|
||
|
|
ui.btn_mult.SetClick(() => { });
|
||
|
|
if (IsWin)
|
||
|
|
{
|
||
|
|
DOVirtual.DelayedCall(2f, () =>
|
||
|
|
{
|
||
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.MakeupConfirmUI_Open, makeupTaskData);
|
||
|
|
GameHelper.addInterAdnumber();
|
||
|
|
|
||
|
|
});
|
||
|
|
GetReward(cash_number);
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.RefreshMakeupData);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
uiCtrlDispatcher.Dispatch(UICtrlMsg.MakeupConfirmUI_Open, makeupTaskData);
|
||
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Close);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
ui.top_money.GetChild("btn_cashout").SetClick(() =>
|
||
|
|
{
|
||
|
|
ui.com_cash.btn_cash.FireClick(false, true);
|
||
|
|
});
|
||
|
|
|
||
|
|
if (GameHelper.GetLevel() <= vo.levels_need)
|
||
|
|
{
|
||
|
|
ui.com_cash.cash_text.text = "Withdrawals can be made through level " + vo.levels_need;
|
||
|
|
ui.com_cash.progress.width = 632f * (GameHelper.GetLevel() - 1) / vo.levels_need;
|
||
|
|
ui.com_cash.progress_text.text = (GameHelper.GetLevel() - 1) + "/" + vo.levels_need;
|
||
|
|
}
|
||
|
|
else if ((float)PreferencesMgr.Instance.Currency102 < vo.item_need)
|
||
|
|
{
|
||
|
|
ui.com_cash.cash_text.text = "Collect " + GameHelper.Get102Str(vo.item_need) + " to cash out";
|
||
|
|
if ((float)PreferencesMgr.Instance.Currency102 > vo.item_need)
|
||
|
|
{
|
||
|
|
ui.com_cash.progress.width = 632;
|
||
|
|
ui.com_cash.progress_text.text = GameHelper.Get102Str(vo.item_need) + "/" + GameHelper.Get102Str(vo.item_need);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ui.com_cash.progress.width = 632 * ((float)PreferencesMgr.Instance.Currency102 / vo.item_need);
|
||
|
|
ui.com_cash.progress_text.text = GameHelper.Get102Str(PreferencesMgr.Instance.Currency102) + "/" + GameHelper.Get102Str(vo.item_need);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Debug.Log((float)PreferencesMgr.Instance.Currency102);
|
||
|
|
}
|
||
|
|
else if ((float)PreferencesMgr.Instance.MakeupTaskH5Time < vo.task_need)
|
||
|
|
{
|
||
|
|
ui.com_cash.cash_text.text = "Cumulataive " + (vo.task_need / 60) + @" minutes in ""Hall"" to cash out";
|
||
|
|
if ((float)PreferencesMgr.Instance.MakeupTaskH5Time > vo.task_need)
|
||
|
|
{
|
||
|
|
ui.com_cash.progress.width = 632;
|
||
|
|
ui.com_cash.progress_text.text = (vo.task_need / 60) + "/" + (vo.task_need / 60);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ui.com_cash.progress.width = 632 * ((float)PreferencesMgr.Instance.MakeupTaskH5Time / vo.task_need);
|
||
|
|
ui.com_cash.progress_text.text = Math.Round(((float)(PreferencesMgr.Instance.MakeupTaskH5Time / 60)), 2) + "/" + (vo.task_need / 60);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
else if (makeupTaskData.videoCount < vo.ad_need)
|
||
|
|
{
|
||
|
|
|
||
|
|
ui.com_cash.cash_text.text = "Watch " + vo.ad_need + " Reward Ads to cash out";
|
||
|
|
if (makeupTaskData.videoCount > vo.ad_need)
|
||
|
|
{
|
||
|
|
ui.com_cash.progress.width = 632;
|
||
|
|
ui.com_cash.progress_text.text = vo.ad_need + "/" + vo.ad_need;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ui.com_cash.progress.width = 632 * ((float)makeupTaskData.videoCount / vo.ad_need);
|
||
|
|
ui.com_cash.progress_text.text = makeupTaskData.videoCount + "/" + vo.ad_need;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ui.com_cash.cash_text.text = "Watch " + vo.ad_need + " Reward Ads to cash out";
|
||
|
|
if (makeupTaskData.videoCount > vo.ad_need)
|
||
|
|
{
|
||
|
|
ui.com_cash.progress.width = 632;
|
||
|
|
ui.com_cash.progress_text.text = vo.ad_need + "/" + vo.ad_need;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
ui.com_cash.progress.width = 632 * ((float)makeupTaskData.videoCount / vo.ad_need);
|
||
|
|
ui.com_cash.progress_text.text = makeupTaskData.videoCount + "/" + vo.ad_need;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
|
||
|
|
ui.text_award.text = AwardGoldNum.ToString();
|
||
|
|
ui.btn_gold.GetChild("text_gold").text = $"{PreferencesMgr.Instance.Currency101:N0}";
|
||
|
|
|
||
|
|
ui.btn_mult.SetClick(() =>
|
||
|
|
{
|
||
|
|
if (!GameHelper.GetCloseResult()) return;
|
||
|
|
|
||
|
|
GameHelper.ShowVideoAd("reward_lobby", isSuccess =>
|
||
|
|
{
|
||
|
|
if (isSuccess)
|
||
|
|
|
||
|
|
{
|
||
|
|
ui.btn_claim.SetClick(() => { });
|
||
|
|
ui.btn_mult.SetClick(() => { });
|
||
|
|
|
||
|
|
GetReward(AwardGoldNum * AwardRate, 101);
|
||
|
|
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|
||
|
|
ui.btn_claim.SetClick(() =>
|
||
|
|
{
|
||
|
|
if (!GameHelper.GetCloseResult()) return;
|
||
|
|
|
||
|
|
ui.btn_claim.SetClick(() => { });
|
||
|
|
ui.btn_mult.SetClick(() => { });
|
||
|
|
|
||
|
|
GetReward(AwardGoldNum, 101);
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void GetReward(float awardNum, int id = 102)
|
||
|
|
{
|
||
|
|
var startObj = id == 102 ? ui.btn_mult : ui.btn_claim;
|
||
|
|
var endObj = id == 102 ? ui.top_money : ui.btn_gold;
|
||
|
|
|
||
|
|
var pos = GameHelper.GetUICenterPosition(endObj);
|
||
|
|
|
||
|
|
var rewardData = new RewardData();
|
||
|
|
var rewardSingleData = new RewardSingleData(id, (decimal)awardNum, RewardOrigin.Play)
|
||
|
|
{
|
||
|
|
startPosition = GameHelper.GetUICenterPosition(startObj),
|
||
|
|
endPosition = new Vector2(pos.x - 260, pos.y - 136)
|
||
|
|
};
|
||
|
|
|
||
|
|
rewardData.AddReward(rewardSingleData);
|
||
|
|
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||
|
|
rewardData.AddCompleted(success =>
|
||
|
|
{
|
||
|
|
if (success)
|
||
|
|
{
|
||
|
|
RefreshAwardNum((decimal)awardNum, id);
|
||
|
|
|
||
|
|
DOVirtual.DelayedCall(1.5f, () =>
|
||
|
|
{
|
||
|
|
CtrlCloseUI();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void RefreshAwardNum(decimal num = -1, int id = 102)
|
||
|
|
{
|
||
|
|
if (num < 0)
|
||
|
|
{
|
||
|
|
num = id == 102 ? PreferencesMgr.Instance.Currency102 : PreferencesMgr.Instance.Currency101;
|
||
|
|
}
|
||
|
|
var btnCoin = ui.btn_gold as com_gold;
|
||
|
|
var money = ui.top_money as com_money;
|
||
|
|
|
||
|
|
GTextField gTextField = id == 102 ? money.number_text : btnCoin.text_gold;
|
||
|
|
CommonHelper.ShowNumAnim(gTextField, num, id);
|
||
|
|
}
|
||
|
|
|
||
|
|
private int time_count = 0;
|
||
|
|
|
||
|
|
void timeEvent()
|
||
|
|
{
|
||
|
|
time_count++;
|
||
|
|
|
||
|
|
if (time_count > 3)
|
||
|
|
{
|
||
|
|
time_count = 0;
|
||
|
|
ui.com_cash.broad.t0.Play(() =>
|
||
|
|
{
|
||
|
|
var name_index = UnityEngine.Random.Range(0, ConfigSystem.GetConfig<exBrPoolModel>().config_name_list.Count);
|
||
|
|
var money_index = UnityEngine.Random.Range(0, ConfigSystem.GetConfig<exBrPoolModel>().config_money_list.Count);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
System.DateTime oldtime = System.DateTime.Now.AddSeconds(-UnityEngine.Random.Range(1 * 3600, 2 * 3600));
|
||
|
|
ui.com_cash.broad.cast_text.text = string.Format("Congratulations, [color=#e3a13a]{0}[/color] withdraw [color=#83c93c]{1} [/color]dollars ", ConfigSystem.GetConfig<exBrPoolModel>().config_name_list[name_index],
|
||
|
|
ConfigSystem.GetConfig<exBrPoolModel>().config_money_list[money_index]);
|
||
|
|
//, oldtime.Hour + ":" + (oldtime.Minute > 10 ? oldtime.Minute : "0" + oldtime.Minute)
|
||
|
|
ui.com_cash.broad.t1.Play();
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
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()
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|