使用済みステージ破棄修正
This commit is contained in:
parent
ef730d9e2b
commit
77b443f8e8
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue