508 lines
16 KiB
C#
508 lines
16 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BingoBrain.Core;
|
|
using BingoBrain.HotFix;
|
|
using DG.Tweening;
|
|
using DontConfuse;
|
|
using FGUI.ACommon;
|
|
using UnityEngine;
|
|
|
|
namespace BingoBrain
|
|
{
|
|
public class H5UI : BaseUI
|
|
{
|
|
private H5UICtrl ctrl;
|
|
private H5Model model;
|
|
private FGUI.G004_webview.com_webview ui;
|
|
|
|
public H5UI(H5UICtrl ctrl) : base(ctrl)
|
|
{
|
|
uiName = UIConst.H5UI;
|
|
this.ctrl = ctrl;
|
|
}
|
|
bool isScrolling;
|
|
|
|
|
|
private bool isTimeOut = false;
|
|
|
|
|
|
private decimal scrollOutTime;
|
|
|
|
|
|
private bool isLoadFinish;
|
|
|
|
|
|
private bool isCurrentTaskFinish;
|
|
|
|
|
|
private bool isCurrentTimeTask;
|
|
|
|
|
|
private bool isAddFinger;
|
|
|
|
private long openTime;
|
|
|
|
private int iconClickCount;
|
|
|
|
private int flyClickCount;
|
|
|
|
private int flyNeedClickCount = 0;
|
|
|
|
private int currentTabIndex;
|
|
|
|
private decimal makeupTaskH5NeedTime;
|
|
|
|
|
|
private Tween bubbleMoveTween;
|
|
|
|
private List<Vector3> movePointList = new List<Vector3>();
|
|
//private CountDownKit countDownKit;
|
|
private int sendH5point = 0;
|
|
private SaveingPotClass makeupTaskData_saveing;
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
|
{
|
|
uiInfo.packageName = "G004_webview";
|
|
uiInfo.assetName = "com_webview";
|
|
uiInfo.layerType = UILayerType.Popup;
|
|
uiInfo.isNeedOpenAnim = false;
|
|
uiInfo.isNeedCloseAnim = false;
|
|
uiInfo.isNeedUIMask = false;
|
|
uiInfo.isTickUpdate = true;
|
|
}
|
|
|
|
#region 生命周期
|
|
protected override void OnInit()
|
|
{
|
|
//model = ModuleManager.Instance.GetModel(ModelConst.H5Model) as H5Model;
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
|
|
//WebThroughUtil.WebThroughDisable(H5WebThroughType.OnlineH5, ui.btn_icon);
|
|
//Hall.Instance.SetInH5(false);
|
|
// StopFly();
|
|
// countDownKit?.OnDestroy();
|
|
|
|
OnStatisticH5Time();
|
|
|
|
|
|
WebviewManager.Instance.setInH5View(false);
|
|
WebviewManager.Instance.ShowH5View(false);
|
|
|
|
// if (GameHelper.is_first_login)
|
|
// {
|
|
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Open);
|
|
// GameHelper.is_first_login = false;
|
|
// }
|
|
}
|
|
private void OnStatisticH5Time()
|
|
{
|
|
var time = GameHelper.GetNowTime() - openTime;
|
|
PreferencesMgr.Instance.H5StayTime += (int)time;
|
|
}
|
|
|
|
protected override void OnBind()
|
|
{
|
|
ui = baseUI as FGUI.G004_webview.com_webview;
|
|
}
|
|
|
|
protected override void OnOpenBefore(object args)
|
|
{
|
|
ui.btn_close.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(SkinInfo.H5UI_Close); });
|
|
if (Screen.safeArea.y != 0)
|
|
{//刘海屏
|
|
ui.gruop_.y += Screen.safeArea.y;
|
|
}
|
|
makeupTaskData_saveing = SaveData.GetSaveobject().saveingpot_history[SaveData.GetSaveobject().saveingpot_history.Count - 1];
|
|
WebviewManager.Instance.setInH5View(true);
|
|
WebviewManager.Instance.ShowH5View(true);
|
|
InitData();
|
|
InitView();
|
|
if (!GameHelper.IsGiftSwitch())
|
|
{
|
|
ui.com_top.visible = ui.btn_out.visible = false;
|
|
}
|
|
}
|
|
|
|
protected override void OnOpen(object args)
|
|
{
|
|
openTime = GameHelper.GetNowTime();
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
}
|
|
|
|
protected override void OnDisplay(object args)
|
|
{
|
|
}
|
|
#endregion
|
|
|
|
#region 消息
|
|
protected override void AddListener()
|
|
{
|
|
//UICtrlDispatcher.Instance.AddListener(SkinInfo.MakeupConfirmUI_Close, SetMakeup);
|
|
GameDispatcher.Instance.AddListener(BingoInfo.RefreshMakeupData, SetMakeup);
|
|
GameDispatcher.Instance.AddListener(BingoInfo.resetH5progress, resetTime);
|
|
}
|
|
protected override void RemoveListener()
|
|
{
|
|
//UICtrlDispatcher.Instance.RemoveListener(UICtrlMsg.MakeupConfirmUI_Close, SetMakeup);
|
|
GameDispatcher.Instance.RemoveListener(BingoInfo.RefreshMakeupData, SetMakeup);
|
|
GameDispatcher.Instance.RemoveListener(BingoInfo.resetH5progress, resetTime);
|
|
}
|
|
#endregion
|
|
void resetTime(object a = null)
|
|
{
|
|
iconTime = 0;
|
|
}
|
|
decimal iconTime = 0;
|
|
private decimal updateTime;
|
|
public override void OnUpdate()
|
|
{
|
|
if (iconTime < ConfigSystem.GetConfig<CommonModel>().ThroughRewardCD)
|
|
{
|
|
iconTime += (decimal)Time.deltaTime;
|
|
UpdateIcon();
|
|
}
|
|
CheckShowFly();
|
|
|
|
updateTime += (decimal)Time.deltaTime;
|
|
|
|
// if (makeupTaskH5NeedTime > 0 && PreferencesMgr.Instance.MakeupTaskH5Time < makeupTaskH5NeedTime)
|
|
// {
|
|
if (updateTime >= 1)
|
|
{
|
|
#if UNITY_EDITOR
|
|
updateTime = 600;
|
|
#endif
|
|
if (PreferencesMgr.Instance.MakeupTaskH5Time > 60 &&
|
|
((PreferencesMgr.Instance.MakeupTaskH5Time % 60) < 1))
|
|
{
|
|
// NetworkKit.BuriedPoint(BuriedPointEvent.h5_event, BuriedPointEvent.h5_event_time, 60);
|
|
}
|
|
|
|
if (sendH5point == 1)
|
|
{
|
|
PlayerPrefs.SetInt("sendH5point", 0);
|
|
sendH5point = 0;
|
|
}
|
|
PreferencesMgr.Instance.MakeupTaskH5Time += updateTime;
|
|
PreferencesMgr.Instance.CoinMakeupTaskH5Time += updateTime;
|
|
|
|
if (makeupTaskData_saveing.status == SaveingPotTaskStatus.None)
|
|
{
|
|
if (PreferencesMgr.Instance.ExchangeAccount != null)
|
|
{
|
|
makeupTaskData_saveing.H5Time += (float)updateTime;
|
|
}
|
|
|
|
}
|
|
updateTime = 0;
|
|
|
|
}
|
|
// }
|
|
// else if (makeupTaskH5NeedTime > 0 && PreferencesMgr.Instance.MakeupTaskH5Time >= makeupTaskH5NeedTime)
|
|
// {
|
|
// if (sendH5point == 0)
|
|
// {
|
|
// NetworkKit.BuriedPoint(BuriedPointEvent.h5_event, BuriedPointEvent.h5_event_numbers, 1);
|
|
// sendH5point = 1;
|
|
// PlayerPrefs.SetInt("sendH5point", 1);
|
|
// }
|
|
// }
|
|
|
|
|
|
}
|
|
//初始化页面逻辑
|
|
private void InitData()
|
|
{
|
|
|
|
// model.show101 = PreferencesMgr.Instance.Currency101;
|
|
flyNeedClickCount = UnityEngine.Random.Range(ConfigSystem.GetConfig<CommonModel>().flyAdTime[0],
|
|
ConfigSystem.GetConfig<CommonModel>().flyAdTime[1] + 1);
|
|
//flyNeedClickCount = 5;
|
|
|
|
// if (PreferencesMgr.Instance.MakeupTaskHistory.Count > 0)
|
|
// {
|
|
// var taskData = PreferencesMgr.Instance.MakeupTaskHistory.Last();
|
|
// if (taskData != null)
|
|
// {
|
|
// Makeup makeupVo = null;
|
|
// foreach (var makeup in ConfigSystem.GetConfig<MakeupModel>().dataList)
|
|
// {
|
|
// if (makeup.id == taskData.tableId)
|
|
// {
|
|
// makeupVo = makeup;
|
|
// break;
|
|
// }
|
|
// }
|
|
|
|
// makeupTaskH5NeedTime = makeupVo.task_need;
|
|
// }
|
|
// }
|
|
|
|
sendH5point = PlayerPrefs.GetInt("sendH5point", 0);
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
isLoadFinish = true;
|
|
#endif
|
|
}
|
|
private void InitView()
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// InitIcon();
|
|
// CheckShowFly();
|
|
// ui.com_fly.SetClick(OnClickFlyCash);
|
|
// #endif
|
|
// SetMakeup();
|
|
|
|
|
|
//OnClickIcon();
|
|
SetMakeup();
|
|
WebviewManager.Instance.ShowFlyBtn(true);
|
|
UpdateIcon();
|
|
OnClickIcon();
|
|
}
|
|
|
|
private void UpdateIcon()
|
|
{
|
|
float amount = (float)iconTime / ConfigSystem.GetConfig<CommonModel>().ThroughRewardCD;
|
|
|
|
|
|
WebviewManager.Instance.SetIconProgress(amount);
|
|
// if (iconTime >= ConfigSystem.GetConfig<CommonModel>().ThroughRewardCD)
|
|
// {
|
|
// if (!ui.btn_icon.fx_ready.playing)
|
|
// {
|
|
// ui.btn_icon.fx_ready.Play();
|
|
// }
|
|
|
|
// ui.btn_icon.cont_state.selectedIndex = btn_icon.State_ready;
|
|
// }
|
|
// else
|
|
// {
|
|
// ui.btn_icon.fx_ready.Stop();
|
|
// }
|
|
}
|
|
private void OnClickIcon()
|
|
{
|
|
|
|
|
|
//WebThroughUtil.WebThroughClick(H5WebThroughType.OnlineH5, ui.btn_icon);
|
|
|
|
if (iconTime < ConfigSystem.GetConfig<CommonModel>().ThroughRewardCD)
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
// WebviewManager.Instance.ShowH5View(false);
|
|
|
|
|
|
|
|
var rewardData = new RewardData();
|
|
|
|
var rewardType = 102;
|
|
float[] cash_array = GameHelper.GetRewardValue(2);
|
|
// decimal rewardValue = CardEntity.GetSumToType(CardPropType.cash);
|
|
|
|
var rewardSingleData = new Goda(rewardType, (decimal)cash_array[0], RewardOrigin.H5Icon)
|
|
{
|
|
startPosition = GameHelper.GetUICenterPosition(ui),
|
|
endPosition = GameHelper.GetUICenterPosition(ui.com_top.text_num)
|
|
};
|
|
rewardData.AddReward(rewardSingleData);
|
|
rewardData.AddCompleted(isSuccess =>
|
|
{
|
|
//ui.btn_icon.cont_state.selectedIndex = btn_icon.State_none;
|
|
iconTime = 0;
|
|
SetMakeup();
|
|
});
|
|
rewardData.condition = RewardCondition.AD;
|
|
rewardData.displayType =
|
|
RewardDisplayType.Dialog | RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
|
|
|
GameDispatcher.Instance.Dispatch(BingoInfo.GetReward, rewardData);
|
|
NetworkKit.BuriedPoint(BuriedPointEvent.Hall_behavior, BuriedPointEvent.annular_get_number, 1);
|
|
}
|
|
private void CheckShowFly()
|
|
{
|
|
var nowTime = GameHelper.GetNowTime();
|
|
var leftTime = (int)(PreferencesMgr.Instance.AdCashFlyShowTime - nowTime);
|
|
|
|
ui.com_fly.visible = false;
|
|
ui.com_fly.visible = leftTime <= 0;
|
|
if (leftTime > 0)
|
|
{
|
|
WebviewManager.Instance.ShowFlyBtn(false);
|
|
isFlyShow = false;
|
|
}
|
|
else
|
|
{
|
|
//StartFly();
|
|
if (!isFlyShow) WebviewManager.Instance.ShowFlyBtn(true);
|
|
isFlyShow = true;
|
|
|
|
}
|
|
}
|
|
private bool isFlyShow = false;
|
|
private void StartFly()
|
|
{
|
|
|
|
|
|
var bubbleGo = ui.com_fly.displayObject.gameObject;
|
|
bubbleMoveTween = bubbleGo.transform
|
|
.DOLocalPath(movePointList.ToArray(), 10)
|
|
.SetEase(Ease.Linear)
|
|
.OnComplete(StartFly)
|
|
.SetAutoKill(true);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnClickFlyCash()
|
|
{
|
|
PreferencesMgr.Instance.AdCashFlyShowTime =
|
|
GameHelper.GetNowTime() + ConfigSystem.GetConfig<CommonModel>().flyCD;
|
|
var rewardData = new RewardData();
|
|
|
|
var singleValue =
|
|
(decimal)Math.Round(
|
|
UnityEngine.Random.Range(ConfigSystem.GetConfig<CommonModel>().flyReward[0],
|
|
ConfigSystem.GetConfig<CommonModel>().flyReward[1]), 2);
|
|
decimal rewardValue;
|
|
|
|
|
|
if (flyClickCount >= flyNeedClickCount)
|
|
{
|
|
flyClickCount = -1;
|
|
//var rate = GameHelper.GetVideoRate();
|
|
rewardValue = singleValue;
|
|
GameHelper.ShowVideoAd("reward_fly", isCompleted =>
|
|
{
|
|
if (isCompleted)
|
|
{
|
|
GameDispatcher.Instance.Dispatch(BingoInfo.GetReward, rewardData);
|
|
GameDispatcher.Instance.Dispatch(BingoInfo.RefreshMakeupData);
|
|
}
|
|
});
|
|
}
|
|
else
|
|
{
|
|
rewardValue = singleValue;
|
|
}
|
|
var rewardSingleData = new Goda(102, rewardValue, RewardOrigin.Play)
|
|
{
|
|
startPosition = GameHelper.GetUICenterPosition(ui.com_fly),
|
|
endPosition = GameHelper.GetUICenterPosition(ui.com_top.text_num)
|
|
};
|
|
|
|
rewardData.AddReward(rewardSingleData);
|
|
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
|
rewardData.AddCompleted(isSuccess =>
|
|
{
|
|
if (isSuccess)
|
|
{
|
|
flyClickCount++;
|
|
}
|
|
|
|
SetMakeup();
|
|
});
|
|
//PreferencesMgr.Instance.Currency102 += rewardValue;
|
|
|
|
GameDispatcher.Instance.Dispatch(BingoInfo.GetReward, rewardData);
|
|
GameDispatcher.Instance.Dispatch(BingoInfo.RefreshMakeupData);
|
|
CheckShowFly();
|
|
}
|
|
|
|
|
|
|
|
public void Set101(decimal cash = -1)
|
|
{
|
|
// if (cash < 0)
|
|
// {
|
|
// cash = PreferencesMgr.Instance.Currency102;
|
|
// }
|
|
|
|
// ui.com_top.text_num.text = "$"+ PreferencesMgr.Instance.Currency102;
|
|
}
|
|
|
|
public void OnLoadFinish()
|
|
{
|
|
isLoadFinish = true;
|
|
}
|
|
|
|
public void OnLoadH5Progress(int progress)
|
|
{
|
|
}
|
|
|
|
private void SetMakeup(object a = null)
|
|
{
|
|
var com_box = ui.com_top;
|
|
|
|
com_box.text_num.text = "$" + PreferencesMgr.Instance.Currency102;
|
|
Debug.Log("-----------------------"+PreferencesMgr.Instance.Currency102);
|
|
DOVirtual.Float(0, (float)PreferencesMgr.Instance.Currency102, 0.5f,
|
|
value => { com_box.text_num.text = "$" + value.ToString("0.00"); });
|
|
|
|
|
|
if (PreferencesMgr.Instance.MakeupTaskHistory.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var makeupTaskData = PreferencesMgr.Instance.MakeupTaskHistory.Last();
|
|
makeup vo = null;
|
|
|
|
foreach (makeup item in ConfigSystem.GetConfig<MakeupModel>().dataList)
|
|
{
|
|
|
|
if (item.id == makeupTaskData.tableId) vo = item;
|
|
}
|
|
var leftCash = (double)Math.Max(vo.item_need - PreferencesMgr.Instance.Currency102, 0);
|
|
com_box.text_more.SetVar("money", "$" + leftCash).FlushVars();
|
|
com_box.pb_num.max = vo.item_need;
|
|
com_box.pb_num.TweenValue(vo.item_need - leftCash, 0.1f);
|
|
|
|
float b = ((float)PreferencesMgr.Instance.Currency102) / vo.item_need;
|
|
|
|
ui.btn_out.SetClick(() =>
|
|
{
|
|
WebviewManager.Instance.ShowH5View(false);
|
|
uiCtrlDispatcher.Dispatch(SkinInfo.MakeupConfirmUI_Open, makeupTaskData);
|
|
// MainTabUI.getIns().OnGameTab(0);
|
|
});
|
|
|
|
}
|
|
|
|
public void ClickBtn(string name)
|
|
{
|
|
// // Debug.Log("[UNITY] Click btn: " + name);
|
|
// FGUIHelper.PlayClickSound();
|
|
if (name == "flyBtn")
|
|
{
|
|
OnClickFlyCash();
|
|
NetworkKit.BuriedPoint(BuriedPointEvent.Hall_behavior, BuriedPointEvent.collect_fly_number, 1);
|
|
//NetworkKit.BuriedPoint(BuriedPointEvent.Hall_behavior,BuriedPointEvent.collect_fly_people,1);
|
|
}
|
|
else if (name == "rewardBtn")
|
|
{
|
|
OnClickIcon();
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
} |