备份CatanBuilding瘦身独立工程
This commit is contained in:
992
Assets/Scripts/UI/Turntable/FishingTurntablePanel.cs
Normal file
992
Assets/Scripts/UI/Turntable/FishingTurntablePanel.cs
Normal file
@@ -0,0 +1,992 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using System;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using asap.core;
|
||||
using UniRx;
|
||||
using Game;
|
||||
using UnityEngine.EventSystems;
|
||||
using game;
|
||||
using tysdk;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class FishingTurntablePanel : BasePanel
|
||||
{
|
||||
Tables _tables;
|
||||
FishingEventData _fishingEventData;
|
||||
CanvasGroup canvasGroup;
|
||||
public Button btn_close;
|
||||
public Button btn_nextLevelInfo;
|
||||
public Button btn_Info;
|
||||
public UIButton btn_draw;
|
||||
private PointerEventData _eventButtonDraw;
|
||||
|
||||
Button stopClick;
|
||||
|
||||
//private Button btn_beilv;
|
||||
//private Button btn_beilv_max;
|
||||
Button btn_levelUp;
|
||||
TMP_Text text_ticket;
|
||||
TMP_Text text_title;
|
||||
TMP_Text text_time;
|
||||
TMP_Text text_level;
|
||||
TMP_Text text_progress;
|
||||
Image bar;
|
||||
|
||||
Image Bg;
|
||||
|
||||
//TMP_Text text_multi;
|
||||
//TMP_Text text_multi_max;
|
||||
TMP_Text text_draw;
|
||||
Timer timer;
|
||||
List<TurntableRewardItem> rewards;
|
||||
GameObject selected;
|
||||
List<WheelDrop> wheelDrops;
|
||||
public WheelLevel wheelLevel;
|
||||
TurntableRewardItem selectedReward = null;
|
||||
public bool isFree;
|
||||
int multiplier = 1;
|
||||
GameObject ticket;
|
||||
GameObject levelUp;
|
||||
GameObject wheelBg;
|
||||
GameObject wheelBg_free;
|
||||
GameObject bg;
|
||||
GameObject bg_free;
|
||||
|
||||
public float gradeUp_time = 1.0f;
|
||||
|
||||
//private CanvasGroup beilvpanel;
|
||||
//public Transform beilvpanel_max;
|
||||
//public Transform bg_beilvlpanel;
|
||||
//private TMP_Text text_beilvpanel_title;
|
||||
//private TMP_Text text_beilvpanel_content;
|
||||
//GameObject mask;
|
||||
//DOTweenAnimation transitionAnimation;
|
||||
Animation gradeAnimation;
|
||||
Animation barAnimation;
|
||||
bool needTransition = false;
|
||||
int selectedIndex = 0;
|
||||
bool isDataSynced = false;
|
||||
int curSelectedIndex = 0;
|
||||
WheelDrop selectedDrop;
|
||||
Coroutine drew;
|
||||
Spine.Unity.SkeletonGraphic skeletonGraphic;
|
||||
RewardItemNew rewardItemNew;
|
||||
|
||||
GameObject fx_ui_fishingturntable_npc_01;
|
||||
GameObject fx_ui_fishingturntable_change_01;
|
||||
GameObject fx_ui_fishingturntable_dengdai_01;
|
||||
GameObject fx_ui_fishingturntable_dengdai_02;
|
||||
Animation turntable;
|
||||
Button ad_btn;
|
||||
[SerializeField] private Animator _animatorDrawButton;
|
||||
[SerializeField] private Button _btnPack;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
btn_nextLevelInfo = transform.Find("root/turntable/btn_questionmark").GetComponent<Button>();
|
||||
btn_Info = transform.Find("root/title/btn_questionmark").GetComponent<Button>();
|
||||
btn_draw = transform.Find("root/turntable/btn_draw/btn_green").GetComponent<UIButton>();
|
||||
stopClick = transform.Find("StopClick").GetComponent<Button>();
|
||||
//btn_beilv = transform.Find("root/turntable/btn_draw/beilv").GetComponent<Button>();
|
||||
//btn_beilv_max = transform.Find("root/turntable/btn_draw/beilv_max").GetComponent<Button>();
|
||||
btn_levelUp = transform.Find("levelup").GetComponent<Button>();
|
||||
text_ticket = transform.Find("root/turntable/icon_ticket/text_num").GetComponent<TMP_Text>();
|
||||
text_title = transform.Find("root/title/text_title").GetComponent<TMP_Text>();
|
||||
text_time = transform.Find("root/title/text_time").GetComponent<TMP_Text>();
|
||||
text_level = transform.Find("root/turntable/grade/text_level").GetComponent<TMP_Text>();
|
||||
text_progress = transform.Find("root/turntable/bg_bar/text_progress").GetComponent<TMP_Text>();
|
||||
text_draw = transform.Find("root/turntable/btn_draw/btn_green/Ani_Container/p_text").GetComponent<TMP_Text>();
|
||||
bar = transform.Find("root/turntable/bg_bar/bar").GetComponent<Image>();
|
||||
//text_multi = transform.Find("root/turntable/btn_draw/beilv/text_beilv").GetComponent<TMP_Text>();
|
||||
//text_multi_max = transform.Find("root/turntable/btn_draw/beilv_max/text_beilv").GetComponent<TMP_Text>();
|
||||
levelUp = transform.Find("levelup").gameObject;
|
||||
ticket = transform.Find("top_area/resource/icon_ticket").gameObject;
|
||||
wheelBg = transform.Find("root/turntable/bg").gameObject;
|
||||
Bg = transform.Find("bg").GetComponent<Image>();
|
||||
wheelBg_free = transform.Find("root/turntable/bg_free").gameObject;
|
||||
bg = transform.Find("bg").gameObject;
|
||||
bg_free = transform.Find("bg_free").gameObject;
|
||||
rewards = new List<TurntableRewardItem>();
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
rewards.Add(transform.Find($"root/turntable/reward{i}").GetComponent<TurntableRewardItem>());
|
||||
}
|
||||
|
||||
selected = transform.Find("root/turntable/selected").gameObject;
|
||||
wheelDrops = new List<WheelDrop>();
|
||||
gradeAnimation = transform.Find("root/turntable/grade").GetComponent<Animation>();
|
||||
barAnimation = transform.Find("root/turntable/bg_bar").GetComponent<Animation>();
|
||||
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide("FishingTurntablePanel");
|
||||
stopClick.gameObject.SetActive(false);
|
||||
skeletonGraphic = transform.Find("root/turntable/mask/npc").GetComponent<Spine.Unity.SkeletonGraphic>();
|
||||
rewardItemNew = transform.Find("root/reward/reward").GetComponent<RewardItemNew>();
|
||||
|
||||
fx_ui_fishingturntable_npc_01 =
|
||||
transform.Find("root/turntable/mask/npc/fx_ui_fishingturntable_npc_01").gameObject;
|
||||
fx_ui_fishingturntable_change_01 = transform.Find("root/fx_ui_fishingturntable_change_01").gameObject;
|
||||
fx_ui_fishingturntable_dengdai_01 =
|
||||
transform.Find("root/turntable/fx_ui_fishingturntable_dengdai_01").gameObject;
|
||||
fx_ui_fishingturntable_dengdai_02 =
|
||||
transform.Find("root/turntable/fx_ui_fishingturntable_dengdai_02").gameObject;
|
||||
turntable = transform.Find("root/turntable").GetComponent<Animation>();
|
||||
|
||||
ad_btn = transform.Find("root/turntable/btn_advert").GetComponent<Button>();
|
||||
_btnPack.onClick.AddListener(() => _ = UIManager.Instance.ShowUI(UITypes.LackOfTicketPopupPanel));
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
_sm = new FSM();
|
||||
_smHandler = new FSMHandler<AFSM<ETurnTableState>, ETurnTableState>(this, _sm);
|
||||
_sm.SetState(ETurnTableState.Init);
|
||||
// Debug.Log($"[turntable] Current thread ID @ Start: {System.Threading.Thread.CurrentThread.ManagedThreadId}");
|
||||
}
|
||||
|
||||
|
||||
#region StateMachine
|
||||
|
||||
private enum ETurnTableState
|
||||
{
|
||||
Default,
|
||||
Init,
|
||||
Standby,
|
||||
SingleDraw,
|
||||
MultiDraw
|
||||
}
|
||||
|
||||
private class FSM : AFSM<ETurnTableState>
|
||||
{
|
||||
}
|
||||
|
||||
private FSM _sm;
|
||||
private FSMHandler<AFSM<ETurnTableState>, ETurnTableState> _smHandler;
|
||||
private System.Threading.CancellationTokenSource _drawCTS;
|
||||
private IDisposable ContinueDisposable;
|
||||
[SerializeField] private float _lvlUpDurationInMilliseconds; //升级面板停留时长,毫秒
|
||||
|
||||
private void Init_Enter()
|
||||
{
|
||||
//Debug.Log("Init_Enter!");
|
||||
//_fishingEventData.CheckTurntable();
|
||||
base.Start();
|
||||
GContext.OnEvent<ResAddEvent>()
|
||||
.Where(x => x.id == 1004)
|
||||
.Subscribe(x => { AddAnim(); })
|
||||
.AddTo(disposables);
|
||||
btn_close.OnClickAsObservable().Subscribe(x =>
|
||||
{
|
||||
if (_sm.State != ETurnTableState.Standby)
|
||||
return;
|
||||
canvasGroup.blocksRaycasts = false;
|
||||
DestroyUI();
|
||||
}).AddTo(disposables);
|
||||
btn_nextLevelInfo.OnClickAsObservable().Subscribe(async x =>
|
||||
{
|
||||
btn_nextLevelInfo.enabled = false;
|
||||
await UIManager.Instance.ShowUI(UITypes.TurntableRewardInfoPopupPanel);
|
||||
btn_nextLevelInfo.enabled = true;
|
||||
}).AddTo(disposables);
|
||||
btn_Info.OnClickAsObservable().Subscribe(async x =>
|
||||
{
|
||||
btn_Info.enabled = false;
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingTurntableInfoPopupPanel);
|
||||
btn_Info.enabled = true;
|
||||
}).AddTo(disposables);
|
||||
//btn_draw.onClick.AddListener(ClickDraw);
|
||||
btn_draw.onLongPress.AddListener(HoldDraw);
|
||||
btn_draw.onClick.AddListener(ClickDraw);
|
||||
//btn_draw.onDown.AddListener(() => Debug.Log("Down!"));
|
||||
//btn_draw.onUp.AddListener(() => Debug.Log("Up!"));
|
||||
|
||||
btn_levelUp.onClick.AddListener(() =>
|
||||
{
|
||||
//Debug.Log("点击升级面板");
|
||||
levelUp.SetActive(false);
|
||||
});
|
||||
//btn_beilv.onClick.AddListener(OnclickMagnification);
|
||||
//btn_beilv_max.onClick.AddListener(OnclickMagnification);
|
||||
//text_beilvpanel_title.text = "All reward";
|
||||
selected.SetActive(false);
|
||||
levelUp.SetActive(false);
|
||||
isFree = _fishingEventData.freecount > 0;
|
||||
fx_ui_fishingturntable_dengdai_01.SetActive(true);
|
||||
Init(true);
|
||||
SetMulti();
|
||||
SetEndTime();
|
||||
// ad_btn.onClick.AddListener(() => { _ = UIManager.Instance.ShowUI(UITypes.GiftPopupPanel_3); });
|
||||
ad_btn.onClick.AddListener(() => { _ = UIManager.Instance.ShowUI(UITypes.TurntableAdPopupPanel); });
|
||||
_sm.SetState(ETurnTableState.Standby);
|
||||
//ActionContinueMultiDraw = null;
|
||||
ContinueDisposable = GContext.OnEvent<FishingTurnTableContinueMultiDraw>()
|
||||
.Subscribe(_ => ContinueMultiDraw());
|
||||
}
|
||||
|
||||
//private void Init_Exit()
|
||||
//{
|
||||
// Debug.Log("Init Exit!");
|
||||
//}
|
||||
private void Standby_Enter()
|
||||
{
|
||||
//Debug.Log("Standby_Enter!");
|
||||
_animatorDrawButton.Play("Normal");
|
||||
}
|
||||
|
||||
//private void Standby_Exit()
|
||||
//{
|
||||
// Debug.Log("Standby_Exit!");
|
||||
//}
|
||||
private void SingleDraw_Enter()
|
||||
{
|
||||
//Debug.Log("Single Draw Enter!");
|
||||
//_animatorDrawButton.Play("clicked");
|
||||
_drawCTS = new System.Threading.CancellationTokenSource();
|
||||
_ = TrySingleDraw(_drawCTS.Token);
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task TrySingleDraw(System.Threading.CancellationToken t)
|
||||
{
|
||||
var res = await Draw(t);
|
||||
if (res is not false)
|
||||
{
|
||||
await OnStop(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sm.SetState(ETurnTableState.Standby);
|
||||
}
|
||||
}
|
||||
|
||||
private void SingleDraw_Exit()
|
||||
{
|
||||
//Debug.Log("SingleDraw_exit!");
|
||||
_drawCTS?.Dispose();
|
||||
}
|
||||
|
||||
private void MultiDraw_Enter()
|
||||
{
|
||||
//Debug.Log("MultiDraw_Enter!");
|
||||
//_animatorDrawButton.Play("Pressed");
|
||||
_drawCTS = new System.Threading.CancellationTokenSource();
|
||||
_ = MultiDrawAsync(_drawCTS.Token);
|
||||
}
|
||||
|
||||
private void MultiDraw_Exit()
|
||||
{
|
||||
//Debug.Log("MultiDraw_Exit!");
|
||||
_drawCTS?.Dispose();
|
||||
}
|
||||
|
||||
private int _multiDrawAnimationSpeedStage = 0;
|
||||
private float _multiDrawAnimationDelayMultiplier = 1.0f;
|
||||
|
||||
private async System.Threading.Tasks.Task MultiDrawAsync(System.Threading.CancellationToken t)
|
||||
{
|
||||
_multiDrawAnimationSpeedStage = 0;
|
||||
_multiDrawAnimationDelayMultiplier = 1.0f;
|
||||
while (_sm.State == ETurnTableState.MultiDraw)
|
||||
{
|
||||
if (_multiDrawAnimationSpeedStage < 5)
|
||||
{
|
||||
_multiDrawAnimationSpeedStage++;
|
||||
_multiDrawAnimationDelayMultiplier =
|
||||
1 - _tables.TbGlobalConfig.WheelPerTime * _multiDrawAnimationSpeedStage;
|
||||
}
|
||||
|
||||
var isDrawn = await Draw(t);
|
||||
// Debug.Log($"<color=#24acf2>Is Cancellation requested? {t.IsCancellationRequested}</color>");
|
||||
// Debug.Log($"<color=#24acf2>Is Drawn? {isDrawn}</color>");
|
||||
if (isDrawn is false)
|
||||
{
|
||||
_sm.SetState(ETurnTableState.Standby);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
await OnStop(t);
|
||||
}
|
||||
}
|
||||
|
||||
_multiDrawAnimationDelayMultiplier = 1.0f;
|
||||
}
|
||||
|
||||
void ClickDraw()
|
||||
{
|
||||
_animatorDrawButton.Play("clicked");
|
||||
if (_sm.State == ETurnTableState.MultiDraw)
|
||||
{
|
||||
//stop multidraw
|
||||
//Debug.Log("<color=red>Draw Clicked!</color>");
|
||||
_drawCTS.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_sm.State != ETurnTableState.Standby)
|
||||
{
|
||||
//Debug.Log("<color=red>Do Nothing!</color>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isFree || _fishingEventData.freecount > 0)
|
||||
{
|
||||
//Debug.Log("<color=red>SingleDraw! </color>");
|
||||
_sm.SetState(ETurnTableState.SingleDraw);
|
||||
}
|
||||
}
|
||||
|
||||
void HoldDraw()
|
||||
{
|
||||
if (_sm.State == ETurnTableState.Standby && !isFree || _fishingEventData.freecount > 0)
|
||||
{
|
||||
_animatorDrawButton.Play("Selected");
|
||||
_sm.SetState(ETurnTableState.MultiDraw);
|
||||
}
|
||||
}
|
||||
|
||||
// void OnStopClick()
|
||||
// {
|
||||
// stopClick.onClick.RemoveAllListeners();
|
||||
// _drawCTS.Cancel();
|
||||
// OnStopAsync();
|
||||
// }
|
||||
// private async System.Threading.Tasks.Task<bool> OnStopAsync()
|
||||
// {
|
||||
// return (bool)await OnStop();
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnGUI()
|
||||
{
|
||||
GUI.Box(new Rect(10, 10, 200, 20), _sm.State.ToString());
|
||||
}
|
||||
#endif
|
||||
async void ChangeDengdai()
|
||||
{
|
||||
fx_ui_fishingturntable_dengdai_01.SetActive(false);
|
||||
fx_ui_fishingturntable_dengdai_02.SetActive(true);
|
||||
await Awaiters.Seconds(2.5f);
|
||||
fx_ui_fishingturntable_dengdai_01.SetActive(true);
|
||||
fx_ui_fishingturntable_dengdai_02.SetActive(false);
|
||||
}
|
||||
|
||||
float[] spineTimer = new float[] { 0, 0, 2.1f };
|
||||
|
||||
async void PlayIdle(int index)
|
||||
{
|
||||
//播放Spine音效
|
||||
skeletonGraphic.AnimationState.SetAnimation(0, $"Celebrate0{index}", false);
|
||||
//PlaySpineSound(index);
|
||||
float duration = skeletonGraphic.AnimationState.GetCurrent(0).Animation.Duration;
|
||||
await Awaiters.Seconds(duration);
|
||||
if (skeletonGraphic)
|
||||
{
|
||||
skeletonGraphic.AnimationState.SetAnimation(0, "Idle01", true);
|
||||
}
|
||||
}
|
||||
|
||||
async void PlaySpineSound(int index)
|
||||
{
|
||||
await Awaiters.Seconds(spineTimer[index - 1]);
|
||||
GContext.Publish(new EventUISound($"audio_ui_turntable_npc_{index}"));
|
||||
}
|
||||
|
||||
//抽奖逻辑
|
||||
// 抽奖选项切换的默认速度,秒
|
||||
[SerializeField] private float _spinIntervalSingle = 0.07f, _spinIntervalMulti = 0.07f;
|
||||
|
||||
// 抽到奖前的旋转圈数,非负整数;慢速切换的选项数。
|
||||
[SerializeField] private int _spinRoundCountSingle = 1, _slowCountSingle = 4;
|
||||
private int rc;
|
||||
private float interval;
|
||||
|
||||
public IEnumerator Draw(System.Threading.CancellationToken t)
|
||||
{
|
||||
int CostNumber = 0; ;
|
||||
if (isFree)
|
||||
{
|
||||
_fishingEventData.AddFreecount(-1);
|
||||
|
||||
text_draw.text =
|
||||
LocalizationMgr.GetFormatTextValue("UI_TurntableInfoPopupPanel_5", _fishingEventData.freecount);
|
||||
}
|
||||
else
|
||||
{
|
||||
CostNumber = wheelLevel.CostNumber;
|
||||
//若奖券不足,弹出提示
|
||||
int turntableTicketCount = _fishingEventData.TurntableCoupon;
|
||||
if (turntableTicketCount < CostNumber)
|
||||
{
|
||||
//GContext.Publish(new VibrationData(HapticTypes.Failure));
|
||||
// _ = UIManager.Instance.ShowUI(UITypes.GiftPopupPanel_3);
|
||||
_ = UIManager.Instance.ShowUI(UITypes.LackOfTicketPopupPanel);
|
||||
// ToastPanel.Show(LocalizationMgr.GetText("UI_TurntableInfoPopupPanel_6"));
|
||||
SetmaxMulti();
|
||||
yield return false;
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_sm.State == ETurnTableState.SingleDraw)
|
||||
{
|
||||
stopClick.gameObject.SetActive(true);
|
||||
// stopClick.onClick.AddListener(OnStopClick);
|
||||
}
|
||||
|
||||
List<WheelInitSeq> wheelInitSeqs = _tables.TbWheelInitSeq.DataList;
|
||||
selectedDrop = null;
|
||||
selectedReward = null;
|
||||
curSelectedIndex = 0;
|
||||
if (_fishingEventData.WheelOperateCount >= wheelInitSeqs.Count)
|
||||
{
|
||||
// 计算抽奖结果
|
||||
int totalWeight = 0;
|
||||
WheelDrop drop;
|
||||
for (int i = 0; i < wheelDrops.Count; i++)
|
||||
{
|
||||
drop = wheelDrops[i];
|
||||
totalWeight += isFree ? drop.ExtraWeight : drop.Weight;
|
||||
}
|
||||
|
||||
int randomValue = UnityEngine.Random.Range(0, totalWeight);
|
||||
int weightSum = 0;
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
drop = wheelDrops[i];
|
||||
weightSum += isFree ? drop.ExtraWeight : drop.Weight;
|
||||
if (randomValue < weightSum)
|
||||
{
|
||||
selectedDrop = drop;
|
||||
selectedReward = rewards[i];
|
||||
curSelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
curSelectedIndex = wheelInitSeqs[_fishingEventData.WheelOperateCount].WheelSeq;
|
||||
selectedDrop = wheelDrops[curSelectedIndex];
|
||||
selectedReward = rewards[curSelectedIndex];
|
||||
}
|
||||
|
||||
//测试
|
||||
// curSelectedIndex = 3;
|
||||
// selectedDrop = wheelDrops[curSelectedIndex];
|
||||
// selectedReward = rewards[curSelectedIndex];
|
||||
// Debug.Log("奖品:" + selectedDrop.DropID);
|
||||
// 播放抽奖动画
|
||||
Vector3 rewardPosition = selectedReward.transform.position;
|
||||
if (_sm.State == ETurnTableState.SingleDraw)
|
||||
{
|
||||
rc = _spinRoundCountSingle;
|
||||
interval = _spinIntervalSingle;
|
||||
}
|
||||
else
|
||||
{
|
||||
// rc = 0;
|
||||
rc = _spinRoundCountSingle;
|
||||
interval = _spinIntervalMulti * _multiDrawAnimationDelayMultiplier;
|
||||
}
|
||||
|
||||
#region Connection Check & Give Reward
|
||||
|
||||
if (selectedDrop is null)
|
||||
{
|
||||
Debug.LogError($"Selected Drop is null. Current selected index: {curSelectedIndex}");
|
||||
yield break;
|
||||
}
|
||||
|
||||
isDataSynced = false;
|
||||
if (CostNumber > 0)
|
||||
{
|
||||
DoConsume();
|
||||
}
|
||||
else
|
||||
{
|
||||
isDataSynced = true;
|
||||
}
|
||||
|
||||
//_ = ZZTimeHelper.RequestSvrTime(true);
|
||||
while (!isDataSynced)
|
||||
{
|
||||
selectedIndex++;
|
||||
selectedIndex %= 12;
|
||||
rewards[selectedIndex].OnSelect();
|
||||
yield return new WaitForSeconds(interval);
|
||||
break;
|
||||
}
|
||||
|
||||
GContext.container.Resolve<FishingEventData>().RewardTurntableRoll(CostNumber, false);
|
||||
UpdateTicketCount();
|
||||
var itemData =
|
||||
_fishingEventData.UpdateWheel(selectedDrop.DropID, selectedDrop.Type == 9 ? 1 : multiplier, true);
|
||||
|
||||
#endregion
|
||||
|
||||
int start = (selectedIndex + 1) % 12;
|
||||
int end = start + 12 * (rc) + (curSelectedIndex - start + 12) % 12;
|
||||
int fast = end - _slowCountSingle;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
// if (t.IsCancellationRequested)
|
||||
// {
|
||||
// yield return true;
|
||||
// yield break;
|
||||
// }
|
||||
if (i <= fast)
|
||||
{
|
||||
yield return new WaitForSeconds(interval);
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return new WaitForSeconds(interval * (i - fast));
|
||||
}
|
||||
|
||||
GContext.Publish(new VibrationData(HapticTypes.LightImpact));
|
||||
rewards[i % 12].OnSelect();
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
stopClick.onClick.RemoveAllListeners();
|
||||
// yield return !t.IsCancellationRequested;
|
||||
// if (t.IsCancellationRequested)
|
||||
// {
|
||||
// _sm.SetState(ETurnTableState.Standby);
|
||||
// }
|
||||
}
|
||||
|
||||
void DoConsume()
|
||||
{
|
||||
if (Application.internetReachability == NetworkReachability.NotReachable)
|
||||
{
|
||||
NoInternet();
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsumeOnPlayfab();
|
||||
}
|
||||
}
|
||||
private async void ConsumeOnPlayfab()
|
||||
{
|
||||
var success = await PlayFabMgr.Instance.SyncDataImmidiate("TurntableRoll",
|
||||
(_fishingEventData.TurntableCoupon - wheelLevel.CostNumber).ToString());
|
||||
Debug.Log($"[FishingTurntablePanel::ConsumeOnPlayfab] {success}");
|
||||
isDataSynced = true;
|
||||
}
|
||||
|
||||
private async void NoInternet()
|
||||
{
|
||||
GameObject go = await UIManager.Instance.ShowUI(UITypes.NoticeConfirmPopupPanel);
|
||||
var NoticeConfirmPopupPanel = go.GetComponent<NoticeConfirmPopupPanel>();
|
||||
string info = LocalizationMgr.GetText("UI_FishingReconnectPanel_101003");
|
||||
string label = LocalizationMgr.GetText("UI_FishingRewardPanel_101022");
|
||||
string title = LocalizationMgr.GetText("UI_FishingReconnectPanel_101002");
|
||||
NoticeConfirmPopupPanel.Init(1, title, info,
|
||||
onClickLeft: DoConsume,
|
||||
onClose: DoConsume,
|
||||
btn_left_text: label);
|
||||
}
|
||||
|
||||
|
||||
//转盘UI显示
|
||||
private bool doPauseMultiDraw;
|
||||
|
||||
IEnumerator OnStop(System.Threading.CancellationToken t)
|
||||
{
|
||||
// Debug.Log($"[turntable] Current thread ID @ OnStop: {System.Threading.Thread.CurrentThread.ManagedThreadId}");
|
||||
selectedReward.OnSelect();
|
||||
selectedIndex = curSelectedIndex;
|
||||
selected.transform.position = rewards[curSelectedIndex].transform.position;
|
||||
//selected.transform.localEulerAngles = new Vector3(0, 0, 90 - 90 * (selectedIndex / 3));
|
||||
selected.SetActive(true);
|
||||
//播放奖品飞入动画
|
||||
int dropId;
|
||||
if (isFree)
|
||||
{
|
||||
dropId = selectedDrop.ExtraDropID;
|
||||
}
|
||||
else
|
||||
{
|
||||
dropId = selectedDrop.DropID;
|
||||
}
|
||||
|
||||
var itemData = _fishingEventData.UpdateWheel(dropId, selectedDrop.Type == 9 ? 1 : multiplier, false);
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("roll_event"))
|
||||
{
|
||||
e.AddContent("fish_multiple", multiplier)
|
||||
.AddContent("gear_info", selectedDrop.Type)
|
||||
.AddContent("level_info", wheelLevel.Level);
|
||||
if (itemData != null)
|
||||
{
|
||||
if (itemData.id == 1001)
|
||||
{
|
||||
e.AddContent("reward_hook", itemData.count);
|
||||
}
|
||||
else if (itemData.id == 1002)
|
||||
{
|
||||
e.AddContent("reward_cash", itemData.count);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
_fishingEventData.AddIncreaseScore(selectedDrop.Point, multiplier);
|
||||
if (selectedDrop.Type == 1)
|
||||
{
|
||||
//Debug.Log("<color=red>big win</color>");
|
||||
ChangeDengdai();
|
||||
// 特等奖
|
||||
//GContext.Publish(new VibrationData(HapticTypes.Warning));
|
||||
PlayIdle(2);
|
||||
yield return new WaitForSeconds(2f);
|
||||
yield return UIManager.Instance.ShowUI(UITypes.TurntableRewardPopupPanel).AsIEnumerator();
|
||||
doPauseMultiDraw = true;
|
||||
//ActionContinueMultiDraw += ContinueMultiDraw;
|
||||
GContext.Publish(new ShowTurntableData(itemData));
|
||||
// Debug.Log($"[turntable] About to pause");
|
||||
while (curSelectedIndex is 3 or 9 && doPauseMultiDraw)
|
||||
{
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
//ActionContinueMultiDraw -= ContinueMultiDraw;
|
||||
}
|
||||
else if (selectedDrop.Type == 9) //currently not used
|
||||
{
|
||||
ChangeDengdai();
|
||||
//GContext.Publish(new VibrationData(HapticTypes.Warning));
|
||||
PlayIdle(3);
|
||||
fx_ui_fishingturntable_npc_01.SetActive(false);
|
||||
fx_ui_fishingturntable_npc_01.SetActive(true);
|
||||
yield return new WaitForSeconds(3f);
|
||||
}
|
||||
else
|
||||
{
|
||||
//GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
|
||||
PlayIdle(1);
|
||||
yield return selectedReward.ShowReward(rewardItemNew).AsIEnumerator();
|
||||
}
|
||||
|
||||
//播放积分飞入动画
|
||||
yield return StartCoroutine(AddProgress());
|
||||
IsFree = _fishingEventData.freecount > 0;
|
||||
if (levelUp.activeSelf)
|
||||
{
|
||||
if (_sm.State == ETurnTableState.SingleDraw)
|
||||
yield return new WaitUntil(() => !levelUp.activeSelf);
|
||||
else
|
||||
{
|
||||
yield return new WaitForSeconds(_lvlUpDurationInMilliseconds / 1000);
|
||||
levelUp.SetActive(false);
|
||||
}
|
||||
|
||||
turntable.Play();
|
||||
yield return Awaiters.Seconds(2.75f);
|
||||
wheelLevel = _fishingEventData.wheelLevel;
|
||||
wheelDrops.Clear();
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
wheelDrops.Add(_tables.TbWheelDrop.Get(wheelLevel.WheelDrop[i]));
|
||||
rewards[i].wheelDrop = wheelDrops[i];
|
||||
rewards[i].Init(isFree);
|
||||
yield return Awaiters.Seconds(0.08485f);
|
||||
}
|
||||
}
|
||||
|
||||
//转场
|
||||
if (needTransition)
|
||||
{
|
||||
fx_ui_fishingturntable_change_01.SetActive(false);
|
||||
fx_ui_fishingturntable_change_01.SetActive(true);
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
//mask.SetActive(true);
|
||||
//transitionAnimation.DORestart();
|
||||
//Debug.Log("播放动画");
|
||||
//等待动画播放完毕
|
||||
//yield return new WaitForSeconds(transitionAnimation.duration);
|
||||
//mask.SetActive(false);
|
||||
needTransition = false;
|
||||
}
|
||||
|
||||
stopClick.gameObject.SetActive(false);
|
||||
Init();
|
||||
int CostNumber = wheelLevel.CostNumber;
|
||||
if (_fishingEventData.TurntableCoupon < CostNumber)
|
||||
{
|
||||
UIManager.Instance.ShowUI(UITypes.LackOfTicketPopupPanel);
|
||||
}
|
||||
|
||||
if (_sm.State == ETurnTableState.SingleDraw)
|
||||
{
|
||||
_sm.SetState(ETurnTableState.Standby);
|
||||
yield return false;
|
||||
}
|
||||
else if (_sm.State == ETurnTableState.MultiDraw && t.IsCancellationRequested)
|
||||
{
|
||||
_sm.SetState(ETurnTableState.Standby);
|
||||
}
|
||||
|
||||
yield return true;
|
||||
}
|
||||
|
||||
//public static Action ActionContinueMultiDraw;
|
||||
private void ContinueMultiDraw()
|
||||
{
|
||||
doPauseMultiDraw = false;
|
||||
}
|
||||
|
||||
private void Init(bool init = false)
|
||||
{
|
||||
selected.SetActive(false);
|
||||
//beilvpanel.alpha = 0;
|
||||
if (isFree)
|
||||
{
|
||||
text_title.text = LocalizationMgr.GetText(_fishingEventData.wheelInit.SpecialTitle_l10n_key);
|
||||
//btn_beilv.interactable = false;
|
||||
//btn_beilv_max.interactable = false;
|
||||
ticket.SetActive(false);
|
||||
wheelBg_free.SetActive(true);
|
||||
wheelBg.SetActive(false);
|
||||
bg.SetActive(false);
|
||||
bg_free.SetActive(true);
|
||||
|
||||
//GContext.container.Resolve<IUIService>().SetImageSprite(Bg, _fishingEventData.wheelInit.SpBg,BasePanel.PanelName);
|
||||
text_draw.text =
|
||||
LocalizationMgr.GetFormatTextValue("UI_TurntableInfoPopupPanel_5", _fishingEventData.freecount);
|
||||
}
|
||||
else
|
||||
{
|
||||
text_title.text = LocalizationMgr.GetText(_fishingEventData.wheelInit.Title_l10n_key);
|
||||
text_draw.text = LocalizationMgr.GetText("UI_TurntableInfoPopupPanel_4");
|
||||
//btn_beilv.interactable = true;
|
||||
//btn_beilv_max.interactable = true;
|
||||
ticket.SetActive(true);
|
||||
wheelBg_free.SetActive(false);
|
||||
wheelBg.SetActive(true);
|
||||
bg.SetActive(true);
|
||||
bg_free.SetActive(false);
|
||||
//GContext.container.Resolve<IUIService>().SetImageSprite(Bg, _fishingEventData.wheelInit.Bg, BasePanel.PanelName);
|
||||
}
|
||||
|
||||
wheelLevel = _fishingEventData.wheelLevel;
|
||||
//Debug.Log("初始化 wheelLevel.level:" + wheelLevel.Level);
|
||||
if (wheelLevel != null)
|
||||
{
|
||||
text_level.text = wheelLevel.Level.ToString();
|
||||
if (init)
|
||||
{
|
||||
if (wheelLevel.NextLevel == -1 || wheelLevel.NextLevel == wheelLevel.Level)
|
||||
{
|
||||
bar.fillAmount = 1;
|
||||
text_progress.text = "MAX";
|
||||
}
|
||||
else
|
||||
{
|
||||
int curCount = _fishingEventData.GetWheelLevelCount(wheelLevel.Level);
|
||||
bar.fillAmount = curCount / (float)wheelLevel.NextLevelPoint;
|
||||
text_progress.text = $"{curCount}/{wheelLevel.NextLevelPoint}";
|
||||
}
|
||||
}
|
||||
|
||||
SetTurntableData();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("wheelLevel is null");
|
||||
}
|
||||
|
||||
UpdateTicketCount();
|
||||
}
|
||||
|
||||
//转盘数据
|
||||
public void SetTurntableData()
|
||||
{
|
||||
wheelDrops.Clear();
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
wheelDrops.Add(_tables.TbWheelDrop.Get(wheelLevel.WheelDrop[i]));
|
||||
rewards[i].wheelDrop = wheelDrops[i];
|
||||
rewards[i].Init(isFree);
|
||||
}
|
||||
}
|
||||
|
||||
void SetEndTime()
|
||||
{
|
||||
if (timer == null)
|
||||
{
|
||||
DateTime endTime = _fishingEventData.GetTurntableEndTime();
|
||||
double seconds = (endTime - ZZTimeHelper.UtcNow().UtcNowOffset()).TotalSeconds;
|
||||
timer = this.AttachTimer((float)seconds, null,
|
||||
(elapsed) =>
|
||||
{
|
||||
TimeSpan now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
text_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end",
|
||||
ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds));
|
||||
if (now.TotalSeconds <= 0)
|
||||
{
|
||||
DestroyUI();
|
||||
}
|
||||
}, useRealTime: true);
|
||||
}
|
||||
}
|
||||
|
||||
void SetMulti()
|
||||
{
|
||||
//multiplier = GContext.container.Resolve<PlayerShopData>().GetTurntableMag();
|
||||
UpdateRewardsShow();
|
||||
}
|
||||
|
||||
|
||||
void SetmaxMulti()
|
||||
{
|
||||
//multiplier = GContext.container.Resolve<PlayerShopData>().GetCurMaxTurntableMag(multiplier);
|
||||
UpdateRewardsShow();
|
||||
}
|
||||
|
||||
void UpdateRewardsShow()
|
||||
{
|
||||
//SetShowMagnification();
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
rewards[i].rewardMulti = multiplier;
|
||||
rewards[i].UpDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFree
|
||||
{
|
||||
get { return isFree; }
|
||||
set
|
||||
{
|
||||
if (isFree != value)
|
||||
{
|
||||
isFree = value;
|
||||
// 当isFree值发生变化时,播放transitionAnimation动画
|
||||
needTransition = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator AddProgress()
|
||||
{
|
||||
if (wheelLevel.NextLevel == -1 || wheelLevel.NextLevel == wheelLevel.Level)
|
||||
{
|
||||
bar.fillAmount = 1;
|
||||
text_progress.text = "MAX";
|
||||
yield break;
|
||||
}
|
||||
|
||||
gradeAnimation.Play();
|
||||
yield return new WaitForSeconds(gradeAnimation.clip.length);
|
||||
|
||||
int curCount = _fishingEventData.GetWheelLevelCount(wheelLevel.Level);
|
||||
float fill_amount_target = curCount / (float)wheelLevel.NextLevelPoint;
|
||||
|
||||
if (fill_amount_target < 1)
|
||||
{
|
||||
bar.DOFillAmount(fill_amount_target, gradeUp_time);
|
||||
DOTween.To(() => int.Parse(text_progress.text.Split('/')[0]),
|
||||
x => text_progress.text = $"{x}/{wheelLevel.NextLevelPoint}", curCount, gradeUp_time);
|
||||
//yield return new WaitForSeconds(gradeUp_time);
|
||||
//退出协程
|
||||
yield break;
|
||||
}
|
||||
|
||||
while (fill_amount_target >= 1)
|
||||
{
|
||||
text_level.text = wheelLevel.Level.ToString();
|
||||
if (bar.fillAmount == 1)
|
||||
{
|
||||
bar.fillAmount = 0;
|
||||
text_progress.text = $"{0}/{wheelLevel.NextLevelPoint}";
|
||||
}
|
||||
|
||||
bar.DOFillAmount(1, gradeUp_time);
|
||||
|
||||
DOTween.To(() => int.Parse(text_progress.text.Split('/')[0]),
|
||||
x => text_progress.text = $"{x}/{wheelLevel.NextLevelPoint}", wheelLevel.NextLevelPoint, gradeUp_time);
|
||||
yield return new WaitForSeconds(gradeUp_time);
|
||||
|
||||
barAnimation.Play();
|
||||
yield return new WaitForSeconds(barAnimation.clip.length);
|
||||
|
||||
|
||||
curCount -= wheelLevel.NextLevelPoint;
|
||||
wheelLevel = _tables.TbWheelLevel.Get(wheelLevel.NextLevel);
|
||||
fill_amount_target = curCount / (float)wheelLevel.NextLevelPoint;
|
||||
}
|
||||
|
||||
text_level.text = wheelLevel.Level.ToString();
|
||||
if (wheelLevel.NextLevel == -1 || wheelLevel.NextLevel == wheelLevel.Level)
|
||||
{
|
||||
bar.fillAmount = 1;
|
||||
text_progress.text = "MAX";
|
||||
}
|
||||
else
|
||||
{
|
||||
curCount = _fishingEventData.GetWheelLevelCount(wheelLevel.Level);
|
||||
fill_amount_target = curCount / (float)wheelLevel.NextLevelPoint;
|
||||
bar.fillAmount = 0;
|
||||
bar.DOFillAmount(fill_amount_target, gradeUp_time);
|
||||
DOTween.To(() => 0, x => text_progress.text = $"{x}/{wheelLevel.NextLevelPoint}", curCount, gradeUp_time);
|
||||
yield return new WaitForSeconds(gradeUp_time);
|
||||
}
|
||||
|
||||
levelUp.SetActive(true);
|
||||
}
|
||||
|
||||
void AddAnim()
|
||||
{
|
||||
UpdateTicketCount();
|
||||
}
|
||||
|
||||
void DestroyUI()
|
||||
{
|
||||
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
|
||||
GContext.Publish(restartShowHomeUIEvent);
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingTurntablePanel);
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新奖券数量,判断余票数量是否足够下一抽;
|
||||
/// </summary>
|
||||
/// <returns>余票数量是否足够下一抽</returns>
|
||||
private void UpdateTicketCount()
|
||||
{
|
||||
int TurntableCoupon = _fishingEventData.TurntableCoupon;
|
||||
int CostNumber = wheelLevel.CostNumber;
|
||||
if (TurntableCoupon < CostNumber)
|
||||
{
|
||||
text_ticket.text = $"<color=red>{ConvertTools.GetNumberString(TurntableCoupon)}/{CostNumber}</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
text_ticket.text = $"{ConvertTools.GetNumberString(TurntableCoupon)} /{CostNumber}";
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
GContext.Publish(new ConditionTypeEvent(ConditionType.WheelTicketLessThan, 1));
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
ContinueDisposable.Dispose();
|
||||
base.OnDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
public struct FishingTurnTableContinueMultiDraw
|
||||
{
|
||||
}
|
||||
11
Assets/Scripts/UI/Turntable/FishingTurntablePanel.cs.meta
Normal file
11
Assets/Scripts/UI/Turntable/FishingTurntablePanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c734c9996bd04c6428fe1893808034fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
76
Assets/Scripts/UI/Turntable/TurntableAdButton.cs
Normal file
76
Assets/Scripts/UI/Turntable/TurntableAdButton.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using asap.core;
|
||||
public class TurntableAdButton : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button _btnAd;
|
||||
[SerializeField] private TMP_Text _textTime, _textFree;
|
||||
private TurntableAdPopupPanel _adPanel;
|
||||
private IDisposable _timer;
|
||||
private PlayerShopData _playerShopData;
|
||||
private void Awake()
|
||||
{
|
||||
_playerShopData = GContext.container.Resolve<PlayerShopData>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
_btnAd.onClick.AddListener(async () => await OpenAddPanel());
|
||||
InitializeButton();
|
||||
}
|
||||
private void InitializeButton()
|
||||
{
|
||||
DateTime nextAdTime = _playerShopData.GetTurnTableNextAdTime();
|
||||
TimeSpan time = nextAdTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
if (_playerShopData.IsTurntableAdMaxOut())
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
if (time.TotalSeconds > 1)
|
||||
{
|
||||
SetTimer();
|
||||
_textTime.gameObject.SetActive(true);
|
||||
_textFree.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_textTime.gameObject.SetActive(false);
|
||||
_textFree.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
private async System.Threading.Tasks.Task OpenAddPanel()
|
||||
{
|
||||
_adPanel = (await UIManager.Instance.ShowUI(UITypes.TurntableAdPopupPanel))
|
||||
.GetComponent<TurntableAdPopupPanel>();
|
||||
_adPanel.OnClosePanel += OnAdPanelClose;
|
||||
}
|
||||
private void SetTimer()
|
||||
{
|
||||
_timer?.Dispose();
|
||||
DateTime nextAdTime = DateTime.Parse(_playerShopData.TurntableAdData.time);
|
||||
TimeSpan remainingTime = nextAdTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
_textTime.text = ConvertTools.ConvertTime2(remainingTime);
|
||||
_timer = Observable.Interval(TimeSpan.FromSeconds(1.0f))
|
||||
.Subscribe( _ =>{
|
||||
TimeSpan remainingTime = nextAdTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
_textTime.text = ConvertTools.ConvertTime2(remainingTime);
|
||||
if (remainingTime.TotalSeconds <= 1f)
|
||||
{
|
||||
_textTime.gameObject.SetActive(false);
|
||||
_textFree.gameObject.SetActive(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
private void OnAdPanelClose()
|
||||
{
|
||||
InitializeButton();
|
||||
if (_playerShopData.IsTurntableAdMaxOut())
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Turntable/TurntableAdButton.cs.meta
Normal file
11
Assets/Scripts/UI/Turntable/TurntableAdButton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2569cfbd451b76042b7e31e0031af6bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
160
Assets/Scripts/UI/Turntable/TurntableAdPopupPanel.cs
Normal file
160
Assets/Scripts/UI/Turntable/TurntableAdPopupPanel.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
using System;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using game;
|
||||
using UniRx;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class TurntableAdPopupPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button _btnWatch, _btnClose;
|
||||
[SerializeField] private TMP_Text _textWatchAd, _textRefreshTimer, _textVip, _textInfo, _textFree;
|
||||
[SerializeField] private GameObject _goWatch, _goRefresh;
|
||||
[SerializeField] private RewardItemNew _reward;
|
||||
private Tables _tables;
|
||||
private PlayerData _playerData;
|
||||
// private TbWheelAd _adConfig;
|
||||
private WheelAd _adConfig;
|
||||
private PlayerItemData _playerItemData;
|
||||
private PlayerShopData _playerShopData;
|
||||
private IDisposable _ads, _timer;
|
||||
private AdvertPopupType _adType;
|
||||
private FishingEventData _fishingEventData;
|
||||
public Action OnClosePanel;
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_playerData = GContext.container.Resolve<PlayerData>();
|
||||
_playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
_playerShopData = GContext.container.Resolve<PlayerShopData>();
|
||||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
_btnClose.onClick.AddListener(OnPanelClose);
|
||||
_btnWatch.onClick.AddListener(OnClickWatch);
|
||||
Init();
|
||||
}
|
||||
private void Init()
|
||||
{
|
||||
_adConfig = _playerShopData.GetTurntableAdCofig();
|
||||
var itemDropPackage = _tables.TbItemDropPackage[_adConfig.Reward];
|
||||
_reward.SetIcon(itemDropPackage.Icon);
|
||||
_reward.text_num.text = itemDropPackage.CountDisplay[0];
|
||||
SetTimer();
|
||||
}
|
||||
public void ResetPanel(bool doesShowWatch)
|
||||
{
|
||||
_goWatch.SetActive(doesShowWatch);
|
||||
_goRefresh.SetActive(!doesShowWatch);
|
||||
if (doesShowWatch)
|
||||
{
|
||||
_adConfig = _playerShopData.GetTurntableAdCofig();
|
||||
int totalAdCount = _tables.TbWheelAd.DataList.Count;
|
||||
int remainsCount = totalAdCount - _playerShopData.TurntableAdData.index + 1;
|
||||
string textCost = LocalizationMgr.GetFormatTextValue("UI_EventAdvertPopupPanel_4", $"{remainsCount}/{totalAdCount}");
|
||||
_textWatchAd.text = textCost;
|
||||
_textFree.text = textCost;
|
||||
_textVip.text = LocalizationMgr.GetText("UI_EventAdvertPopupPanel_5");
|
||||
bool isVip = _playerData.vip >= _adConfig.VipFree;
|
||||
_textVip.gameObject.SetActive(isVip);
|
||||
_textFree.gameObject.SetActive(isVip);
|
||||
_textWatchAd.gameObject.SetActive(!isVip);
|
||||
_textInfo.gameObject.SetActive(!isVip);
|
||||
}
|
||||
}
|
||||
void OnClickWatch()
|
||||
{
|
||||
int viplv = _playerData.vip;
|
||||
if (viplv >= _adConfig.VipFree)
|
||||
{
|
||||
OnAdWatchedSuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
_btnWatch.enabled = false;
|
||||
//拉起广告
|
||||
DisposeAds();
|
||||
_ads = GContext.OnEvent<AdsResult>().Subscribe(SetResult);
|
||||
_adType = AdvertPopupType.Turntable;
|
||||
GContext.container.Resolve<IAdsService>().ShowRewarded(AdvertPopupType.Turntable);
|
||||
}
|
||||
}
|
||||
private void DisposeAds()
|
||||
{
|
||||
if (_ads != null)
|
||||
{
|
||||
_adType = AdvertPopupType.None;
|
||||
_ads.Dispose();
|
||||
_ads = null;
|
||||
}
|
||||
}
|
||||
private void OnAdWatchedSuccess()
|
||||
{
|
||||
List<ItemData> items = _playerItemData.AddItemByDrop(_adConfig.Reward, false);
|
||||
_playerShopData.UpdateTurntableAd();
|
||||
if (_playerShopData.TurntableAdData.index > _tables.TbWheelAd.DataList.Count)
|
||||
{
|
||||
GContext.Publish(new ShowData(items));
|
||||
GContext.Publish(new ShowData());
|
||||
OnPanelClose();
|
||||
return;
|
||||
}
|
||||
Init();
|
||||
ResetPanel(false);
|
||||
GContext.Publish(new ShowData(items));
|
||||
GContext.Publish(new ShowData());
|
||||
}
|
||||
void SetResult(AdsResult adsResult)
|
||||
{
|
||||
if (adsResult.Result == 0 && adsResult.Type == _adType)
|
||||
{
|
||||
GContext.container.Resolve<PlayerShopData>().AddAdvertCount(_fishingEventData.wheelInit.ID);
|
||||
//广告成功
|
||||
OnAdWatchedSuccess();
|
||||
}
|
||||
DisposeAds();
|
||||
_btnWatch.enabled = true;
|
||||
}
|
||||
private void SetTimer()
|
||||
{
|
||||
if (_timer != null)
|
||||
{
|
||||
_timer.Dispose();
|
||||
}
|
||||
ResetPanel(false);
|
||||
DateTime nextAdTime = _playerShopData.GetTurnTableNextAdTime();
|
||||
if ((nextAdTime - ZZTimeHelper.UtcNow().UtcNowOffset()).TotalSeconds <= 1.5f)
|
||||
{
|
||||
ResetPanel(true);
|
||||
return;
|
||||
}
|
||||
string strTime;
|
||||
TimeSpan remainingTime = nextAdTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
strTime = ConvertTools.ConvertTime2(remainingTime);
|
||||
_textRefreshTimer.text = LocalizationMgr.GetFormatTextValue("UI_EventAdvertPopupPanel_3", strTime);
|
||||
_timer = Observable.Interval(TimeSpan.FromSeconds(1.0f))
|
||||
.Subscribe( _ =>{
|
||||
TimeSpan remainingTime = nextAdTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
strTime = ConvertTools.ConvertTime2(remainingTime);
|
||||
_textRefreshTimer.text = LocalizationMgr.GetFormatTextValue("UI_EventAdvertPopupPanel_3", strTime);
|
||||
if (remainingTime.TotalSeconds <= 1f)
|
||||
{
|
||||
Init();
|
||||
ResetPanel(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
private void OnPanelClose()
|
||||
{
|
||||
_timer?.Dispose();
|
||||
_ads?.Dispose();
|
||||
OnClosePanel?.Invoke();
|
||||
UIManager.Instance.DestroyUI(UITypes.TurntableAdPopupPanel);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Turntable/TurntableAdPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Turntable/TurntableAdPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 863be8db667cde048bf5eb9ba391a82d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Scripts/UI/Turntable/TurntableInfoPopupPanel.cs
Normal file
48
Assets/Scripts/UI/Turntable/TurntableInfoPopupPanel.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using GameCore;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using TMPro;
|
||||
public class TurntableInfoPopupPanel : MonoBehaviour
|
||||
{
|
||||
Button btn_close;
|
||||
TurntableRewardItem rewardItem1;
|
||||
TurntableRewardItem rewardItem2;
|
||||
TurntableRewardItem rewardItem4;
|
||||
TMP_Text text_num;
|
||||
void Awake()
|
||||
{
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
rewardItem1 = transform.Find("root/info2/reward1").GetComponent<TurntableRewardItem>();
|
||||
rewardItem2 = transform.Find("root/info2/reward2").GetComponent<TurntableRewardItem>();
|
||||
rewardItem4 = transform.Find("root/info2/reward4").GetComponent<TurntableRewardItem>();
|
||||
text_num = transform.Find("root/info1/icon_ticket/text_num").GetComponent<TMP_Text>();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(() =>
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingTurntableInfoPopupPanel);
|
||||
});
|
||||
var _fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
var wheelLevel = _fishingEventData.wheelLevel;
|
||||
var _tables = GContext.container.Resolve<Tables>();
|
||||
rewardItem1.wheelDrop = _tables.TbWheelDrop.Get(wheelLevel.WheelDrop[0]);
|
||||
rewardItem1.Init(false);
|
||||
rewardItem2.wheelDrop = _tables.TbWheelDrop.Get(wheelLevel.WheelDrop[1]);
|
||||
rewardItem2.Init(false);
|
||||
rewardItem4.wheelDrop = _tables.TbWheelDrop.Get(wheelLevel.WheelDrop[3]);
|
||||
rewardItem4.Init(false);
|
||||
int TurntableCoupon = _fishingEventData.TurntableCoupon;
|
||||
int CostNumber = wheelLevel.CostNumber;
|
||||
if (TurntableCoupon < CostNumber)
|
||||
{
|
||||
text_num.text = $"<color=red>{ConvertTools.GetNumberString(TurntableCoupon)}/{CostNumber}</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
text_num.text = $"{ConvertTools.GetNumberString(TurntableCoupon)} /{CostNumber}";
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Turntable/TurntableInfoPopupPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Turntable/TurntableInfoPopupPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c098131e982ec774a947eb7b86e6b78c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
164
Assets/Scripts/UI/Turntable/TurntableRewardInfoPopupPanel.cs
Normal file
164
Assets/Scripts/UI/Turntable/TurntableRewardInfoPopupPanel.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using cfg;
|
||||
using asap.core;
|
||||
|
||||
public class TurntableRewardInfoPopupPanel : MonoBehaviour
|
||||
{
|
||||
FishingEventData _fishingEventData;
|
||||
Button btn_close;
|
||||
Button btn_mask;
|
||||
Button btn_left;
|
||||
Button btn_right;
|
||||
TMP_Text text_info;
|
||||
TMP_Text text_title;
|
||||
TMP_Text text_level;
|
||||
List<WheelLevel> wheelLevels = new List<WheelLevel>();
|
||||
List<List<WheelDrop>> wheelsList = new List<List<WheelDrop>>();
|
||||
int wheelInitId;
|
||||
int index = 99999;
|
||||
List<GameObject> rewards;
|
||||
List<int> requiredPoints = new List<int>();
|
||||
int Progress;
|
||||
void Awake()
|
||||
{
|
||||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_mask = transform.Find("mask").GetComponent<Button>();
|
||||
btn_left = transform.Find("root/btn_slider_left").GetComponent<Button>();
|
||||
btn_right = transform.Find("root/btn_slider_right").GetComponent<Button>();
|
||||
text_info = transform.Find("root/text_info").GetComponent<TMP_Text>();
|
||||
wheelInitId = _fishingEventData.wheelInit.ID;
|
||||
text_title = transform.Find("root/turntable/text_title").GetComponent<TMP_Text>();
|
||||
text_level = transform.Find("root/turntable/text_title/grade/text_level").GetComponent<TMP_Text>();
|
||||
rewards = new List<GameObject>();
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
rewards.Add(transform.Find($"root/turntable/reward{i}").gameObject);
|
||||
}
|
||||
Progress = _fishingEventData.GetWheelLevelCount(_fishingEventData.wheelLevel.Level);
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(() =>
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.TurntableRewardInfoPopupPanel);
|
||||
});
|
||||
btn_mask.onClick.AddListener(() =>
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.TurntableRewardInfoPopupPanel);
|
||||
});
|
||||
btn_left.onClick.AddListener(OnLeftClick);
|
||||
btn_right.onClick.AddListener(OnRightClick);
|
||||
Init();
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
int max = 0;
|
||||
bool isFind = false;
|
||||
foreach (var wheelLevel in GContext.container.Resolve<Tables>().TbWheelLevel.DataList)
|
||||
{
|
||||
if (wheelLevel.Wheel == wheelInitId)
|
||||
{
|
||||
wheelLevels.Add(wheelLevel);
|
||||
wheelsList.Add(new List<WheelDrop>());
|
||||
foreach (int wheelDropId in wheelLevel.WheelDrop)
|
||||
{
|
||||
wheelsList[max].Add(GContext.container.Resolve<Tables>().TbWheelDrop.Get(wheelDropId));
|
||||
}
|
||||
max++;
|
||||
isFind = true;
|
||||
}
|
||||
else if (isFind)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
SetPointsList();
|
||||
index = _fishingEventData.wheelLevel.Level;
|
||||
if (index >= wheelsList.Count)
|
||||
{
|
||||
index = wheelsList.Count - 1;
|
||||
}
|
||||
UpDisplay();
|
||||
}
|
||||
void UpDisplay()
|
||||
{
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
rewards[i].GetComponent<TurntablelInfoRewardItem>().wheelDrop = wheelsList[index][i];
|
||||
if (index > 0 && requiredPoints[index] != 0)
|
||||
{
|
||||
rewards[i].GetComponent<TurntablelInfoRewardItem>().preWheelDrop = wheelsList[index - 1][i];
|
||||
}
|
||||
else
|
||||
{
|
||||
rewards[i].GetComponent<TurntablelInfoRewardItem>().preWheelDrop = null;
|
||||
}
|
||||
rewards[i].GetComponent<TurntablelInfoRewardItem>().Init();
|
||||
}
|
||||
text_level.text = (index + 1).ToString();
|
||||
|
||||
if (requiredPoints[index] == 0)
|
||||
{
|
||||
text_info.text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
text_info.text = LocalizationMgr.GetFormatTextValue("UI_TurntableInfoPopupPanel_7", ConvertTools.GetNumberString(requiredPoints[index]), index + 1);
|
||||
}
|
||||
|
||||
text_title.text = LocalizationMgr.GetFormatTextValue("UI_TurntableInfoPopupPanel_9", index + 1);
|
||||
|
||||
OnLeftOrRight();
|
||||
}
|
||||
void OnLeftClick()
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
index--;
|
||||
UpDisplay();
|
||||
}
|
||||
|
||||
}
|
||||
void OnRightClick()
|
||||
{
|
||||
if (index < wheelsList.Count - 1)
|
||||
{
|
||||
index++;
|
||||
UpDisplay();
|
||||
}
|
||||
}
|
||||
void OnLeftOrRight()
|
||||
{
|
||||
btn_left.interactable = index > 0;
|
||||
btn_right.interactable = index < wheelsList.Count - 1;
|
||||
}
|
||||
|
||||
void SetPointsList()
|
||||
{
|
||||
foreach (var wheelLevel in wheelLevels)
|
||||
{
|
||||
int pointsNeeded = 0;
|
||||
|
||||
if (wheelLevel.Level <= _fishingEventData.wheelLevel.Level)
|
||||
{
|
||||
pointsNeeded = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log($"Progress:{Progress}");
|
||||
for (int i = _fishingEventData.wheelLevel.Level - 1; i < wheelLevel.Level - 1; i++)
|
||||
{
|
||||
pointsNeeded += wheelLevels[i].NextLevelPoint;
|
||||
}
|
||||
pointsNeeded -= Progress;
|
||||
}
|
||||
requiredPoints.Add(pointsNeeded);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d5d982a7be30a24684a8564697ede0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Assets/Scripts/UI/Turntable/TurntableRewardItem.cs
Normal file
132
Assets/Scripts/UI/Turntable/TurntableRewardItem.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using cfg;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using GameCore;
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class TurntableRewardItem : MonoBehaviour
|
||||
{
|
||||
public WheelDrop wheelDrop;
|
||||
//int id = 0 ;
|
||||
Image icon;
|
||||
TMP_Text text_num;
|
||||
public int rewardMulti = 1;
|
||||
public int num = 0;
|
||||
Item item;
|
||||
ItemData itemData;
|
||||
Transform rewardNew;
|
||||
GameObject particle;
|
||||
GameObject particle_01;
|
||||
DOTweenAnimation dotween_selected;
|
||||
|
||||
Button btn_click;
|
||||
Image icon_card;
|
||||
Image logo;
|
||||
Image card_num;
|
||||
void Awake()
|
||||
{
|
||||
wheelDrop = null;
|
||||
text_num = transform.Find("text_num").GetComponent<TMP_Text>();
|
||||
icon = transform.Find("icon").GetComponent<UnityEngine.UI.Image>();
|
||||
rewardNew = transform.Find("reward");
|
||||
particle = transform.Find("particle").gameObject;
|
||||
particle_01 = transform.Find("particle_01").gameObject;
|
||||
dotween_selected = transform.Find("dotween_selected").GetComponent<DOTweenAnimation>();
|
||||
|
||||
icon_card = transform.Find("icon_card").GetComponent<Image>();
|
||||
logo = transform.Find("icon_card/logo").GetComponent<Image>();
|
||||
card_num = transform.Find("icon_card/num").GetComponent<Image>();
|
||||
|
||||
btn_click = GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
if (btn_click != null)
|
||||
{
|
||||
btn_click.onClick.AddListener(OnClick);
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick()
|
||||
{
|
||||
if (itemData == null || itemData.id == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GContext.container.Resolve<PlayerItemData>().ShowItemTips(itemData.id, transform);
|
||||
}
|
||||
public void Init(bool isFree)
|
||||
{
|
||||
if (isFree)
|
||||
{
|
||||
itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(wheelDrop.ExtraDropID);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(wheelDrop.DropID);
|
||||
}
|
||||
item = GContext.container.Resolve<Tables>().TbItem.Get(itemData.id); //是否可能有多个物品?
|
||||
text_num.gameObject.SetActive(wheelDrop.Type != 9 || isFree);
|
||||
UpDisplay();
|
||||
}
|
||||
public void UpDisplay()
|
||||
{
|
||||
if (wheelDrop.Type == 9)
|
||||
{
|
||||
rewardMulti = 1;
|
||||
}
|
||||
num = (int)itemData.count * rewardMulti;
|
||||
text_num.text = ConvertTools.GetNumberString(num);
|
||||
if (item.Type == 5)
|
||||
{
|
||||
IUIService uiService = GContext.container.Resolve<IUIService>();
|
||||
List<string> BgNameList;
|
||||
if (item.SubType == 1)
|
||||
{
|
||||
var fishCard = GContext.container.Resolve<Tables>().TbFishCardDrop.GetOrDefault(item.RedirectID);
|
||||
BgNameList = fishCard.BgNameList;
|
||||
}
|
||||
else
|
||||
{
|
||||
var fishCard = GContext.container.Resolve<Tables>().TbGeneralCardWeight.GetOrDefault(item.RedirectID);
|
||||
BgNameList = fishCard.BgNameList;
|
||||
}
|
||||
|
||||
uiService.SetImageSprite(icon_card, BgNameList[0], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(logo, BgNameList[1], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(card_num, BgNameList[2], BasePanel.PanelName);
|
||||
icon_card.gameObject.SetActive(true);
|
||||
icon.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
icon_card.gameObject.SetActive(false);
|
||||
icon.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
}
|
||||
public void OnSelect()
|
||||
{
|
||||
particle_01.SetActive(false);
|
||||
particle.SetActive(false);
|
||||
particle_01.SetActive(true);
|
||||
particle.SetActive(true);
|
||||
dotween_selected.DORestart();
|
||||
}
|
||||
public async System.Threading.Tasks.Task ShowReward(RewardItemNew rewardItemNew)
|
||||
{
|
||||
ItemData itemDataNew = new ItemData();
|
||||
itemDataNew.id = itemData.id;
|
||||
itemDataNew.count = itemData.count * rewardMulti;
|
||||
rewardItemNew.transform.parent.position = rewardNew.position;
|
||||
rewardItemNew.SetRewardPopupData(itemDataNew, false);
|
||||
rewardItemNew.PlayOpen(true);
|
||||
await Awaiters.Seconds(0.6f);
|
||||
await rewardItemNew.PlayClose();
|
||||
await rewardItemNew.ParticleAttractor();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Turntable/TurntableRewardItem.cs.meta
Normal file
11
Assets/Scripts/UI/Turntable/TurntableRewardItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e546bcf3533cfb74c9604735f5f234ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
74
Assets/Scripts/UI/Turntable/TurntableRewardPopupPanel.cs
Normal file
74
Assets/Scripts/UI/Turntable/TurntableRewardPopupPanel.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using game;
|
||||
|
||||
public class ShowTurntableData
|
||||
{
|
||||
public ItemData itemData;
|
||||
public ShowTurntableData(ItemData itemData)
|
||||
{
|
||||
this.itemData = itemData;
|
||||
}
|
||||
}
|
||||
public class TurntableRewardPopupPanel : MonoBehaviour
|
||||
{
|
||||
Button btnClose;
|
||||
RewardItemNew itemNew;
|
||||
[SerializeField] private int popDurationInMilliseconds;//窗口停留时间,毫秒。如果为非正整数则无限期停留,需要手动点击关闭。
|
||||
//Image icon;
|
||||
//TMP_Text txtName;
|
||||
System.IDisposable disposable;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
btnClose = transform.Find("mask").GetComponent<Button>();
|
||||
itemNew = transform.Find("root/reward").GetComponent<RewardItemNew>();
|
||||
//icon = transform.Find("root/reward/icon").GetComponent<Image>();
|
||||
//txtName = transform.Find("root/reward/text_num").GetComponent<TMP_Text>();
|
||||
disposable = GContext.OnEvent<ShowTurntableData>().Subscribe(OnShowTurntableData);
|
||||
}
|
||||
private async void Start()
|
||||
{
|
||||
//btnClose.onClick.AddListener(OnBtnCloseClick);
|
||||
if (popDurationInMilliseconds > 0)
|
||||
{
|
||||
await System.Threading.Tasks.Task.Delay(popDurationInMilliseconds);
|
||||
UIManager.Instance.DestroyUI(UITypes.TurntableRewardPopupPanel);
|
||||
}
|
||||
}
|
||||
//void OnBtnCloseClick()
|
||||
//{
|
||||
// UIManager.Instance.DestroyUI(UITypes.TurntableRewardPopupPanel);
|
||||
//}
|
||||
void OnShowTurntableData(ShowTurntableData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Debug.Log($"[turntable] Current thread ID @ OnShowTurntableData: {System.Threading.Thread.CurrentThread.ManagedThreadId}");
|
||||
if (btnClose != null)
|
||||
btnClose.enabled = false;
|
||||
itemNew.SetData(data.itemData, isCanClick: true);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
}
|
||||
//await Awaiters.Seconds(1.34f);
|
||||
//await itemNew.PlayClose();
|
||||
//await itemNew.ParticleAttractor();
|
||||
//OnBtnCloseClick();
|
||||
//btnClose.enabled = true;
|
||||
//GContext.container.Resolve<IUIService>().SetImageSprite(icon, item.Icon, BasePanel.PanelName);
|
||||
//txtName.text = ConvertTools.GetNumberString((int)data.itemData.count);
|
||||
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
GContext.Publish(new ShowData());
|
||||
disposable.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e539bdd6fb17b947a857dd3585cd6cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
121
Assets/Scripts/UI/Turntable/TurntablelInfoRewardItem.cs
Normal file
121
Assets/Scripts/UI/Turntable/TurntablelInfoRewardItem.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using cfg;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using GameCore;
|
||||
using asap.core;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TurntablelInfoRewardItem : MonoBehaviour
|
||||
{
|
||||
|
||||
public WheelDrop wheelDrop;
|
||||
public WheelDrop preWheelDrop;
|
||||
UnityEngine.UI.Image icon;
|
||||
TMP_Text text_num;
|
||||
public int orignalNum = 0;
|
||||
public int rewardMulti = 1;
|
||||
ItemData itemData;
|
||||
GameObject newitem;
|
||||
GameObject arrow;
|
||||
Button btn_click;
|
||||
Image icon_card;
|
||||
Image logo;
|
||||
Image card_num;
|
||||
void Awake()
|
||||
{
|
||||
wheelDrop = null;
|
||||
text_num = transform.Find("text_num").GetComponent<TMP_Text>();
|
||||
icon = transform.Find("icon").GetComponent<UnityEngine.UI.Image>();
|
||||
newitem = transform.Find("new").gameObject;
|
||||
arrow = transform.Find("arrow").gameObject;
|
||||
|
||||
icon_card = transform.Find("icon_card").GetComponent<Image>();
|
||||
logo = transform.Find("icon_card/logo").GetComponent<Image>();
|
||||
card_num = transform.Find("icon_card/num").GetComponent<Image>();
|
||||
btn_click = GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
if (btn_click != null)
|
||||
{
|
||||
btn_click.onClick.AddListener(OnClick);
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick()
|
||||
{
|
||||
if (itemData == null || itemData.id == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GContext.container.Resolve<PlayerItemData>().ShowItemTips(itemData.id, transform);
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
int dropID = wheelDrop.DropID;
|
||||
if (GContext.container.Resolve<FishingEventData>().freecount > 0)
|
||||
{
|
||||
dropID = wheelDrop.ExtraDropID;
|
||||
text_num.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
text_num.gameObject.SetActive(wheelDrop.Type != 9);
|
||||
}
|
||||
itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(dropID);
|
||||
orignalNum = (int)itemData.count;
|
||||
UpDisplay();
|
||||
}
|
||||
public void UpDisplay()
|
||||
{
|
||||
arrow.SetActive(false);
|
||||
newitem.SetActive(false);
|
||||
text_num.text = ConvertTools.GetNumberString(orignalNum);
|
||||
var item = GContext.container.Resolve<Tables>().TbItem.Get(itemData.id);
|
||||
if (item.Type == 5)
|
||||
{
|
||||
IUIService uiService = GContext.container.Resolve<IUIService>();
|
||||
List<string> BgNameList;
|
||||
if (item.SubType == 1)
|
||||
{
|
||||
var fishCard = GContext.container.Resolve<Tables>().TbFishCardDrop.GetOrDefault(item.RedirectID);
|
||||
BgNameList = fishCard.BgNameList;
|
||||
}
|
||||
else
|
||||
{
|
||||
var fishCard = GContext.container.Resolve<Tables>().TbGeneralCardWeight.GetOrDefault(item.RedirectID);
|
||||
BgNameList = fishCard.BgNameList;
|
||||
}
|
||||
uiService.SetImageSprite(icon_card, BgNameList[0], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(logo, BgNameList[1], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(card_num, BgNameList[2], BasePanel.PanelName);
|
||||
icon_card.gameObject.SetActive(true);
|
||||
icon.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
icon_card.gameObject.SetActive(false);
|
||||
icon.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
if (preWheelDrop != null)
|
||||
{
|
||||
int dropID = preWheelDrop.DropID;
|
||||
if (GContext.container.Resolve<FishingEventData>().freecount > 0)
|
||||
{
|
||||
dropID = preWheelDrop.ExtraDropID;
|
||||
}
|
||||
ItemData preItem = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(dropID);
|
||||
if (itemData.id != preItem.id)
|
||||
{
|
||||
newitem.SetActive(true);
|
||||
}
|
||||
else if ((int)itemData.count > (int)preItem.count)
|
||||
{
|
||||
arrow.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Turntable/TurntablelInfoRewardItem.cs.meta
Normal file
11
Assets/Scripts/UI/Turntable/TurntablelInfoRewardItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8850da69c7683384b99becfacbc5432c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user