You've already forked taptap2024_GJ_chidouren
91 lines
3.1 KiB
C#
91 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
using Coffee.UIExtensions;
|
|
using Framework.GamePool;
|
|
using Framework.Timer;
|
|
using Framework.UI;
|
|
using Framework.Utils;
|
|
using Game;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using IcecreamView;
|
|
using MintAnimation.Runtime.Components.MintAnimation;
|
|
using Utils;
|
|
using CameraType = Framework.Utils.CameraType;
|
|
|
|
namespace Views
|
|
{
|
|
public class CommonScreenEffectPanel : IcecreamView.IC_AbstractModule
|
|
{
|
|
[SerializeField] private UIParticle _particlePrefab;
|
|
[SerializeField] private UIParticle _particleGameSuccess;
|
|
[SerializeField] private UIParticle _particleGameField;
|
|
[SerializeField] private MintAnimBase _screenFlickerAnim;
|
|
|
|
private MiniGameObjectPool<UIParticle> _pool;
|
|
private Camera _camera;
|
|
|
|
public override void OnInitView ()
|
|
{
|
|
this._pool = new MiniGameObjectPool<UIParticle> ();
|
|
this._pool.InitPool (this._particlePrefab , this.transform);
|
|
this._camera = CameraGroup.Instance.GetCamera (CameraType.Ui);
|
|
}
|
|
|
|
public override void OnOpenView (IC_ViewData parameters)
|
|
{
|
|
GameUpdateMgr.Instance.AddUpdater (DoUpdate);
|
|
this._particleGameSuccess.Stop ();
|
|
this._particleGameField.Stop ();
|
|
this._screenFlickerAnim.StopAnim ();
|
|
this._screenFlickerAnim.SetPlayTime (1);
|
|
}
|
|
|
|
public override void OnCloseView ()
|
|
{
|
|
GameUpdateMgr.Instance.RemoveUpdater (DoUpdate);
|
|
}
|
|
|
|
private void DoUpdate ()
|
|
{
|
|
if (Input.GetMouseButtonDown (0))
|
|
{
|
|
var position = Input.mousePosition;
|
|
var screenPointToUILocalPoint = UIKit.ScreenPointToUILocalPoint (this._camera , this.transform as RectTransform, position);
|
|
CreateEffect (screenPointToUILocalPoint);
|
|
}
|
|
}
|
|
|
|
private void CreateEffect (Vector2 localPos)
|
|
{
|
|
var particle = this._pool.Create ();
|
|
particle.rectTransform.anchoredPosition = localPos;
|
|
particle.Play ();
|
|
GameUpdateMgr.Instance.CreateTimer (1.5f , () => { this._pool.Destroy (particle); });
|
|
}
|
|
|
|
// [BindUIEvent(GameEventCode.OnScreenFlicker)]
|
|
// private void OnFightCallback (EventArg arg)
|
|
// {
|
|
// // if (arg.Count > 0)
|
|
// // {
|
|
// // if (arg.GetValue<bool> ())
|
|
// // {
|
|
// // this._particleGameSuccess.Play ();
|
|
// // }
|
|
// // }
|
|
// // else
|
|
// // {
|
|
// // this._particleGameSuccess.Play ();
|
|
// // }
|
|
// }
|
|
|
|
[BindUIEvent (GameEventCode.OnScreenFlicker)]
|
|
private void OnScreenFlicker (EventArg arg)
|
|
{
|
|
var count = arg.GetValue<int> ();
|
|
var mintTweenOptions = this._screenFlickerAnim.MintAnimation ().TweenOptions;
|
|
mintTweenOptions.LoopCount = count;
|
|
this._screenFlickerAnim.StartAnim ();
|
|
}
|
|
}
|
|
} |