使用済みステージ破棄修正

This commit is contained in:
kimura 2022-07-25 12:07:54 +09:00
parent ef730d9e2b
commit 77b443f8e8
1 changed files with 15 additions and 5 deletions

View File

@ -29,6 +29,15 @@ namespace MyGame.Scenes.MiniGame.Scripts
fenceSubject.AddTo(this);
difficulty.AddTo(this);
}
/*
*
* CurrentDifficulteyが切り替わると生成コース変更
* 3調
* Difficultyでゲームスピード切り替え
* deltaTimeを倍にする
* deltaTime以外の影響はプレイヤーのAnimatorのSpeed()
*/
public void SetBeginStages(Transform[] newStages)
{
@ -54,7 +63,6 @@ namespace MyGame.Scenes.MiniGame.Scripts
var xPos = x.transform.position.x;
minPos = Mathf.Min(minPos, xPos);
maxPos = Mathf.Max(maxPos, xPos);
// 落とし穴があった場合通知
if (x.ItemType != StageItem.Type.Hole)
{
return;
@ -67,13 +75,15 @@ namespace MyGame.Scenes.MiniGame.Scripts
stage.SetPositionX(stageEndXPos - minDiff);
// endPos更新
stageEndXPos = stage.position.x + maxDiff + partsToPartsOffset;
var cacheStageEndPos = stageEndXPos;
// ステージの破棄
Observable.Interval(TimeSpan.FromSeconds(.5f))
.Where(_ => stageEndXPos < cacheTargetXPos)
.Subscribe(_ =>
.First(_ => cacheStageEndPos < cacheTargetXPos)
.Subscribe(_ => { }, () =>
{
Destroy(stage.gameObject);
}).AddTo(this);
}).AddTo(stage.gameObject);
// 落とし穴があった場合通知
if (holePos > float.MinValue)
{
Observable.NextFrame().Subscribe(_ => fenceSubject.OnNext(stage.position.x + holePos - xPos)).AddTo(this);
@ -84,7 +94,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
public void UpdatePos(float targetXPos)
{
cacheTargetXPos = targetXPos;
if (stageEndXPos - targetXPos <= stageGenerateDistance)
if (stageEndXPos - partsToPartsOffset - targetXPos <= stageGenerateDistance)
{
GenerateStage();
}