You've already forked taptap2024_GJ_chidouren
增加boss 互动
This commit is contained in:
69
Assets/Scripts/Views/BossTouchPanel.cs
Normal file
69
Assets/Scripts/Views/BossTouchPanel.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Framework.Timer;
|
||||
using Game;
|
||||
using Game.Component;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using IcecreamView;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace Views
|
||||
{
|
||||
public class BossTouchPanel : IcecreamView.IC_AbstractModule
|
||||
{
|
||||
[SerializeField] private Button _clickBtn;
|
||||
[SerializeField] private GameObject _text;
|
||||
private AnimatorStateUpdate _animatorStateUpdate;
|
||||
|
||||
private float _time = 0;
|
||||
|
||||
public override void OnOpenView (IC_ViewData parameters)
|
||||
{
|
||||
this._clickBtn.gameObject.SetActive (false);
|
||||
this._animatorStateUpdate = RoomManager.Instance._BossSceneDirector.transform.GetComponentInChildren<AnimatorStateUpdate> ();
|
||||
this._clickBtn.onClick.AddListener (OnClickTouch);
|
||||
GameUpdateMgr.Instance.AddUpdater (DoUpdate);
|
||||
}
|
||||
|
||||
private void OnClickTouch ()
|
||||
{
|
||||
this._time += 0.1f;
|
||||
GameManager.Instance.Vibrator (VibratorScale.Small);
|
||||
CameraImpulseUtils.Instance.UniformImpulseCamera (0.5f , math.clamp (this._time , 0 , 2));
|
||||
}
|
||||
|
||||
private void DoUpdate ()
|
||||
{
|
||||
if (_animatorStateUpdate.state == 2)
|
||||
{
|
||||
if (!this._clickBtn.gameObject.activeSelf)
|
||||
{
|
||||
this._clickBtn.gameObject.SetActive (true);
|
||||
}
|
||||
this._time -= Time.deltaTime;
|
||||
if (this._time <= 0 && !this._text.activeSelf)
|
||||
{
|
||||
this._text.SetActive (true);
|
||||
}
|
||||
}
|
||||
else if(_animatorStateUpdate.state == 3)
|
||||
{
|
||||
this.ViewConnector.CloseView ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._clickBtn.gameObject.activeSelf)
|
||||
{
|
||||
this._clickBtn.gameObject.SetActive (false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void OnCloseView ()
|
||||
{
|
||||
GameUpdateMgr.Instance.RemoveUpdater (DoUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user