ball 项目提交
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class LiveDetailCtrl : BaseCtrl
|
||||
{
|
||||
public static LiveDetailCtrl Instance { get; private set; }
|
||||
|
||||
private LiveDetailModel model;
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
Instance = this;
|
||||
//model = ModuleManager.Instance..GetModel(ModelConst.LiveDetailModel) as LiveDetailModel;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35b20b630f8bf4c80baf0f2b6fa4f1e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class LiveDetailModel : BaseModel
|
||||
{
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6c3a05ddce334b378bf365745a1d482
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,346 @@
|
||||
using System;
|
||||
using DG.Tweening;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_Common;
|
||||
using FGUI.LG_live;
|
||||
using Newtonsoft.Json;
|
||||
using SGModule.Common.Extensions;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Video;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class LiveDetailUI : BaseUI
|
||||
{
|
||||
private LiveDetailUICtrl ctrl;
|
||||
private LiveDetailModel model;
|
||||
private com_liveDetail ui;
|
||||
private VideoPlayer video;
|
||||
|
||||
public LiveDetailUI(LiveDetailUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.LiveDetailUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_live";
|
||||
uiInfo.assetName = "com_liveDetail";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
//初始化页面逻辑
|
||||
private void Updata()
|
||||
{
|
||||
if (GameHelper.GetNowTime() < livedata_.LiveADTime)
|
||||
{
|
||||
Debug.Log("??????????????????");
|
||||
(ui.btn_watchad as btn_ad).state.selectedIndex = 1;
|
||||
(ui.btn_watchad as btn_ad).text_time.text = CommonHelper.TimeFormat(
|
||||
(int)livedata_.LiveADTime - Convert.ToInt32(GameHelper.GetNowTime()),
|
||||
CountDownType.Hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
(ui.btn_watchad as btn_ad).state.selectedIndex = 0;
|
||||
if (LiveConfig.AD == livedata_.AD_num + 1)
|
||||
ui.btn_watchad.title = "+" + (100 - livedata_.progress) + "%";
|
||||
else
|
||||
ui.btn_watchad.title = "+" + livedata_.Singleprogress + "%";
|
||||
}
|
||||
}
|
||||
|
||||
private void InitView(object a = null)
|
||||
{
|
||||
// TextureHelper.SetImgLoader(ui.com_loader.GetChild("loader") as GLoader, LiveConfig.Name, () =>
|
||||
// {
|
||||
|
||||
// });
|
||||
Debug.Log(JsonConvert.SerializeObject(livedata_));
|
||||
Debug.Log(JsonConvert.SerializeObject(LiveConfig));
|
||||
|
||||
Updata();
|
||||
var btn_down_coin = ((btn_unlock)ui.btn_download_coin);
|
||||
if (GameHelper.GetVipLevel() >= 1)
|
||||
{
|
||||
(ui.btn_download as btn_claim_1).have_vip.selectedIndex = 1;
|
||||
ui.is_vip.selectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.is_vip.selectedIndex = 0;
|
||||
btn_down_coin.down_load.selectedIndex = 1;
|
||||
}
|
||||
if (livedata_.progress < 100)
|
||||
{
|
||||
ui.state.selectedIndex = 0;
|
||||
if (LiveConfig.AD == 0) ui.can_speed.selectedIndex = 1;
|
||||
if (LiveConfig.SubscribeUnlock == 1)
|
||||
{
|
||||
ui.SubscribeUnlock.selectedIndex = 1;
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
ui.btn_pay.visible = false;
|
||||
ui.btn_watchad.visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.SubscribeUnlock.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.state.selectedIndex = 1;
|
||||
if (video != null) video.Play();
|
||||
}
|
||||
|
||||
(ui.img_cover.GetChild("img_mask") as GImage).fillAmount = (float)(100 - livedata_.progress) / 100;
|
||||
ui.progress_live.value = (float)livedata_.progress;
|
||||
|
||||
//ui.btn_pay.title = LiveConfig.GoldCoins.ToString();
|
||||
Debug.Log(LiveConfig.GoldCoins);
|
||||
var need_gold = (int)MathF.Ceiling((100f - livedata_.progress) * LiveConfig.GoldCoins / 100);
|
||||
ui.btn_pay.title = need_gold.ToString();
|
||||
|
||||
if (LiveConfig.AD == livedata_.AD_num + 1)
|
||||
ui.btn_watchad.title = "+" + (100 - livedata_.progress) + "%";
|
||||
else
|
||||
ui.btn_watchad.title = "+" + livedata_.Singleprogress + "%";
|
||||
|
||||
|
||||
ui.btn_pay.SetClick(() =>
|
||||
{
|
||||
if (DataMgr.Coin.Value >= need_gold)
|
||||
{
|
||||
DataMgr.Coin.Value -= need_gold;
|
||||
|
||||
livedata_.progress = 100;
|
||||
DataMgr.LiveDataDic.Value[index] = livedata_;
|
||||
Debug.Log($"[解锁成功 0] LiveData总数为: {DataMgr.LiveDataDic.Value.Count}");
|
||||
DataMgr.LiveDataDic.Save();
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.LiveChange, index);
|
||||
|
||||
InitView();
|
||||
GameHelper.ShowTips("unlock_success", true);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_live_resources);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ui.btn_watchad.SetClick(() =>
|
||||
{
|
||||
if (livedata_.LiveADTime < GameHelper.GetNowTime())
|
||||
GameHelper.ShowVideoAd("UnlockLive", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
livedata_.AD_num++;
|
||||
if (LiveConfig.AD == livedata_.AD_num)
|
||||
{
|
||||
livedata_.progress = 100;
|
||||
GameHelper.ShowTips("unlock_success", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
livedata_.progress += livedata_.Singleprogress;
|
||||
}
|
||||
|
||||
DataMgr.LiveDataDic.Value[index] = livedata_;
|
||||
Debug.Log($"[解锁成功 1] LiveData总数为: {DataMgr.LiveDataDic.Value.Count}");
|
||||
DataMgr.LiveDataDic.Save();
|
||||
|
||||
livedata_.LiveADTime = GameHelper.GetNowTime() + LiveConfig.CD;
|
||||
SaveData.SaveDataFunc();
|
||||
// if (livedata_.progress == 100) HandlePvPlay();
|
||||
InitView();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.LiveChange, index);
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.btn_vip_unlock.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
livedata_.progress = 100;
|
||||
DataMgr.LiveDataDic.Value[index] = livedata_;
|
||||
Debug.Log($"[解锁成功 0] LiveData总数为: {DataMgr.LiveDataDic.Value.Count}");
|
||||
DataMgr.LiveDataDic.Save();
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.LiveChange, index);
|
||||
|
||||
// HandlePvPlay();
|
||||
InitView();
|
||||
GameHelper.ShowTips("unlock_success", true);
|
||||
|
||||
string eventName = ADEventTrack.Property.vip_live_unclock_ + (index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.VipLive, eventName);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
||||
TrackKit.SendEvent(ADEventTrack.VipLive, ADEventTrack.Property.vip_live_unclock);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.LiveDetailModel) as LiveDetailModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
if (video != null) Object.Destroy(video.gameObject);
|
||||
HallManager.Instance.UpdateSecondEvent -= Updata;
|
||||
|
||||
VideoPlayerHandover.Return();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_liveDetail;
|
||||
}
|
||||
|
||||
private void HandlePvPlay()
|
||||
{
|
||||
Debug.Log("HandlePvPlay: " + index);
|
||||
var secondUIRoot = ui.displayObject.gameObject.transform;
|
||||
var loader = ui.com_loader.GetChild("loader") as GLoader;
|
||||
|
||||
|
||||
// 接管播放器
|
||||
VideoPlayerHandover.TakeOver(player, secondUIRoot, loader);
|
||||
ui.img_cover.visible = false;
|
||||
}
|
||||
|
||||
private int index;
|
||||
private VideoPlayer player;
|
||||
private LiveData livedata_;
|
||||
private Live LiveConfig;
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
var tuple = ((int index, VideoPlayer player))args;
|
||||
|
||||
index = tuple.index;
|
||||
player = tuple.player;
|
||||
player.audioOutputMode = VideoAudioOutputMode.None;
|
||||
|
||||
// 从配置表取配置(这里还是 List,如果有 Id 字段可改成字典)
|
||||
LiveConfig = ConfigSystem.GetConfig<Live>()[index];
|
||||
|
||||
livedata_ = PreDownloadManager.GetLiveDataByIndex(LiveConfig, index);
|
||||
|
||||
ui.btn_close.SetClick(() => { CtrlCloseUI(); });
|
||||
|
||||
|
||||
if (livedata_.progress >= 100 && LiveVideoManager.Instance.ExistVideo(LiveConfig.Name))
|
||||
HandlePvPlay();
|
||||
else
|
||||
{
|
||||
var coverLoader = ui.img_cover.GetChild("loader") as GLoader;
|
||||
LiveVideoManager.Instance.GetVideoCover(coverLoader, LiveConfig.Name + "_cover", (tex) =>
|
||||
{
|
||||
if (tex != null)
|
||||
{
|
||||
if (coverLoader != null)
|
||||
{
|
||||
coverLoader.texture = new NTexture(tex);
|
||||
coverLoader.visible = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var btn_down_coin = ((btn_unlock)ui.btn_download_coin);
|
||||
var downloadCoinNum = ConfigSystem.GetCommonConf().CoinsDownload;
|
||||
btn_down_coin.title = downloadCoinNum.ToString();
|
||||
HallManager.Instance.UpdateSecondEvent += Updata;
|
||||
|
||||
btn_down_coin.SetClick(() =>
|
||||
{
|
||||
|
||||
if (GameHelper.Get101() >= downloadCoinNum)
|
||||
{
|
||||
DataMgr.Coin.Value -= downloadCoinNum;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TextureHelper.SaveVideoToAlbum(LiveConfig.Name, CtrlCloseUI);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.download);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ui.btn_download.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.GetVipLevel() >= 1)
|
||||
{
|
||||
TextureHelper.SaveVideoToAlbum(LiveConfig.Name, CtrlCloseUI);
|
||||
}
|
||||
else
|
||||
GameHelper.ShowVideoAd("DownloadLive", isSuccess =>
|
||||
{
|
||||
if (isSuccess) TextureHelper.SaveVideoToAlbum(LiveConfig.Name, CtrlCloseUI);
|
||||
});
|
||||
});
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.liveVideoLoaded, liveVideoLoaded);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent -= Updata;
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.liveVideoLoaded, liveVideoLoaded);
|
||||
}
|
||||
private void liveVideoLoaded(object o)
|
||||
{
|
||||
HandlePvPlay();
|
||||
// InitView();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01d3c04cad33b4561b62c4c347fb230d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class LiveDetailUICtrl : BaseUICtrl
|
||||
{
|
||||
private LiveDetailUI ui;
|
||||
private LiveDetailModel model;
|
||||
|
||||
private uint openUIMsg = UICtrlMsg.LiveDetailUI_Open;
|
||||
private uint closeUIMsg = UICtrlMsg.LiveDetailUI_Close;
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.LiveDetailModel) as LiveDetailModel;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null)
|
||||
{
|
||||
ui = new LiveDetailUI(this);
|
||||
ui.Open(args);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CloseUI(object args = null)
|
||||
{
|
||||
if (ui != null && !ui.isClose)
|
||||
{
|
||||
ui.Close();
|
||||
}
|
||||
ui = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
public override uint GetOpenUIMsg(string uiName)
|
||||
{
|
||||
return openUIMsg;
|
||||
}
|
||||
public override uint GetCloseUIMsg(string uiName)
|
||||
{
|
||||
return closeUIMsg;
|
||||
}
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
||||
}
|
||||
|
||||
protected override void AddServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void RemoveServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 547517fcf624749f8918034cdddf3439
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user