add BGMスピード変化
This commit is contained in:
parent
8187fbf145
commit
64a109da48
|
|
@ -138,6 +138,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
resultManager.OnClose.ThrottleFirst(TimeSpan.FromMilliseconds(.2f)).Subscribe(_ =>
|
||||
{
|
||||
SoundManager.Instance.ChangeVolumeUniqueBGM(1f);
|
||||
SoundManager.Instance.ChangePitchBGM(1f);
|
||||
UpdatePlayCount();
|
||||
scoreUpdate.OnNext(Unit.Default);
|
||||
menuState.Value = MenuState.StageSelect;
|
||||
|
|
@ -165,7 +166,6 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
break;
|
||||
case GameState.Success:
|
||||
SoundManager.Instance.PlaySE("se_minigame_End");
|
||||
stageManager.StopTimer();
|
||||
player.Result();
|
||||
break;
|
||||
case GameState.Failure:
|
||||
|
|
@ -220,6 +220,13 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
state.Value = GameState.Success;
|
||||
}).AddTo(this);
|
||||
|
||||
player.CurrentSpeedMultiply.SkipLatestValueOnSubscribe()
|
||||
.Where(_ => state.Value == GameState.Play)
|
||||
.Subscribe(x =>
|
||||
{
|
||||
SoundManager.Instance.ChangePitchBGM(x);
|
||||
}).AddTo(this);
|
||||
|
||||
player.OnHitItem.Where(_ => state.Value == GameState.Play).Subscribe(x =>
|
||||
{
|
||||
if (!x.TryGetComponent<StageItem>(out var item))
|
||||
|
|
@ -267,6 +274,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
switch (item.ItemType)
|
||||
{
|
||||
case StageItem.Type.Obstacle:
|
||||
stageManager.StopTimer();
|
||||
player.Hit(closestPoint);
|
||||
break;
|
||||
case StageItem.Type.Item1:
|
||||
|
|
@ -299,6 +307,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
.Subscribe(x =>
|
||||
{
|
||||
resultManager.ShowResult(scoreCount.Value, placeList, stageData);
|
||||
SoundManager.Instance.ChangePitchBGM(1f);
|
||||
}).AddTo(gameCompositeDisposable);
|
||||
|
||||
resultManager.OnRetry.ThrottleFirst(TimeSpan.FromSeconds(.2f)).Subscribe(_ =>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
private bool isResult;
|
||||
private bool isHitStop;
|
||||
private float currentFallSpeed;
|
||||
private float currentSpeedMultiply;
|
||||
private readonly ReactiveProperty<float> currentSpeedMultiply = new();
|
||||
public IReadOnlyReactiveProperty<float> CurrentSpeedMultiply => currentSpeedMultiply;
|
||||
public bool IsHit => isHit;
|
||||
private readonly CompositeDisposable jumpCompositeDisposable = new CompositeDisposable();
|
||||
private readonly CompositeDisposable hitCompositeDisposable = new CompositeDisposable();
|
||||
|
|
@ -55,6 +56,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
private void Start()
|
||||
{
|
||||
count.AddTo(this);
|
||||
currentSpeedMultiply.AddTo(this);
|
||||
jumpCompositeDisposable.AddTo(this);
|
||||
hitCompositeDisposable.AddTo(this);
|
||||
endHitSubject.AddTo(this);
|
||||
|
|
@ -81,7 +83,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
isWall = false;
|
||||
isResult = false;
|
||||
isHitStop = false;
|
||||
currentSpeedMultiply = 1f;
|
||||
currentSpeedMultiply.Value = 1f;
|
||||
}
|
||||
|
||||
private void Stay(bool force = false)
|
||||
|
|
@ -95,11 +97,11 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
|
||||
public void Move()
|
||||
{
|
||||
if (isHitStay || isWall || isHitStop)
|
||||
if (isHitStay || isWall)
|
||||
{
|
||||
return;
|
||||
}
|
||||
transform.AddPositionX(speed * Time.deltaTime * currentSpeedMultiply);
|
||||
transform.AddPositionX(speed * Time.deltaTime * currentSpeedMultiply.Value);
|
||||
if (isJump || isHit || isFall)
|
||||
{
|
||||
return;
|
||||
|
|
@ -120,7 +122,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
isFall = false;
|
||||
var lastFrame = jumpAnimationCurve[jumpAnimationCurve.length - 1];
|
||||
// 最高点までのジャンプ
|
||||
var jumpTime = lastFrame.time / currentSpeedMultiply;
|
||||
var jumpTime = lastFrame.time / currentSpeedMultiply.Value;
|
||||
var jumpCoroutine = MonoBehaviourExtensions.DoCallLerp(jumpTime, t =>
|
||||
{
|
||||
transform.SetLocalPositionY(basePos.y + jumpAnimationCurve.Evaluate(t * lastFrame.time));
|
||||
|
|
@ -172,10 +174,10 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
else
|
||||
{
|
||||
animator.Play("Brother_pink_Glideing_Cancel");
|
||||
currentFallSpeed -= fallAcceleration * Time.deltaTime * currentSpeedMultiply;
|
||||
currentFallSpeed -= fallAcceleration * Time.deltaTime * currentSpeedMultiply.Value;
|
||||
}
|
||||
|
||||
var newYPos = transform.localPosition.y + currentFallSpeed * Time.deltaTime * currentSpeedMultiply;
|
||||
var newYPos = transform.localPosition.y + currentFallSpeed * Time.deltaTime * currentSpeedMultiply.Value;
|
||||
transform.SetLocalPositionY(Mathf.Max(basePos.y, newYPos));
|
||||
}, () =>
|
||||
{
|
||||
|
|
@ -214,6 +216,8 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
|
||||
isHit = true;
|
||||
isHitStop = true;
|
||||
var cacheSpeedMultiply = currentSpeedMultiply.Value;
|
||||
currentSpeedMultiply.Value = 0f;
|
||||
Instantiate(hitEffectPrefab, hitPos, Quaternion.identity, transform.parent);
|
||||
SoundManager.Instance.PlaySE("se_minigame_Collide");
|
||||
animator?.Play("Brother_pink_FallDown", 0, 0f);
|
||||
|
|
@ -223,7 +227,8 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
hitStopTimer.Subscribe(_ =>
|
||||
{
|
||||
isHitStop = false;
|
||||
animator.speed = currentSpeedMultiply;
|
||||
currentSpeedMultiply.Value = cacheSpeedMultiply;
|
||||
animator.speed = currentSpeedMultiply.Value;
|
||||
}).AddTo(hitCompositeDisposable);
|
||||
|
||||
// HitStop後、Hit跳ね返りアニメーション
|
||||
|
|
@ -236,7 +241,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
return;
|
||||
}
|
||||
|
||||
var hitJumpCoroutine = MonoBehaviourExtensions.DoCallLerp(diffHeight <= 0f ? 0f : hitJumpTime / currentSpeedMultiply, t =>
|
||||
var hitJumpCoroutine = MonoBehaviourExtensions.DoCallLerp(diffHeight <= 0f ? 0f : hitJumpTime / cacheSpeedMultiply, t =>
|
||||
{
|
||||
transform.SetLocalPositionY(cachePosY + hitAnimationCurve.Evaluate(t));
|
||||
});
|
||||
|
|
@ -256,11 +261,11 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
// 31フレームまでが落下32からズサー
|
||||
SoundManager.Instance.PlaySE("se_minigame_FallDown");
|
||||
animator?.PlayInFixedTime("Brother_pink_FallDown", 0, .52f);
|
||||
animator.speed = currentSpeedMultiply;
|
||||
animator.speed = currentSpeedMultiply.Value;
|
||||
currentFallSpeed = 0f;
|
||||
isJump = false;
|
||||
isFall = false;
|
||||
Observable.Timer(TimeSpan.FromSeconds(hitTime / currentSpeedMultiply)).Subscribe(_ => { }, () =>
|
||||
Observable.Timer(TimeSpan.FromSeconds(hitTime / currentSpeedMultiply.Value)).Subscribe(_ => { }, () =>
|
||||
{
|
||||
isHitStay = true;
|
||||
Observable.Timer(TimeSpan.FromSeconds(hitWaitTime)).Subscribe(_ => { }, () =>
|
||||
|
|
@ -308,8 +313,8 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
.TakeWhile(_ => transform.localPosition.y > baseYPos)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
currentFallSpeed -= fallAcceleration * Time.deltaTime * currentSpeedMultiply;
|
||||
var newYPos = transform.localPosition.y + currentFallSpeed * Time.deltaTime * currentSpeedMultiply;
|
||||
currentFallSpeed -= fallAcceleration * Time.deltaTime * currentSpeedMultiply.Value;
|
||||
var newYPos = transform.localPosition.y + currentFallSpeed * Time.deltaTime * currentSpeedMultiply.Value;
|
||||
transform.SetLocalPositionY(Mathf.Max(baseYPos, newYPos));
|
||||
}, onComplete);
|
||||
}
|
||||
|
|
@ -321,7 +326,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
|||
|
||||
public void SetSpeed(ScrollGameDifficulty difficulty)
|
||||
{
|
||||
currentSpeedMultiply = difficulty switch
|
||||
currentSpeedMultiply.Value = difficulty switch
|
||||
{
|
||||
ScrollGameDifficulty.Easy => 1f,
|
||||
ScrollGameDifficulty.Normal => normalSpeedMultiply,
|
||||
|
|
|
|||
|
|
@ -283,6 +283,12 @@ public class SoundManager : SingletonMonoBehaviour<SoundManager> {
|
|||
bgmSource.Stop();
|
||||
bgmSource.clip = null;
|
||||
}
|
||||
|
||||
public void ChangePitchBGM(float pitch)
|
||||
{
|
||||
if (!bgmSource) return;
|
||||
bgmSource.pitch = pitch;
|
||||
}
|
||||
public void StopSE(string filePath){
|
||||
var index = seSourceList.FindIndex(playing => playing.Name == filePath);
|
||||
if (index == -1) return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue