smart-interactive-display/Assets/GadGame/Scripts/PassByAnimation.cs

53 lines
1.7 KiB
C#
Raw Normal View History

2024-04-25 04:54:33 -07:00
using System.Collections;
using Cysharp.Threading.Tasks;
2024-04-22 02:10:49 -07:00
using DG.Tweening;
using GadGame.Singleton;
using Sirenix.OdinInspector;
2024-04-23 02:44:22 -07:00
using TMPro;
2024-04-22 02:10:49 -07:00
using UnityEngine;
2024-04-23 02:44:22 -07:00
using UnityEngine.UI;
2024-04-25 04:54:33 -07:00
using UnityEngine.Video;
2024-04-22 02:10:49 -07:00
namespace GadGame.State.MainFlowState
{
public class PassByAnimation : Singleton<PassByAnimation>
{
public Animator passBy;
[SerializeField] private RectTransform _transform;
2024-04-25 04:54:33 -07:00
// [SerializeField] private RectTransform _videoIdleTransform;
[SerializeField] private Image CircleImg;
2024-04-23 02:44:22 -07:00
[SerializeField] private TextMeshProUGUI txtProgress;
2024-04-25 04:54:33 -07:00
[SerializeField] private VideoPlayer videoPlayer;
2024-04-22 02:10:49 -07:00
[Button]
public void Play(bool engage) {
2024-04-25 04:54:33 -07:00
// videoPlayer.gameObject.SetActive(!passBy);
_transform.DOAnchorPosX(engage ? -1000 : 0, 1);
2024-04-22 02:10:49 -07:00
}
2024-04-23 02:44:22 -07:00
2024-04-25 04:54:33 -07:00
public async void SetPlayVideo(bool value){
if(value) {
while (videoPlayer.targetCameraAlpha < 1)
{
videoPlayer.targetCameraAlpha += Time.deltaTime * 3;
await UniTask.Yield();
}
videoPlayer.targetCameraAlpha = 1;
} else {
while (videoPlayer.targetCameraAlpha > 0)
{
videoPlayer.targetCameraAlpha -= Time.deltaTime * 3;
await UniTask.Yield();
}
videoPlayer.targetCameraAlpha = 0;
}
}
2024-04-23 02:44:22 -07:00
public void ReadyCountDown(float progress){
CircleImg.fillAmount = progress ;
txtProgress.text = Mathf.Floor(progress * 3).ToString();
}
2024-04-22 02:10:49 -07:00
}
}