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