Merge branch 'feature/addMiniGame' of bitbucket.org:usaya/popcorn into feature/addMiniGame
This commit is contained in:
commit
014191ce70
|
|
@ -590,6 +590,8 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
text: {fileID: 1458058295484164564}
|
||||
timeText: {fileID: 7932948163013127618}
|
||||
countDownAnimator: {fileID: 8834137657701799390}
|
||||
countDownText: {fileID: 6898933620753137981}
|
||||
--- !u!1 &7328251775195385351
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
.Subscribe(time =>
|
||||
{
|
||||
SoundManager.Instance.PlaySE("se_minigame_RemainingTimeLeft");
|
||||
headerView.StartCountDown();
|
||||
}).AddTo(gameCompositeDisposable);
|
||||
break;
|
||||
case GameState.Success:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -9,6 +10,14 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
{
|
||||
[SerializeField] private Text text;
|
||||
[SerializeField] private Text timeText;
|
||||
[SerializeField] private Animator countDownAnimator;
|
||||
[SerializeField] private TextMeshProUGUI countDownText;
|
||||
private int count = 5;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
countDownAnimator.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void ChangeItemCount(int value) => text.text = value.ToString();
|
||||
|
||||
|
|
@ -16,5 +25,24 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
{
|
||||
timeText.text = $"{newTime:0}";
|
||||
}
|
||||
|
||||
public void StartCountDown()
|
||||
{
|
||||
Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f))
|
||||
.Select(x => count - x)
|
||||
.Take(count)
|
||||
.Subscribe(x =>
|
||||
{
|
||||
countDownAnimator.gameObject.SetActive(true);
|
||||
countDownText.text = x.ToString();
|
||||
countDownAnimator.Play("CountDown", 0, 0f);
|
||||
}, () =>
|
||||
{
|
||||
Observable.Timer(TimeSpan.FromSeconds(1f)).Subscribe(_ =>
|
||||
{
|
||||
countDownAnimator.gameObject.SetActive(false);
|
||||
}).AddTo(this);
|
||||
}).AddTo(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue