You've already forked taptap2024_GJ_chidouren
init
This commit is contained in:
69
Assets/Scripts/Views/Common/CommonAudioModule.cs
Normal file
69
Assets/Scripts/Views/Common/CommonAudioModule.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using Framework.Audio;
|
||||
using Framework.Timer;
|
||||
using Framework.Utils.Extend;
|
||||
using IcecreamView;
|
||||
using UnityEngine;
|
||||
using AudioType = Framework.Audio.AudioType;
|
||||
|
||||
namespace Views.Common
|
||||
{
|
||||
public class CommonAudioModule : IcecreamView.IC_AbstractModule
|
||||
{
|
||||
[Serializable]
|
||||
public class AudioData
|
||||
{
|
||||
public SeAudio AudioName = SeAudio.None;
|
||||
public bool IsLoop = false;
|
||||
public float Volume = 1;
|
||||
public float Delay = 0;
|
||||
|
||||
public AudioData (SeAudio audioName)
|
||||
{
|
||||
this.AudioName = audioName;
|
||||
}
|
||||
}
|
||||
|
||||
private TimeHandler _timeHandler;
|
||||
[Header("页面打开时,环境音效缩放系数")]
|
||||
public float BseVolumeScaleOffset = 1;
|
||||
[Header("页面打开时,环境音效缩放时间")]
|
||||
public float BseVolumeScaleTime = 0.35f;
|
||||
|
||||
[SerializeField] private AudioData _openAudioData = new AudioData (SeAudio.PanelPop_Pop01);
|
||||
[SerializeField] private AudioData _closeAudioData= new AudioData (SeAudio.PanelPop_Pop02);
|
||||
|
||||
public override void OnOpenView (IC_ViewData msgData)
|
||||
{
|
||||
if (!BseVolumeScaleOffset.Compare(1f))
|
||||
{
|
||||
// AudioManager.Instance.SetGroupVolume(AudioType.BSE , AudioManager.Instance.BSEValue * BseVolumeScaleOffset , BseVolumeScaleTime);
|
||||
AudioManager.Instance.SetGlobalVolume(AudioType.BGM , AudioManager.Instance.MusicValue * BseVolumeScaleOffset , BseVolumeScaleTime);
|
||||
}
|
||||
|
||||
_timeHandler?.Kill ();
|
||||
if (_openAudioData.AudioName != SeAudio.None)
|
||||
{
|
||||
_timeHandler = GameUpdateMgr.Instance.CreateTimer (_openAudioData.Delay , () =>
|
||||
{
|
||||
AudioManager.Instance.PlaySoundEffect (_openAudioData.AudioName , _openAudioData.Volume , 0 , _openAudioData.IsLoop);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnCloseView ()
|
||||
{
|
||||
if (!BseVolumeScaleOffset.Compare(1f))
|
||||
{
|
||||
// AudioManager.Instance.SetGroupVolume(AudioType.BSE , AudioManager.Instance.BSEValue , BseVolumeScaleTime);
|
||||
AudioManager.Instance.SetGlobalVolume(AudioType.BGM , AudioManager.Instance.MusicValue , BseVolumeScaleTime);
|
||||
}
|
||||
|
||||
_timeHandler?.Kill ();
|
||||
if (_closeAudioData.AudioName != SeAudio.None)
|
||||
{
|
||||
AudioManager.Instance.PlaySoundEffect (_closeAudioData.AudioName , _closeAudioData.Volume , 0 , _closeAudioData.IsLoop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Views/Common/CommonAudioModule.cs.meta
Normal file
3
Assets/Scripts/Views/Common/CommonAudioModule.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a5dc5711836436e90b7bb10f3e2a26a
|
||||
timeCreated: 1704357292
|
||||
27
Assets/Scripts/Views/Common/CommonBlurEffectTable.cs
Normal file
27
Assets/Scripts/Views/Common/CommonBlurEffectTable.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using Framework.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Views.Common
|
||||
{
|
||||
public class CommonBlurEffectTable: IcecreamView.IC_AbstractModule
|
||||
{
|
||||
public BlurEffectType BlurEffectType = BlurEffectType.Blur;
|
||||
private float EffectDuration = 0.2f;
|
||||
|
||||
public override void OnFocusActive ()
|
||||
{
|
||||
CameraEffectUtils.Instance.SetGameCamBlur (1 , this.EffectDuration , null , this.BlurEffectType);
|
||||
}
|
||||
|
||||
public override void OnFocusInactive ()
|
||||
{
|
||||
if (UIManager.Instance.CurFocusView != null && UIManager.Instance.CurFocusView.GetComponent<CommonBlurEffectTable> () != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CameraEffectUtils.Instance.SetGameCamBlur (0 , this.EffectDuration , null , this.BlurEffectType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f3bea63d1b448c4bbbacbb7b3eec2dd
|
||||
timeCreated: 1706023228
|
||||
66
Assets/Scripts/Views/Common/CommonCardHubTip.cs
Normal file
66
Assets/Scripts/Views/Common/CommonCardHubTip.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using Framework.UI;
|
||||
using Game.EventDefine;
|
||||
using IcecreamView;
|
||||
using Script.Core.Utils.Extend;
|
||||
using UniFramework.Event;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Views.Common
|
||||
{
|
||||
public class CommonCardHubTip : IcecreamView.IC_AbstractModule
|
||||
{
|
||||
public CommonTipBoxFrame _propTipBox; // 道具提示框
|
||||
private bool _hasShowWeaponTip;
|
||||
|
||||
|
||||
private EventGroup _eventGroup;
|
||||
|
||||
public override void OnInitView ()
|
||||
{
|
||||
this._propTipBox.InitBox ();
|
||||
this._eventGroup = new EventGroup ();
|
||||
this._eventGroup.AddListener<GameEventDefine.ShowTipBox> (this.OnShowTipBox);
|
||||
UIManager.Instance.OnViewFocusChanged += this.OnViewFocusChanged;
|
||||
}
|
||||
|
||||
private void OnShowTipBox (IEventMessage obj)
|
||||
{
|
||||
var message = obj as GameEventDefine.ShowTipBox;
|
||||
if (message == null || message.tipText == null)
|
||||
{
|
||||
this._propTipBox.CloseTipBox ();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((this.ViewConnector.HasFocusView && this._hasShowWeaponTip) || !this.ViewConnector.HasFocusView)
|
||||
{
|
||||
var msg = new CommonTipBox.Message ();
|
||||
msg.title = message.tipText;
|
||||
msg.content = message.content;
|
||||
this._propTipBox.ShowTipBox (message.box , msg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnCloseView ()
|
||||
{
|
||||
this._propTipBox.ReleaseTipBox ();
|
||||
this._eventGroup.RemoveAllListener ();
|
||||
UIManager.Instance.OnViewFocusChanged -= this.OnViewFocusChanged;
|
||||
}
|
||||
|
||||
private void OnViewFocusChanged (IC_AbstractView obj)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnFocusActive ()
|
||||
{
|
||||
this._hasShowWeaponTip = true;
|
||||
}
|
||||
|
||||
public override void OnFocusInactive ()
|
||||
{
|
||||
this._hasShowWeaponTip = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Views/Common/CommonCardHubTip.cs.meta
Normal file
3
Assets/Scripts/Views/Common/CommonCardHubTip.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c8bf83518f047e7a8b1c2bcd2a828e4
|
||||
timeCreated: 1723792207
|
||||
3
Assets/Scripts/Views/Common/MessageTipBox.meta
Normal file
3
Assets/Scripts/Views/Common/MessageTipBox.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de599dce7c3f49ad8a02433668d1e439
|
||||
timeCreated: 1722932772
|
||||
@@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Views.Common
|
||||
{
|
||||
public abstract class ACommonTipBoxMessage : MonoBehaviour
|
||||
{
|
||||
public virtual Vector2 ExtraDistance => Vector2.one * 0.5f;
|
||||
public abstract void Init ();
|
||||
public abstract void ShowTipBpx (object message);
|
||||
public abstract void ReleaseTipBox ();
|
||||
|
||||
public virtual void CloseBox ()
|
||||
{
|
||||
gameObject.SetActive (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b5e5cb31a0042efa9fb360fea033423
|
||||
timeCreated: 1722830445
|
||||
87
Assets/Scripts/Views/Common/MessageTipBox/CommonTipBox.cs
Normal file
87
Assets/Scripts/Views/Common/MessageTipBox/CommonTipBox.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using System.Collections.Generic;
|
||||
using Framework.Timer;
|
||||
using Sirenix.Utilities;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Views.Common
|
||||
{
|
||||
public class CommonTipBox : ACommonTipBoxMessage
|
||||
{
|
||||
public class Message
|
||||
{
|
||||
public string title;
|
||||
public string content;
|
||||
}
|
||||
|
||||
public Vector2 extraDistance = Vector2.one * 0.5f;
|
||||
public TMP_Text _title;
|
||||
public TMP_Text _content;
|
||||
public override Vector2 ExtraDistance => this.extraDistance;
|
||||
public float _maxDuration = 5f;
|
||||
private TimeHandler _timeHandler;
|
||||
public bool HasClickScreenClose = true;
|
||||
|
||||
public override void Init ()
|
||||
{
|
||||
this._title.text = "";
|
||||
this._content.text = "";
|
||||
this.gameObject.SetActive (false);
|
||||
}
|
||||
|
||||
public override void ShowTipBpx (object message)
|
||||
{
|
||||
this.gameObject.SetActive (false);
|
||||
this._timeHandler?.Kill ();
|
||||
if (message is Message msg)
|
||||
{
|
||||
this._timeHandler?.Kill ();
|
||||
this._timeHandler = GameUpdateMgr.Instance.CreateTimer (this._maxDuration , CloseBox);
|
||||
this._title.gameObject.SetActive (!msg.title.IsNullOrWhitespace ());
|
||||
this._title.text = msg.title;
|
||||
this._content.text = msg.content;
|
||||
this.gameObject.SetActive (true);
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(this.transform as RectTransform);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReleaseTipBox ()
|
||||
{
|
||||
this._timeHandler?.Kill ();
|
||||
this.gameObject.SetActive (false);
|
||||
}
|
||||
|
||||
private void Update ()
|
||||
{
|
||||
if (this.gameObject.activeSelf)
|
||||
{
|
||||
//如果点击了屏幕,通过射线检测,关闭提示框
|
||||
if (HasClickScreenClose && Input.GetMouseButtonDown (0))
|
||||
{
|
||||
PointerEventData SaveMousePosition = new PointerEventData (EventSystem.current);
|
||||
SaveMousePosition.position = Input.mousePosition;
|
||||
List<RaycastResult> result = new List<RaycastResult> ();
|
||||
EventSystem.current.RaycastAll (SaveMousePosition, result);
|
||||
if (result.Count > 0)
|
||||
{
|
||||
foreach (var raycastResult in result)
|
||||
{
|
||||
if (raycastResult.gameObject == this.gameObject)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ReleaseTipBox ();
|
||||
}
|
||||
else
|
||||
{
|
||||
ReleaseTipBox ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b36c47c754f540058b7cdc3690506bff
|
||||
timeCreated: 1722851424
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Framework.Utils;
|
||||
using Framework.Utils.UITools;
|
||||
using UnityEngine;
|
||||
using CameraType = Framework.Utils.CameraType;
|
||||
|
||||
namespace Views.Common
|
||||
{
|
||||
public class CommonTipBoxFrame : MonoBehaviour
|
||||
{
|
||||
public ACommonTipBoxMessage TipBox;
|
||||
public CameraType cameraType = CameraType.Base;
|
||||
public bool rayClose;
|
||||
|
||||
private RectTransform _rectTransform;
|
||||
private AdjustBox _adjustBox;
|
||||
|
||||
public void InitBox ()
|
||||
{
|
||||
var boxTransform = this.TipBox.transform as RectTransform;
|
||||
this._rectTransform = this.transform as RectTransform;
|
||||
this._adjustBox = new AdjustBox (CameraGroup.Instance.GetCamera (this.cameraType), this._rectTransform, boxTransform,
|
||||
new Vector2Int (0, 0));
|
||||
this.TipBox.Init ();
|
||||
}
|
||||
|
||||
public async void ShowTipBox (RectTransform targetRect, object message)
|
||||
{
|
||||
this.gameObject.SetActive (true);
|
||||
this.TipBox.ShowTipBpx (message);
|
||||
await UniTask.DelayFrame (1);
|
||||
this._adjustBox.AutoController (targetRect , this.TipBox.ExtraDistance , null , true);
|
||||
}
|
||||
|
||||
private void OnMouseDown ()
|
||||
{
|
||||
if (this.rayClose)
|
||||
{
|
||||
this.TipBox.CloseBox ();
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseTipBox ()
|
||||
{
|
||||
this.TipBox.CloseBox ();
|
||||
}
|
||||
|
||||
public void ReleaseTipBox ()
|
||||
{
|
||||
this.TipBox.ReleaseTipBox ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41818aa9c7f64beebd65ce32d2e3fb22
|
||||
timeCreated: 1722828231
|
||||
15
Assets/Scripts/Views/Common/MessageTipBox/WeaponTipBanner.cs
Normal file
15
Assets/Scripts/Views/Common/MessageTipBox/WeaponTipBanner.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Views.Common
|
||||
{
|
||||
public class WeaponTipBanner : MonoBehaviour
|
||||
{
|
||||
public TMP_Text _content;
|
||||
|
||||
public void ShowTipBanner (string content)
|
||||
{
|
||||
this._content.text = content;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42fa24af5aea493e9ed2e488fe6b329c
|
||||
timeCreated: 1722936858
|
||||
Reference in New Issue
Block a user