bingo 项目提交
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using BingoBrain.Core;
|
||||
|
||||
namespace BingoBrain
|
||||
{
|
||||
public class BingoToyCtrl : BaseCtrl
|
||||
{
|
||||
public static BingoToyCtrl Instance { get; private set; }
|
||||
|
||||
private BingoToyModel model;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36d23c7382a24211a72f44df9ae5400f
|
||||
timeCreated: 1679564096
|
||||
@@ -0,0 +1,53 @@
|
||||
using BingoBrain.Core;
|
||||
|
||||
namespace BingoBrain
|
||||
{
|
||||
public class BingoToyModel : BaseModel
|
||||
{
|
||||
public float animationTime = 6f;
|
||||
|
||||
public string NextOpenWheelTimeStr
|
||||
{
|
||||
get
|
||||
{
|
||||
var val = PreferencesMgr.Instance.NextOpenWheelStampTime - GameHelper.GetNowTime();
|
||||
return val > 0 ? GameHelper.GetInterval(val) : "00:00:00";
|
||||
}
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnReset()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
ctrlDispatcher.AddListener(CtrlMsg.GameNewDays, NewDay);
|
||||
}
|
||||
|
||||
private void NewDay(object obj)
|
||||
{
|
||||
PreferencesMgr.Instance.IsOnceWheel = true;
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
ctrlDispatcher.RemoveListener(CtrlMsg.GameNewDays, NewDay);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbf609aa6837440d83ffaf0a2c9a3cd2
|
||||
timeCreated: 1679564096
|
||||
@@ -0,0 +1,308 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using BingoBrain.Core;
|
||||
using FGUI.JWheel;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BingoBrain
|
||||
{
|
||||
public class BingoToyUI : BaseUI
|
||||
{
|
||||
private BingoToyUICtrl ctrl;
|
||||
private BingoToyModel model;
|
||||
public com_wheel ui;
|
||||
private List<com_reward> com_RewardLst = new();
|
||||
private int[] freeWeight = new int[8];
|
||||
private List<float> vidieWeight = new();
|
||||
private bool isClickSpin;
|
||||
private Action CloseCb;
|
||||
private ParticleSystem fx_zhuangpan_enter;
|
||||
|
||||
public BingoToyUI(BingoToyUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.BingoToyUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "JWheel";
|
||||
uiInfo.assetName = "com_wheel";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = true;
|
||||
uiInfo.isNeedCloseAnim = true;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
model = ModuleBoardk.GetModel(ModelConst.BingoToyModel) as BingoToyModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
ui?.FadeOut();
|
||||
Hall.Instance.UpdateSecondEvent -= UpdateTime;
|
||||
CloseCb?.Invoke();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_wheel;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
Audio.Instance.PlayDynamicEffect("pop_open");
|
||||
FX.Instance.SetFx<ParticleSystem>(ui.gp_Fx, Fx_Type.fx_zhuangpan_enter, ps =>
|
||||
{
|
||||
fx_zhuangpan_enter = ps;
|
||||
fx_zhuangpan_enter.gameObject.SetActive(false);
|
||||
}, CloseCb);
|
||||
FX.Instance.SetFx<ParticleSystem>(ui.com_wheels.gp_Select, Fx_Type.fx_zhuanpan_Select,
|
||||
ps => { ps.transform.localPosition = new Vector3(0, 195, 0); }, CloseCb);
|
||||
|
||||
ui.com_wheels.gp_Select.visible = false;
|
||||
|
||||
SetWheelData();
|
||||
|
||||
com_RewardLst.Add(ui.com_wheels.com_reward1);
|
||||
com_RewardLst.Add(ui.com_wheels.com_reward2);
|
||||
com_RewardLst.Add(ui.com_wheels.com_reward3);
|
||||
com_RewardLst.Add(ui.com_wheels.com_reward4);
|
||||
com_RewardLst.Add(ui.com_wheels.com_reward5);
|
||||
com_RewardLst.Add(ui.com_wheels.com_reward6);
|
||||
com_RewardLst.Add(ui.com_wheels.com_reward7);
|
||||
com_RewardLst.Add(ui.com_wheels.com_reward8);
|
||||
|
||||
var dataList = GameHelper.GetConfig<TurntableModel>().GetDataList();
|
||||
for (var i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
freeWeight[i] = dataList[i].weightA;
|
||||
vidieWeight.Add(dataList[i].weightB);
|
||||
}
|
||||
|
||||
ui.closeButton.SetClick(CtrlCloseUI);
|
||||
ui.btn_spin.SetClick(ClickSpinBtn);
|
||||
ui.com_Spinn.SetClick(ClickSpinBtn);
|
||||
ui.fairyBatching = false;
|
||||
Hall.Instance.UpdateSecondEvent += UpdateTime;
|
||||
}
|
||||
|
||||
private void UpdateTime()
|
||||
{
|
||||
ui.btn_spin.cont_button.selectedIndex =
|
||||
GameHelper.GetNowTime() >= PreferencesMgr.Instance.NextOpenWheelStampTime
|
||||
? btn_spin.Button_none
|
||||
: btn_spin.Button_cd;
|
||||
|
||||
ui.btn_spin.text_time.text = model.NextOpenWheelTimeStr;
|
||||
}
|
||||
|
||||
private void SetWheelData()
|
||||
{
|
||||
if (PreferencesMgr.Instance.WheelVersion != GameHelper.GetDynamicVersion())
|
||||
{
|
||||
PreferencesMgr.Instance.FerrWheelLst.Clear();
|
||||
PreferencesMgr.Instance.VidelWheelLst.Clear();
|
||||
}
|
||||
|
||||
var turntableModel = GameHelper.GetConfig<TurntableModel>();
|
||||
// if (PreferencesMgr.Instance.FerrWheelLst.Count < turntableModel.GetCount() ||
|
||||
// PreferencesMgr.Instance.VidelWheelLst.Count < turntableModel.GetCount())
|
||||
// {
|
||||
Debug.Log("????????????????ttttttttttttttttt");
|
||||
PreferencesMgr.Instance.FerrWheelLst.Clear();
|
||||
PreferencesMgr.Instance.VidelWheelLst.Clear();
|
||||
var list = turntableModel.GetDataList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
PreferencesMgr.Instance.FerrWheelLst.Add(
|
||||
item.quantityA[GameHelper.GetDynamicIndex(item.wheel_itemA)]);
|
||||
PreferencesMgr.Instance.VidelWheelLst.Add(
|
||||
item.quantityB[GameHelper.GetDynamicIndex(item.wheel_itemB)]);
|
||||
}
|
||||
|
||||
PreferencesMgr.Instance.SaveFerrWheelLst();
|
||||
PreferencesMgr.Instance.SaveVidelWheelLst();
|
||||
PreferencesMgr.Instance.WheelVersion = GameHelper.GetDynamicVersion();
|
||||
// }
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
ui?.FadeIn();
|
||||
UpdateTime();
|
||||
RefreshUI();
|
||||
ui.cont_state.selectedIndex =
|
||||
PreferencesMgr.Instance.IsOnceWheel ? com_wheel.State_normal : com_wheel.State_videl;
|
||||
}
|
||||
|
||||
private void RefreshUI(object o = null)
|
||||
{
|
||||
var turntableModel = GameHelper.GetConfig<TurntableModel>();
|
||||
for (var i = 0; i < com_RewardLst.Count; i++)
|
||||
{
|
||||
var rewards = com_RewardLst[i];
|
||||
if (GameHelper.IsGiftSwitch()) rewards.gift.selectedIndex = 1;
|
||||
var turntable = turntableModel.GetData(i + 1);
|
||||
int id;
|
||||
string val;
|
||||
if (PreferencesMgr.Instance.IsOnceWheel)
|
||||
{
|
||||
id = turntable.wheel_itemA;
|
||||
val = id == 102
|
||||
? GameHelper.Get102Str((decimal)PreferencesMgr.Instance.FerrWheelLst[i])
|
||||
: PreferencesMgr.Instance.FerrWheelLst[i].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
id = turntable.wheel_itemB;
|
||||
val = id == 102
|
||||
? GameHelper.Get102Str((decimal)PreferencesMgr.Instance.VidelWheelLst[i])
|
||||
: PreferencesMgr.Instance.VidelWheelLst[i].ToString();
|
||||
}
|
||||
|
||||
rewards.cont_currency.selectedIndex = id switch
|
||||
{
|
||||
101 => com_reward.Currency_coin,
|
||||
102 => com_reward.Currency_diam,
|
||||
104 => com_reward.Currency_card,
|
||||
_ => rewards.cont_currency.selectedIndex
|
||||
};
|
||||
|
||||
rewards.text_num.text = val;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClickSpinBtn()
|
||||
{
|
||||
if (isClickSpin)
|
||||
return;
|
||||
if (!PreferencesMgr.Instance.IsOnceWheel)
|
||||
{
|
||||
if (GameHelper.GetNowTime() < PreferencesMgr.Instance.NextOpenWheelStampTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameHelper.GetVideo("reward_wheel", isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
PlayLucky();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayLucky();
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayLucky()
|
||||
{
|
||||
isClickSpin = true;
|
||||
|
||||
ui.closeButton.touchable = false;
|
||||
ui.closeButton.grayed = true;
|
||||
ui.btn_spin.touchable = false;
|
||||
ui.btn_spin.grayed = true;
|
||||
ui.com_Spinn.touchable = false;
|
||||
ui.com_Spinn.cont_spin.selectedIndex = com_spin.Spin_grey;
|
||||
ui.closeButton.touchable = false;
|
||||
ui.com_wheels.rotation = 0;
|
||||
var index = PreferencesMgr.Instance.IsOnceWheel
|
||||
? GlobalHarmony.RandomWeight(freeWeight)
|
||||
: GlobalHarmony.GetChanceList(vidieWeight);
|
||||
|
||||
var turntableModel = GameHelper.GetConfig<TurntableModel>();
|
||||
var vo = turntableModel.GetData(index + 1);
|
||||
|
||||
var angle = UnityEngine.Random.Range(3600 - (vo.Seq - 1) * 45 - 10, 3600 - (vo.Seq - 1) * 45 + 10) +
|
||||
22.5f;
|
||||
|
||||
Audio.Instance.PlayDynamicEffect("wheel_spin");
|
||||
ui.fx_zhen.Play();
|
||||
DOTween.To(() => ui.com_wheels.rotation, (e) => ui.com_wheels.rotation = e, angle, model.animationTime)
|
||||
.SetEase(AnimationCurveData.Instance.LuckySpinAniCurve);
|
||||
tw = DOVirtual.DelayedCall(model.animationTime, () => OpenReceivePlane(vo));
|
||||
}
|
||||
|
||||
private Tween tw;
|
||||
|
||||
private void OpenReceivePlane(Turntable vo)
|
||||
{
|
||||
ui.fx_zhen.Stop();
|
||||
ui.img_zhen.rotation = 0;
|
||||
ui.com_wheels.gp_Select.visible = true;
|
||||
ui.com_wheels.gp_Select.rotation = (vo.Seq - 2) * 45 + 22.5f;
|
||||
|
||||
DOVirtual.DelayedCall(1.5f, () =>
|
||||
{
|
||||
ui.com_wheels.gp_Select.visible = false;
|
||||
isClickSpin = false;
|
||||
tw = null;
|
||||
ui.closeButton.touchable = true;
|
||||
ui.btn_spin.touchable = true;
|
||||
ui.com_Spinn.touchable = true;
|
||||
ui.btn_spin.grayed = false;
|
||||
ui.closeButton.grayed = false;
|
||||
ui.com_Spinn.cont_spin.selectedIndex = com_spin.Spin_none;
|
||||
if (PreferencesMgr.Instance.IsOnceWheel)
|
||||
{
|
||||
ui.closeButton.touchable = false;
|
||||
ui.btn_spin.touchable = false;
|
||||
ui.com_Spinn.touchable = false;
|
||||
ui.btn_spin.grayed = true;
|
||||
|
||||
GameHelper.GetRewardExtra(vo.wheel_itemA, (decimal)PreferencesMgr.Instance.FerrWheelLst[vo.Seq - 1],
|
||||
vo.cont_index, isCompleted =>
|
||||
{
|
||||
PreferencesMgr.Instance.FerrWheelLst.Clear();
|
||||
PreferencesMgr.Instance.IsOnceWheel = false;
|
||||
|
||||
ui.fx_exit.Play();
|
||||
var sequence = DOTween.Sequence();
|
||||
sequence.Append(DOVirtual.DelayedCall(0.75f, () =>
|
||||
{
|
||||
ui.cont_state.selectedIndex = PreferencesMgr.Instance.IsOnceWheel
|
||||
? com_wheel.State_normal
|
||||
: com_wheel.State_videl;
|
||||
SetWheelData();
|
||||
RefreshUI();
|
||||
ui.fx_enter.Play();
|
||||
}));
|
||||
sequence.Append(DOVirtual.DelayedCall(0.75f, () =>
|
||||
{
|
||||
fx_zhuangpan_enter.gameObject.SetActive(true);
|
||||
ui.closeButton.touchable = true;
|
||||
ui.btn_spin.touchable = true;
|
||||
ui.com_Spinn.touchable = true;
|
||||
ui.btn_spin.grayed = false;
|
||||
Audio.Instance.PlayDynamicEffect("wheel_show");
|
||||
}));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.GetRewardOnly(vo.wheel_itemB,
|
||||
(decimal)PreferencesMgr.Instance.VidelWheelLst[vo.Seq - 1], RewardOrigin.Wheel);
|
||||
|
||||
PreferencesMgr.Instance.VidelWheelLst.Clear();
|
||||
PreferencesMgr.Instance.NextOpenWheelStampTime =
|
||||
GameHelper.GetNowTime() + GameHelper.GetCommonModel().TurntableCD;
|
||||
UpdateTime();
|
||||
|
||||
SetWheelData();
|
||||
RefreshUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b550d156353c43678858ff3266c0ba0a
|
||||
timeCreated: 1679564096
|
||||
@@ -0,0 +1,71 @@
|
||||
using BingoBrain.Core;
|
||||
using BingoBrain.HotFix;
|
||||
|
||||
namespace BingoBrain
|
||||
{
|
||||
public class BingoToyUICtrl : BaseUICtrl
|
||||
{
|
||||
private BingoToyUI ui;
|
||||
private BingoToyModel model;
|
||||
|
||||
private uint openUIMsg = SkinInfo.BingoToyUI_Open;
|
||||
private uint closeUIMsg = SkinInfo.BingoToyUI_Close;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null)
|
||||
{
|
||||
ui = new BingoToyUI(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);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91d3d68cfa3940a09eb1179bfa1d54a6
|
||||
timeCreated: 1679564096
|
||||
Reference in New Issue
Block a user