备份CatanBuilding瘦身独立工程
This commit is contained in:
929
Assets/Scripts/UI/Pinball/EventPinballPanel.cs
Normal file
929
Assets/Scripts/UI/Pinball/EventPinballPanel.cs
Normal file
@@ -0,0 +1,929 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class EventPinballPanel : BasePanel
|
||||
{
|
||||
public float m_ProgressBarSpeed = 0.5f;
|
||||
public float m_PauseTimeAfterProgressBarIsFull = 0.1f;
|
||||
|
||||
#region 新手引导
|
||||
[Header("新手相关设置")]
|
||||
[SerializeField] private GameObject m_FakeFiringPinOwner, finger;
|
||||
[SerializeField] private Image m_FakeFiringPinImage;
|
||||
|
||||
IDisposable _guideDisposable;
|
||||
public void InitGuidance()
|
||||
{
|
||||
EventPinballMain pinballMain = m_DataManager.GetCurrentEventPinballMain();
|
||||
|
||||
if (pinballMain != null)
|
||||
{
|
||||
bool isGuide = GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide(pinballMain.UIPanel);
|
||||
if (isGuide)
|
||||
{
|
||||
FishingPinballAct.Publish(new EventPinballHideFiringPinData());
|
||||
m_FakeFiringPinOwner.SetActive(true);
|
||||
finger.SetActive(false);
|
||||
_guideDisposable = GContext.OnEvent<AddIndexEvent>().Subscribe(ShowComboTipsGuide);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FakeFiringPinOwner.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShowComboTipsGuide(AddIndexEvent addIndexEvent)
|
||||
{
|
||||
Debug.Log("addIndexEvent.guideStep:" + addIndexEvent.guideSubIndex);
|
||||
Debug.Log("addIndexEvent.CompleteGuide:" + addIndexEvent.CompleteGuide);
|
||||
//Debug.Log("addIndexEvent.isAutoNext:" + addIndexEvent.isAutoNext);
|
||||
|
||||
if (addIndexEvent.guideSubIndex == 2)
|
||||
{
|
||||
m_FakeFiringPinOwner.SetActive(true);
|
||||
finger.SetActive(true);
|
||||
}
|
||||
else if (addIndexEvent.guideSubIndex > 2)
|
||||
{
|
||||
FishingPinballAct.Publish(new EventPinballShowFiringPinData());
|
||||
m_FakeFiringPinOwner.SetActive(false);
|
||||
}
|
||||
|
||||
if (addIndexEvent.CompleteGuide)
|
||||
{
|
||||
_guideDisposable?.Dispose();
|
||||
FishingPinballAct.Publish(new EventPinballShowFiringPinData());
|
||||
m_FakeFiringPinOwner.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetIconPinball(Transform pos)
|
||||
{
|
||||
icon_pinball.position = ConvertTools.WorldToScreenPoint(pos.position, false);
|
||||
}
|
||||
|
||||
public void CreateFakeFiringPin(SpriteRenderer firingPin)
|
||||
{
|
||||
if (firingPin == null) return;
|
||||
|
||||
Vector3 spriteSize = firingPin.bounds.size;
|
||||
|
||||
Vector3 screenSize = Camera.main.WorldToScreenPoint(spriteSize) - Camera.main.WorldToScreenPoint(Vector3.zero);
|
||||
|
||||
m_FakeFiringPinImage.rectTransform.sizeDelta = screenSize;
|
||||
|
||||
Vector3 screenPos = Camera.main.WorldToScreenPoint(firingPin.transform.position);
|
||||
//m_FakeFiringPinOwner.rectTransform.position = screenPos;
|
||||
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(
|
||||
m_FakeFiringPinOwner.transform.parent.transform as RectTransform,
|
||||
screenPos,
|
||||
UIManager.Instance.UICanvas.worldCamera,
|
||||
out Vector2 localPoint);
|
||||
|
||||
m_FakeFiringPinOwner.GetComponent<RectTransform>().localPosition = localPoint;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件相关
|
||||
private void InitEvent()
|
||||
{
|
||||
FishingPinballAct.Subscribe<EventPinballTokenUpdateData>(UpdateToken);
|
||||
FishingPinballAct.Subscribe<EventPinballResetMagnification>(ResetMagnification);
|
||||
FishingPinballAct.Subscribe<EventPinballRewardUpdateData>(UpdateReward);
|
||||
FishingPinballAct.Subscribe<EventPinballShowPopupData>(ShowPopup);
|
||||
FishingPinballAct.Subscribe<EventPinballHidePopupData>(HidePopup);
|
||||
FishingPinballAct.Subscribe<EventPinballShowMultipleTextData>(ShowMultipleText);
|
||||
FishingPinballAct.Subscribe<EventPinballResetPelletStatusData>(ResetPelletInUI);
|
||||
FishingPinballAct.Subscribe<EventPinballLaunchPelletStatusData>(LaunchPelletInUI);
|
||||
|
||||
// 监听关闭奖励面板
|
||||
GContext.OnEvent<RewardPanelClose>().Subscribe(OnRewardPanelClose).AddTo(FishingPinballAct.Disposables);
|
||||
}
|
||||
private bool m_IsPelletRunning = false;
|
||||
public void LaunchPelletInUI(EventPinballLaunchPelletStatusData data)
|
||||
{
|
||||
m_IsPelletRunning = true;
|
||||
}
|
||||
public void ResetPelletInUI(EventPinballResetPelletStatusData data)
|
||||
{
|
||||
if (bg_popup != null)
|
||||
{
|
||||
bg_popup.gameObject.SetActive(false);
|
||||
}
|
||||
m_IsPelletRunning = false;
|
||||
}
|
||||
private void OnRewardPanelClose(RewardPanelClose rewardPanelClose)
|
||||
{
|
||||
// 刷新奖励
|
||||
UpdateReward(null);
|
||||
|
||||
// 重置小球
|
||||
FishingPinballAct.Publish(new EventPinballResumePelletData());
|
||||
}
|
||||
private void UpdateToken(EventPinballTokenUpdateData data)
|
||||
{
|
||||
if (m_DataManager == null || Txt_num == null) return;
|
||||
|
||||
//int token = m_DataManager.GetToken() - m_DataManager.TemporaryConsumedToken;
|
||||
int token = m_DataManager.GetToken();
|
||||
Txt_num.text = "" + token;
|
||||
}
|
||||
public void ResetMagnification(EventPinballResetMagnification data)
|
||||
{
|
||||
//m_DataManager.ResetMagnification();
|
||||
|
||||
int magnification = m_DataManager.GetCurMagnification();
|
||||
string text = "x" + magnification;
|
||||
text_beilv_normal.text = text;
|
||||
text_beilv_max.text = text;
|
||||
|
||||
if (m_DataManager.IsMaxMagnification())
|
||||
{
|
||||
beilv_normal.SetActive(false);
|
||||
beilv_max.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
beilv_normal.SetActive(true);
|
||||
beilv_max.SetActive(false);
|
||||
}
|
||||
|
||||
FishingPinballAct.Publish<EventPinballBasicScore>(new EventPinballBasicScore()
|
||||
{
|
||||
Score = magnification
|
||||
});
|
||||
}
|
||||
public void UpdateReward(EventPinballRewardUpdateData data)
|
||||
{
|
||||
if (m_DataManager == null) return;
|
||||
PlayerItemData playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
var curDataItem = playerItemData.GetItemDataOne(m_DataManager.PinballData.CurDropID);
|
||||
Obj_reward.SetData(curDataItem, abbr: true);
|
||||
|
||||
var finalDataItem = playerItemData.GetItemDataOne(m_DataManager.PinballData.FinalDropID);
|
||||
Obj_finalreward.SetData(finalDataItem, abbr: true);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
EventPinballReward curReward = m_DataManager.GetEventPinballReward(m_DataManager.PinballData.RewardIndex);
|
||||
int curLevelScore = curReward.SpinPoint;
|
||||
|
||||
EventPinballReward preReward = curReward;
|
||||
int preLevelScore = preReward.SpinPoint;
|
||||
|
||||
if (m_DataManager.PinballData.RewardIndex < 1)
|
||||
{
|
||||
preLevelScore = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
preReward = m_DataManager.GetEventPinballReward(m_DataManager.PinballData.RewardIndex - 1);
|
||||
preLevelScore = preReward.SpinPoint;
|
||||
}
|
||||
|
||||
int baseScore = curLevelScore - preLevelScore;
|
||||
float displayScore = m_DataManager.PinballData.Scores - preLevelScore;
|
||||
|
||||
Img_bar.fillAmount = displayScore / baseScore;
|
||||
|
||||
bar_text_num.text = displayScore + "/" + baseScore;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.StartCoroutine(StartProgressBar(data));
|
||||
}
|
||||
}
|
||||
|
||||
public List<EventPinballRewardDisplayUpdateData> GetRewardUpdateDisplayDataList(int fromScore, int targetScore, int fromRewardIndex, int targetRewardIndex)
|
||||
{
|
||||
List<EventPinballRewardDisplayUpdateData> list = new List<EventPinballRewardDisplayUpdateData>();
|
||||
|
||||
int tmpFromScore = fromScore;
|
||||
int tmpTargetScore = targetScore;
|
||||
|
||||
int tmpFromRewardIndex = fromRewardIndex;
|
||||
|
||||
while (tmpFromRewardIndex <= targetRewardIndex)
|
||||
{
|
||||
EventPinballReward curReward = m_DataManager.GetEventPinballReward(tmpFromRewardIndex);
|
||||
int curSpinPoint = curReward.SpinPoint;
|
||||
|
||||
EventPinballReward preReward = curReward;
|
||||
int preSpinPoint = 0;
|
||||
if (tmpFromRewardIndex > 0)
|
||||
{
|
||||
preReward = m_DataManager.GetEventPinballReward(tmpFromRewardIndex - 1);
|
||||
preSpinPoint = preReward.SpinPoint;
|
||||
}
|
||||
|
||||
int tmpLevelScoreDisplay = curSpinPoint - preSpinPoint;
|
||||
|
||||
int tmpFromScoreDisplay = tmpFromScore - preSpinPoint;
|
||||
|
||||
int tmpTargetScoreDisplay = (tmpTargetScore > curSpinPoint) ? tmpLevelScoreDisplay : (tmpTargetScore - preSpinPoint);
|
||||
|
||||
float tmpFromRatio = (float)tmpFromScoreDisplay / tmpLevelScoreDisplay;
|
||||
|
||||
float tmpTargetRatio = (float)tmpTargetScoreDisplay / tmpLevelScoreDisplay;
|
||||
|
||||
EventPinballRewardDisplayUpdateData updateData = new EventPinballRewardDisplayUpdateData()
|
||||
{
|
||||
RewardId = curReward.ID,
|
||||
RewardIndex = tmpFromRewardIndex,
|
||||
FromScore = tmpFromScoreDisplay,
|
||||
TargetScore = tmpTargetScoreDisplay,
|
||||
LevelScore = tmpLevelScoreDisplay,
|
||||
FromRatio = tmpFromRatio,
|
||||
TargetRatio = tmpTargetRatio,
|
||||
DropId = (tmpTargetScoreDisplay >= tmpLevelScoreDisplay) ? curReward.DropID : -1,
|
||||
RewardDisplayDropId = curReward.DropID
|
||||
};
|
||||
|
||||
list.Add(updateData);
|
||||
|
||||
tmpFromScore = curReward.SpinPoint;
|
||||
|
||||
tmpFromRewardIndex++;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public IEnumerator StartProgressBar(EventPinballRewardUpdateData data)
|
||||
{
|
||||
Queue<EventPinballRewardDisplayUpdateData> updateQueue = new Queue<EventPinballRewardDisplayUpdateData>();
|
||||
|
||||
int fromScore = m_DataManager.PinballData.Scores;
|
||||
int targetScore = fromScore + data.Scores;
|
||||
|
||||
int curRewardIndex = m_DataManager.PinballData.RewardIndex;
|
||||
int rewardMaxIndex = m_DataManager.PinballData.RewardMaxIndex;
|
||||
int targetRewardIndex = rewardMaxIndex;
|
||||
|
||||
EventPinballReward finalReward = m_DataManager.GetEventPinballReward(rewardMaxIndex);
|
||||
int maxSpinPoint = finalReward.SpinPoint;
|
||||
|
||||
if (targetScore >= maxSpinPoint)
|
||||
{
|
||||
List<EventPinballRewardDisplayUpdateData> list1 = GetRewardUpdateDisplayDataList(fromScore, targetScore, curRewardIndex, rewardMaxIndex);
|
||||
|
||||
int count = list1.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
updateQueue.Enqueue(list1[i]);
|
||||
}
|
||||
list1.Clear();
|
||||
|
||||
fromScore = 0;
|
||||
targetScore -= maxSpinPoint;
|
||||
curRewardIndex = 0;
|
||||
|
||||
targetRewardIndex = m_DataManager.FindInsertionIndex(m_DataManager.RewardList, targetScore);
|
||||
|
||||
List<EventPinballRewardDisplayUpdateData> list2 = GetRewardUpdateDisplayDataList(fromScore, targetScore, curRewardIndex, targetRewardIndex);
|
||||
|
||||
count = list2.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
updateQueue.Enqueue(list2[i]);
|
||||
}
|
||||
list2.Clear();
|
||||
|
||||
curRewardIndex = count - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetRewardIndex = m_DataManager.FindInsertionIndex(m_DataManager.RewardList, targetScore);
|
||||
List<EventPinballRewardDisplayUpdateData> list1 = GetRewardUpdateDisplayDataList(fromScore, targetScore, curRewardIndex, targetRewardIndex);
|
||||
|
||||
int count = list1.Count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
updateQueue.Enqueue(list1[i]);
|
||||
}
|
||||
list1.Clear();
|
||||
|
||||
curRewardIndex += count - 1;
|
||||
}
|
||||
|
||||
bool syncData = updateQueue.Count > 0;
|
||||
|
||||
//foreach (var item in updateQueue)
|
||||
//{
|
||||
// Debug.LogError("---- item:" + Newtonsoft.Json.JsonConvert.SerializeObject(item));
|
||||
//}
|
||||
|
||||
List<int> rewardList = new List<int>();
|
||||
|
||||
PlayerItemData playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
|
||||
while (updateQueue.Count > 0)
|
||||
{
|
||||
var item = updateQueue.Dequeue();
|
||||
|
||||
int levelScore = item.LevelScore;
|
||||
|
||||
float tmpRatio = item.FromRatio;
|
||||
|
||||
int displayScore = 0;
|
||||
|
||||
received.SetActive(false);
|
||||
|
||||
displayScore = (int)(item.LevelScore * tmpRatio);
|
||||
bar_text_num.text = displayScore + "/" + levelScore;
|
||||
Img_bar.fillAmount = tmpRatio;
|
||||
|
||||
if (item.RewardDisplayDropId > 0)
|
||||
{
|
||||
var curDataItem = playerItemData.GetItemDataOne(item.RewardDisplayDropId);
|
||||
if (curDataItem != null)
|
||||
{
|
||||
Obj_reward.SetData(curDataItem, abbr: true);
|
||||
}
|
||||
}
|
||||
|
||||
yield return null;
|
||||
|
||||
while (tmpRatio < item.TargetRatio)
|
||||
{
|
||||
tmpRatio += m_ProgressBarSpeed * Time.deltaTime;
|
||||
|
||||
displayScore = (int)(item.LevelScore * tmpRatio);
|
||||
|
||||
bar_text_num.text = displayScore + "/" + levelScore;
|
||||
Img_bar.fillAmount = tmpRatio;
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
displayScore = item.TargetScore;
|
||||
tmpRatio = item.TargetRatio;
|
||||
|
||||
bar_text_num.text = displayScore + "/" + levelScore;
|
||||
Img_bar.fillAmount = tmpRatio;
|
||||
|
||||
if (item.DropId > 0)
|
||||
{
|
||||
rewardList.Add(item.DropId);
|
||||
}
|
||||
|
||||
if (tmpRatio >= 1f)
|
||||
{
|
||||
received.SetActive(true);
|
||||
yield return new WaitForSeconds(m_PauseTimeAfterProgressBarIsFull);
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
EventPinballReward curReward = m_DataManager.GetEventPinballReward(curRewardIndex);
|
||||
|
||||
if (syncData)
|
||||
{
|
||||
m_DataManager.PinballData.Scores = targetScore;
|
||||
m_DataManager.PinballData.RewardIndex = curRewardIndex;
|
||||
m_DataManager.PinballData.CurDropID = curReward.DropID;
|
||||
m_DataManager.SyncTemporaryData();
|
||||
m_DataManager.SyncData();
|
||||
}
|
||||
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("event_pinball"))
|
||||
{
|
||||
e.AddContent("force", m_DataManager.PinballData.Force)
|
||||
.AddContent("consume_item", m_DataManager.TemporaryConsumedToken)
|
||||
.AddContent("bounce_count", m_DataManager.AccumulatedTriggerCount)
|
||||
.AddContent("result_bonus", m_DataManager.PinballData.Multiple)
|
||||
.AddContent("result_points", m_DataManager.TemporaryScore)
|
||||
.AddContent("reward_level", curReward.ID)
|
||||
.AddContent("reward_id", Newtonsoft.Json.JsonConvert.SerializeObject(rewardList));
|
||||
}
|
||||
#endif
|
||||
|
||||
// 弹出奖励面板
|
||||
if (rewardList.Count > 0)
|
||||
{
|
||||
//#if AGG
|
||||
// using (var e = GEvent.GameEvent("event_pinball_reward"))
|
||||
// {
|
||||
// e.AddContent("total_item", m_DataManager.PinballData.TotalConsumedToken)
|
||||
// .AddContent("total_point", m_DataManager.PinballData.TotalScores)
|
||||
// .AddContent("reward_id", Newtonsoft.Json.JsonConvert.SerializeObject(rewardList))
|
||||
// .AddContent("reward_level", curReward.ID);
|
||||
// }
|
||||
//#endif
|
||||
|
||||
GContext.container.Resolve<PlayerItemData>()?.AddItemByDropList(rewardList);
|
||||
GContext.Publish(new ShowData());
|
||||
}
|
||||
else
|
||||
{
|
||||
FishingPinballAct.Publish(new EventPinballResumePelletData());
|
||||
}
|
||||
}
|
||||
private void ShowPopup(EventPinballShowPopupData data)
|
||||
{
|
||||
if (bg_popup.gameObject.activeSelf == false)
|
||||
{
|
||||
bg_popup.gameObject.SetActive(true);
|
||||
}
|
||||
bg_popup.Play("point_popup_in");
|
||||
|
||||
popup_icon_point.gameObject.SetActive(true);
|
||||
|
||||
string text = "" + data.Scores;
|
||||
|
||||
TMP_Text hideText1 = popup_Txt_num_normal;
|
||||
TMP_Text hideText2 = popup_Txt_num_max;
|
||||
TMP_Text showText = popup_Txt_num;
|
||||
|
||||
if (data.BonusType == EventPinballBonusType.TypeMultiple)
|
||||
{
|
||||
hideText1 = popup_Txt_num;
|
||||
|
||||
if (data.IsMultipleMax)
|
||||
{
|
||||
hideText2 = popup_Txt_num_normal;
|
||||
showText = popup_Txt_num_max;
|
||||
}
|
||||
else
|
||||
{
|
||||
hideText2 = popup_Txt_num_max;
|
||||
showText = popup_Txt_num_normal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hideText1 = popup_Txt_num_normal;
|
||||
hideText2 = popup_Txt_num_max;
|
||||
showText = popup_Txt_num;
|
||||
}
|
||||
|
||||
hideText1.gameObject.SetActive(false);
|
||||
hideText2.gameObject.SetActive(false);
|
||||
showText.gameObject.SetActive(true);
|
||||
showText.text = text;
|
||||
}
|
||||
private void HidePopup(EventPinballHidePopupData data)
|
||||
{
|
||||
popup_icon_point.gameObject.SetActive(false);
|
||||
bg_popup.Play("point_popup_out");
|
||||
}
|
||||
[Header("MultipleText 动画设置")]
|
||||
[SerializeField] private float m_MultipleTextScaleMax = 1.2f;
|
||||
[SerializeField] private float m_MultipleTextScaleMin = 1.1f;
|
||||
[SerializeField] private int m_MultipleTextScaleTimes = 2;
|
||||
[SerializeField] private float m_MultipleTextPerScaleDuration = 0.1f;
|
||||
[SerializeField] private float m_MultipleTextFlyingDuration = 0.6f;
|
||||
|
||||
public void ShowMultipleText(EventPinballShowMultipleTextData data)
|
||||
{
|
||||
if (data == null) return;
|
||||
|
||||
if (m_DataManager.IsSimulatorMode)
|
||||
{
|
||||
FishingPinballAct.Publish(new EventPinballResumePelletData());
|
||||
return;
|
||||
}
|
||||
|
||||
popup_icon_point.gameObject.SetActive(true);
|
||||
|
||||
TMP_Text showText = MultipleText;
|
||||
TMP_Text hideText = MultipleText_max;
|
||||
|
||||
if (data.IsMultipleMax)
|
||||
{
|
||||
showText = MultipleText_max;
|
||||
hideText = MultipleText;
|
||||
}
|
||||
|
||||
hideText.gameObject.SetActive(false);
|
||||
showText.gameObject.SetActive(true);
|
||||
showText.text = data.Tips;
|
||||
|
||||
showText.transform.localScale = new Vector3(m_MultipleTextScaleMin, m_MultipleTextScaleMin, 1f);
|
||||
|
||||
Vector3 screenPos = Camera.main.WorldToScreenPoint(data.Position);
|
||||
Vector2 localPoint;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(
|
||||
UIManager.Instance.UICanvas.transform as RectTransform,
|
||||
screenPos,
|
||||
UIManager.Instance.UICanvas.worldCamera,
|
||||
out localPoint);
|
||||
|
||||
showText.rectTransform.anchoredPosition = localPoint;
|
||||
|
||||
showText.DOKill();
|
||||
|
||||
float gap = (m_MultipleTextScaleMax - m_MultipleTextScaleMin) / m_MultipleTextScaleTimes;
|
||||
|
||||
var sequence = DOTween.Sequence();
|
||||
|
||||
var scale = m_MultipleTextScaleMax;
|
||||
for (int i = 1; i < m_MultipleTextScaleTimes; ++i)
|
||||
{
|
||||
float tmpScale = scale;
|
||||
sequence.Append(showText.transform.DOScale(tmpScale, m_MultipleTextPerScaleDuration).SetEase(Ease.Linear));
|
||||
sequence.Append(showText.transform.DOScale(m_MultipleTextScaleMin, m_MultipleTextPerScaleDuration).SetEase(Ease.Linear));
|
||||
scale -= gap;
|
||||
}
|
||||
|
||||
sequence.Append(showText.transform.DOMove(MultipleTextTargetPosition.position, m_MultipleTextFlyingDuration).SetEase(Ease.Linear));
|
||||
sequence.AppendCallback(() =>
|
||||
{
|
||||
showText.gameObject.SetActive(false);
|
||||
hideText.gameObject.SetActive(false);
|
||||
|
||||
string text = "" + m_DataManager.TemporaryScore;
|
||||
|
||||
TMP_Text hidePopupText1 = popup_Txt_num_normal;
|
||||
TMP_Text hidePopupText2 = popup_Txt_num_max;
|
||||
TMP_Text showPopupText = popup_Txt_num;
|
||||
|
||||
if (data.BonusType == EventPinballBonusType.TypeMultiple)
|
||||
{
|
||||
hidePopupText1 = popup_Txt_num;
|
||||
|
||||
if (data.IsMultipleMax)
|
||||
{
|
||||
hidePopupText2 = popup_Txt_num_normal;
|
||||
showPopupText = popup_Txt_num_max;
|
||||
}
|
||||
else
|
||||
{
|
||||
hidePopupText2 = popup_Txt_num_max;
|
||||
showPopupText = popup_Txt_num_normal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hidePopupText1 = popup_Txt_num_normal;
|
||||
hidePopupText2 = popup_Txt_num_max;
|
||||
showPopupText = popup_Txt_num;
|
||||
}
|
||||
|
||||
hidePopupText1.gameObject.SetActive(false);
|
||||
hidePopupText2.gameObject.SetActive(false);
|
||||
showPopupText.gameObject.SetActive(true);
|
||||
showPopupText.text = text;
|
||||
|
||||
//FishingPinballAct.Publish(new EventPinballHidePopupData());
|
||||
|
||||
// 播放动画
|
||||
FlyTemporaryIconAndScore(data.BonusType, data.IsMultipleMax, text, popup_icon_point.transform.position, popup_icon_point.transform.localScale);
|
||||
|
||||
//if (!data.IsMultipleMax)
|
||||
//{
|
||||
// FishingPinballAct.Publish(new EventPinballRewardUpdateData()
|
||||
// {
|
||||
// Scores = data.Scores
|
||||
// });
|
||||
//}
|
||||
});
|
||||
sequence.Play();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 动画/特效
|
||||
[Header("icon_energy 动画设置")]
|
||||
[SerializeField] private float m_FlyingIconAndScoreScale1 = 1.2f;
|
||||
[SerializeField] private float m_FlyingIconAndScoreStep1Duration1 = 0.5f;
|
||||
[SerializeField] private float m_FlyingIconAndScoreEffect1Duration1 = 0.6f;
|
||||
[SerializeField] private float m_FlyingIconAndScoreScale2 = 0.6f;
|
||||
[SerializeField] private float m_FlyingIconAndScoreDuration2 = 0.5f;
|
||||
//[SerializeField] private Vector3 m_IconEnergyScale = new Vector3(0.2f, 0.2f, 0f);
|
||||
[SerializeField] private float m_IconEnergyScale = 1.2f;
|
||||
[SerializeField] private float m_IconEnergyScaleDuration = 0.5f;
|
||||
[SerializeField] private int m_IconEnergyScaleTimes = 10;
|
||||
private void FlyTemporaryIconAndScore(EventPinballBonusType bonusType, bool isMultipleMax, string text, Vector3 srcPosition, Vector3 srcScale)
|
||||
{
|
||||
Vector3 targetScale = new Vector3(icon_energy.transform.localScale.x, icon_energy.transform.localScale.y, icon_energy.transform.localScale.z);
|
||||
Vector3 targetPosition = new Vector3(icon_energy.transform.position.x, icon_energy.transform.position.y, icon_energy.transform.position.z);
|
||||
|
||||
TemporaryIconAndScore.sprite = popup_icon_point.sprite;
|
||||
|
||||
TMP_Text hideText1 = TemporaryIconAndScore_Txt_num;
|
||||
TMP_Text hideText2 = TemporaryIconAndScore_Txt_num_max;
|
||||
TMP_Text showText = TemporaryIconAndScore_Txt_num_normal;
|
||||
|
||||
if (bonusType == EventPinballBonusType.TypeMultiple)
|
||||
{
|
||||
hideText1 = TemporaryIconAndScore_Txt_num;
|
||||
if (isMultipleMax)
|
||||
{
|
||||
hideText2 = TemporaryIconAndScore_Txt_num_normal;
|
||||
showText = TemporaryIconAndScore_Txt_num_max;
|
||||
}
|
||||
else
|
||||
{
|
||||
hideText2 = TemporaryIconAndScore_Txt_num_max;
|
||||
showText = TemporaryIconAndScore_Txt_num_normal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hideText1 = TemporaryIconAndScore_Txt_num_normal;
|
||||
hideText2 = TemporaryIconAndScore_Txt_num_max;
|
||||
showText = TemporaryIconAndScore_Txt_num;
|
||||
}
|
||||
|
||||
hideText1.gameObject.SetActive(false);
|
||||
hideText2.gameObject.SetActive(false);
|
||||
|
||||
showText.gameObject.SetActive(true);
|
||||
showText.text = text;
|
||||
|
||||
popup_icon_point.gameObject.SetActive(false);
|
||||
|
||||
Vector3 tmpScale = new Vector3(srcScale.x, srcScale.y, srcScale.z);
|
||||
|
||||
TemporaryIconAndScore.transform.localScale = tmpScale;
|
||||
TemporaryIconAndScore.transform.position = srcPosition;
|
||||
|
||||
TemporaryIconAndScore.gameObject.SetActive(true);
|
||||
TemporaryIconAndScore.transform.DOKill();
|
||||
|
||||
TemporaryIconAndScore_Effect1.SetActive(true);
|
||||
|
||||
var sequence = DOTween.Sequence();
|
||||
|
||||
sequence.Append(TemporaryIconAndScore.transform.DOScale(m_FlyingIconAndScoreScale1, m_FlyingIconAndScoreStep1Duration1).SetEase(Ease.Linear));
|
||||
//sequence.AppendCallback(() =>
|
||||
//{
|
||||
// TemporaryIconAndScore_Effect1.SetActive(true);
|
||||
//});
|
||||
sequence.Append(TemporaryIconAndScore.transform.DOScale(tmpScale.x, m_FlyingIconAndScoreStep1Duration1).SetEase(Ease.Linear));
|
||||
|
||||
sequence.AppendInterval(m_FlyingIconAndScoreEffect1Duration1);
|
||||
|
||||
sequence.AppendCallback(() =>
|
||||
{
|
||||
TemporaryIconAndScore_Effect1.SetActive(false);
|
||||
FishingPinballAct.Publish(new EventPinballHidePopupData());
|
||||
});
|
||||
|
||||
sequence.Append(TemporaryIconAndScore.transform.DOMove(targetPosition, m_FlyingIconAndScoreDuration2).SetEase(Ease.Linear));
|
||||
sequence.Join(TemporaryIconAndScore.transform.DOScale(m_FlyingIconAndScoreScale2, m_FlyingIconAndScoreDuration2).SetEase(Ease.Linear));
|
||||
|
||||
sequence.AppendCallback(() =>
|
||||
{
|
||||
TemporaryIconAndScore.gameObject.SetActive(false);
|
||||
|
||||
FishingPinballAct.Publish(new EventPinballRewardUpdateData()
|
||||
{
|
||||
Scores = m_DataManager.TemporaryScore
|
||||
});
|
||||
|
||||
icon_energy.transform.DOKill();
|
||||
|
||||
icon_energy_Effect1.SetActive(true);
|
||||
|
||||
var sequence1 = DOTween.Sequence();
|
||||
|
||||
sequence1.Append(icon_energy.transform.DOScale(m_IconEnergyScale, m_IconEnergyScaleDuration).SetEase(Ease.Linear));
|
||||
|
||||
//sequence1.AppendCallback(() =>
|
||||
//{
|
||||
// icon_energy_Effect1.SetActive(true);
|
||||
//});
|
||||
sequence1.Append(icon_energy.transform.DOScale(targetScale.x, m_IconEnergyScaleDuration).SetEase(Ease.Linear));
|
||||
|
||||
//sequence1.Append(icon_energy.transform.DOScale(targetScale.x, m_IconEnergyScaleDuration).SetEase(Ease.Linear));
|
||||
|
||||
sequence1.AppendCallback(() =>
|
||||
{
|
||||
icon_energy.transform.localScale = targetScale;
|
||||
icon_energy_Effect1.SetActive(false);
|
||||
});
|
||||
|
||||
sequence1.Play();
|
||||
});
|
||||
|
||||
sequence.Play();
|
||||
}
|
||||
|
||||
[Header("倍率按钮 动画设置")]
|
||||
[SerializeField] private float m_BtnMagnificationReactTime = 0.12f;
|
||||
[SerializeField] private string m_BtnMagnificationPressedAnim = "Pressed";
|
||||
[SerializeField] private string m_BtnMagnificationNormalAnim = "Normal";
|
||||
#endregion
|
||||
|
||||
#region UI
|
||||
private Button Btn_questionmark;
|
||||
private TMP_Text Txt_titleName;
|
||||
private TMP_Text Txt_time;
|
||||
|
||||
private Image icon_energy;
|
||||
private GameObject icon_energy_Effect1;
|
||||
|
||||
private Image Img_bar;
|
||||
private RewardItemNew Obj_reward;
|
||||
private RewardItemNew Obj_finalreward;
|
||||
private GameObject received;
|
||||
private TMP_Text bar_text_num;
|
||||
|
||||
private TMP_Text Txt_num;
|
||||
|
||||
private Button btn_beilv;
|
||||
private Animator btn_beilv_animator;
|
||||
private GameObject beilv_normal;
|
||||
private TMP_Text text_beilv_normal;
|
||||
private GameObject beilv_max;
|
||||
private TMP_Text text_beilv_max;
|
||||
|
||||
private Button Btn_close;
|
||||
|
||||
private Animator bg_popup;
|
||||
private Image popup_icon_point;
|
||||
private TMP_Text popup_Txt_num;
|
||||
private TMP_Text popup_Txt_num_normal;
|
||||
private TMP_Text popup_Txt_num_max;
|
||||
|
||||
private Transform MultipleTextTargetPosition;
|
||||
private TMP_Text MultipleText;
|
||||
private TMP_Text MultipleText_max;
|
||||
|
||||
private Image TemporaryIconAndScore;
|
||||
private TMP_Text TemporaryIconAndScore_Txt_num;
|
||||
private TMP_Text TemporaryIconAndScore_Txt_num_normal;
|
||||
private TMP_Text TemporaryIconAndScore_Txt_num_max;
|
||||
private GameObject TemporaryIconAndScore_Effect1;
|
||||
Transform icon_pinball;
|
||||
private void InitUI()
|
||||
{
|
||||
Btn_questionmark = transform.Find("root/title/Btn_questionmark").GetComponent<Button>();
|
||||
Txt_titleName = transform.Find("root/title/Txt_titleName").GetComponent<TMP_Text>();
|
||||
Txt_time = transform.Find("root/title/Txt_time").GetComponent<TMP_Text>();
|
||||
Txt_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end", ConvertTools.ConvertTime2(m_DataManager.RemainingTime));
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f)).Subscribe(_ =>
|
||||
{
|
||||
Txt_time.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end", ConvertTools.ConvertTime2(m_DataManager.RemainingTime));
|
||||
}).AddTo(this);
|
||||
Btn_questionmark.onClick.RemoveAllListeners();
|
||||
Btn_questionmark.onClick.AddListener(OnBtnQuestionmarkClickListener);
|
||||
|
||||
icon_energy = transform.Find("root/title/bg_reward/icon_energy").GetComponent<Image>();
|
||||
icon_energy_Effect1 = icon_energy.transform.Find("fx_eventpinball_points_popup").gameObject;
|
||||
icon_energy_Effect1.SetActive(false);
|
||||
|
||||
Img_bar = transform.Find("root/title/bg_reward/bg_bar/Img_bar").GetComponent<Image>();
|
||||
Obj_reward = transform.Find("root/title/bg_reward/bg_bar/Obj_reward").GetComponent<RewardItemNew>();
|
||||
Obj_finalreward = transform.Find("root/title/bg_reward/bg_bar/Obj_finalreward").GetComponent<RewardItemNew>();
|
||||
received = transform.Find("root/title/bg_reward/bg_bar/Obj_reward/received").gameObject;
|
||||
bar_text_num = transform.Find("root/title/bg_reward/bg_bar/text_num").GetComponent<TMP_Text>();
|
||||
|
||||
Txt_num = transform.Find("root/icon_pinball/Txt_num").GetComponent<TMP_Text>();
|
||||
|
||||
btn_beilv = transform.Find("root/icon_pinball/btn_beilv").GetComponent<Button>();
|
||||
btn_beilv.onClick.RemoveAllListeners();
|
||||
btn_beilv.onClick.AddListener(OnBtnBeilvClickListener);
|
||||
btn_beilv_animator = btn_beilv.transform.GetComponent<Animator>();
|
||||
beilv_normal = btn_beilv.transform.Find("beilv").gameObject;
|
||||
text_beilv_normal = beilv_normal.transform.Find("text_beilv").GetComponent<TMP_Text>();
|
||||
beilv_max = btn_beilv.transform.Find("beilv_max").gameObject;
|
||||
text_beilv_max = beilv_max.transform.Find("text_beilv").GetComponent<TMP_Text>();
|
||||
beilv_normal.SetActive(true);
|
||||
beilv_max.SetActive(false);
|
||||
|
||||
Btn_close = transform.Find("root/Btn_close").GetComponent<Button>();
|
||||
//Btn_close.onClick.RemoveAllListeners();
|
||||
Btn_close.onClick.AddListener(OnBtnCloseClickListener);
|
||||
|
||||
bg_popup = transform.Find("root/bg_popup").GetComponent<Animator>();
|
||||
popup_icon_point = transform.Find("root/bg_popup/icon_point").GetComponent<Image>();
|
||||
popup_Txt_num = transform.Find("root/bg_popup/icon_point/Txt_num").GetComponent<TMP_Text>();
|
||||
popup_Txt_num_normal = transform.Find("root/bg_popup/icon_point/Txt_num_normal").GetComponent<TMP_Text>();
|
||||
popup_Txt_num_max = transform.Find("root/bg_popup/icon_point/Txt_num_max").GetComponent<TMP_Text>();
|
||||
bg_popup.gameObject.SetActive(false);
|
||||
|
||||
icon_pinball = transform.Find("root/icon_pinball");
|
||||
|
||||
MultipleTextTargetPosition = transform.Find("MultipleTextTargetPosition");
|
||||
MultipleText = transform.Find("MultipleText").GetComponent<TMP_Text>();
|
||||
MultipleText.gameObject.SetActive(false);
|
||||
MultipleText_max = transform.Find("MultipleText_max").GetComponent<TMP_Text>();
|
||||
MultipleText_max.gameObject.SetActive(false);
|
||||
|
||||
TemporaryIconAndScore = transform.Find("TemporaryIconAndScore").GetComponent<Image>();
|
||||
TemporaryIconAndScore_Txt_num = TemporaryIconAndScore.transform.Find("Txt_num").GetComponent<TMP_Text>();
|
||||
TemporaryIconAndScore_Txt_num_normal = TemporaryIconAndScore.transform.Find("Txt_num_normal").GetComponent<TMP_Text>();
|
||||
TemporaryIconAndScore_Txt_num_max = TemporaryIconAndScore.transform.Find("Txt_num_max").GetComponent<TMP_Text>();
|
||||
TemporaryIconAndScore_Effect1 = TemporaryIconAndScore.transform.Find("fx_ui_eventpinball_digit_popup").gameObject;
|
||||
TemporaryIconAndScore_Effect1.SetActive(false);
|
||||
TemporaryIconAndScore.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private async void OnBtnQuestionmarkClickListener()
|
||||
{
|
||||
if (m_IsPelletRunning)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_62"));
|
||||
return;
|
||||
}
|
||||
|
||||
await UIManager.Instance.ShowUI(m_DataManager.GetInfoPanel());
|
||||
UIManager.Instance.HideUI(m_DataManager.GetUIPanel());
|
||||
}
|
||||
|
||||
private async void OnBtnBeilvClickListener()
|
||||
{
|
||||
if (m_IsPelletRunning)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_62"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_DataManager.ScrollToTheNextMagnification();
|
||||
|
||||
if (m_DataManager.IsMaxMagnification())
|
||||
{
|
||||
beilv_normal.SetActive(false);
|
||||
beilv_max.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
beilv_normal.SetActive(true);
|
||||
beilv_max.SetActive(false);
|
||||
}
|
||||
|
||||
ResetMagnification(null);
|
||||
|
||||
btn_beilv_animator.Play(m_BtnMagnificationPressedAnim);
|
||||
|
||||
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(m_BtnMagnificationReactTime));
|
||||
|
||||
btn_beilv_animator.Play(m_BtnMagnificationNormalAnim);
|
||||
}
|
||||
|
||||
public void OnBtnCloseClickListener()
|
||||
{
|
||||
if (m_IsPelletRunning)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_62"));
|
||||
return;
|
||||
}
|
||||
|
||||
// 关闭当前Act
|
||||
GContext.Publish(new UnloadActToNextAct());
|
||||
}
|
||||
|
||||
public void RefreshData()
|
||||
{
|
||||
m_IsPelletRunning = false;
|
||||
|
||||
UpdateToken(null);
|
||||
|
||||
ResetMagnification(null);
|
||||
|
||||
UpdateReward(null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
private EventPinballDataManager m_DataManager;
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
m_DataManager = GContext.container.Resolve<EventPinballDataManager>();
|
||||
|
||||
InitUI();
|
||||
|
||||
InitEvent();
|
||||
|
||||
RefreshData();
|
||||
|
||||
InitGuidance();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (bg_popup != null)
|
||||
{
|
||||
bg_popup.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
_guideDisposable?.Dispose();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user