备份CatanBuilding瘦身独立工程
This commit is contained in:
144
Assets/Scripts/EventPinball/PinballScoringWidgetScore.cs
Normal file
144
Assets/Scripts/EventPinball/PinballScoringWidgetScore.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class PinballScoringWidgetScore : PinballScoringWidgetBase
|
||||
{
|
||||
[SerializeField] private TextMeshPro m_TextMesh;
|
||||
|
||||
#region 特效相关
|
||||
[Header("特效设置")]
|
||||
[SerializeField] public GameObject m_Effect1;
|
||||
[SerializeField] public GameObject m_Effect2;
|
||||
[SerializeField] public float m_Effect1Duration = 0.3f;
|
||||
[SerializeField] public float m_Effect2Duration = 0.3f;
|
||||
|
||||
private float m_Effect1_CumulativeTime = 0f;
|
||||
public void ShowEffect1()
|
||||
{
|
||||
m_Effect1_CumulativeTime = 0f;
|
||||
}
|
||||
private void UpdateEffect1()
|
||||
{
|
||||
if (m_Effect1 != null)
|
||||
{
|
||||
if (m_Effect1_CumulativeTime < m_Effect1Duration)
|
||||
{
|
||||
if (m_Effect1.activeSelf == false)
|
||||
{
|
||||
m_Effect1.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Effect1.activeSelf == true)
|
||||
{
|
||||
m_Effect1.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
m_Effect1_CumulativeTime += Time.deltaTime;
|
||||
if (m_Effect1_CumulativeTime > float.MaxValue)
|
||||
{
|
||||
m_Effect1_CumulativeTime = m_Effect1Duration + 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float m_Effect2_CumulativeTime = 0f;
|
||||
public void ShowEffect2(EventPinballShowWidgetScoreEffect2Data data)
|
||||
{
|
||||
m_Effect2_CumulativeTime = 0f;
|
||||
}
|
||||
private void UpdateEffect2()
|
||||
{
|
||||
if (m_Effect2 != null)
|
||||
{
|
||||
if (m_Effect2_CumulativeTime < m_Effect2Duration)
|
||||
{
|
||||
if (m_Effect2.activeSelf == false)
|
||||
{
|
||||
m_Effect2.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Effect2.activeSelf == true)
|
||||
{
|
||||
m_Effect2.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
m_Effect2_CumulativeTime += Time.deltaTime;
|
||||
if (m_Effect2_CumulativeTime > float.MaxValue)
|
||||
{
|
||||
m_Effect2_CumulativeTime = m_Effect2Duration + 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据
|
||||
public override string GetTip()
|
||||
{
|
||||
return "+" + Number;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件相关
|
||||
private void InitEvent()
|
||||
{
|
||||
FishingPinballAct.Subscribe<EventPinballBasicScore>(UpdateScore);
|
||||
FishingPinballAct.Subscribe<EventPinballBasicScoreHideData>(HideScore);
|
||||
FishingPinballAct.Subscribe<EventPinballBasicScoreShowData>(ShowScore);
|
||||
FishingPinballAct.Subscribe<EventPinballShowWidgetScoreEffect2Data>(ShowEffect2);
|
||||
}
|
||||
private void UpdateScore(EventPinballBasicScore data)
|
||||
{
|
||||
if (data == null) return;
|
||||
Number = data.Score;
|
||||
|
||||
if (m_TextMesh != null)
|
||||
{
|
||||
m_TextMesh.text = "" + Number;
|
||||
}
|
||||
}
|
||||
private void HideScore(EventPinballBasicScoreHideData data)
|
||||
{
|
||||
if (m_TextMesh != null)
|
||||
{
|
||||
m_TextMesh.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
private void ShowScore(EventPinballBasicScoreShowData data)
|
||||
{
|
||||
if (m_TextMesh != null)
|
||||
{
|
||||
m_TextMesh.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
m_BonusType = EventPinballBonusType.TypeScore;
|
||||
InitEvent();
|
||||
|
||||
m_Effect1_CumulativeTime = m_Effect1Duration + 1f;
|
||||
m_Effect2_CumulativeTime = m_Effect2Duration + 1f;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
UpdateEffect1();
|
||||
UpdateEffect2();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user