This commit is contained in:
kimura 2022-07-21 17:42:50 +09:00
parent 02fa1b8161
commit e7960e1c1e
2 changed files with 40 additions and 25 deletions

View File

@ -292,8 +292,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
SoundManager.Instance.ChangeVolumeUniqueBGM(1f);
stageManager.ResetStage();
player.transform.position = characterBeginPos;
player.Stay();
player.ResetCount();
player.ResetPlayer();
scoreCount.Value = 0;
headerView.ChangeTimeCount(timeLimit);
resultManager.Reset();

View File

@ -31,25 +31,51 @@ namespace MyGame.Scenes.MiniGame.Scripts
private bool isFlying;
private bool isResult;
private bool isHit;
private bool isHole;
private bool isWall;
private float currentFallSpeed;
public bool IsHit => isHit;
private readonly BoolReactiveProperty isHitStay = new BoolReactiveProperty();
private IDisposable hitDisposable;
private readonly CompositeDisposable hitCompositeDisposable = new CompositeDisposable();
private IDisposable jumpHoldDisposable;
private Coroutine jumpCoroutine;
private Coroutine jumpFallCoroutine;
private Vector3 basePos;
private int count;
private readonly ReactiveProperty<int> count = new ReactiveProperty<int>();
public IObservable<Collider2D> OnHitItem => itemHitCollider.OnTriggerEnter2DAsObservable().TakeUntilDestroy(this);
public IObservable<Collider2D> OnHitObstacle => obstacleHitCollider.OnTriggerEnter2DAsObservable().TakeUntilDestroy(this);
private void Start()
{
isHitStay.AddTo(this);
count.AddTo(this);
hitCompositeDisposable.AddTo(this);
animator = GetComponent<Animator>();
basePos = transform.localPosition;
count.Subscribe(x =>
{
level1.SetActive(x >= level1Value);
level2.SetActive(x >= level2Value);
level3.SetActive(x >= level3Value);
}).AddTo(this);
}
public void Stay(bool force = false)
public void ResetPlayer()
{
Stay();
ResetCount();
isJump = false;
isFall = false;
isFlying = false;
isHit = false;
isHitStay.Value = false;
isHole = false;
isWall = false;
isResult = false;
}
private void Stay(bool force = false)
{
if (!force && isHit)
{
@ -79,7 +105,6 @@ namespace MyGame.Scenes.MiniGame.Scripts
return;
}
SoundManager.Instance.PlaySE("se_minigame_Jump");
animator?.Play("Brother_pink_jump", 0, 0);
isJump = true;
isFall = false;
@ -166,7 +191,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
Instantiate(hitEffectPrefab, hitPos, Quaternion.identity, transform.parent);
animator?.Play("Brother_pink_FallDown");
isHit = true;
hitDisposable?.Dispose();
hitCompositeDisposable?.Clear();
// ヒット以外動作停止
this.SafeStopCoroutine(jumpCoroutine);
@ -198,10 +223,10 @@ namespace MyGame.Scenes.MiniGame.Scripts
isJump = false;
isFall = false;
isFlying = false;
this.CallWaitForSeconds(hitTime, () =>
Observable.Timer(TimeSpan.FromSeconds(hitTime)).Subscribe(_ => { }, () =>
{
isHitStay.Value = true;
this.CallWaitForSeconds(hitWaitTime, () =>
Observable.Timer(TimeSpan.FromSeconds(hitWaitTime)).Subscribe(_ => { }, () =>
{
isHit = false;
isHitStay.Value = false;
@ -213,9 +238,9 @@ namespace MyGame.Scenes.MiniGame.Scripts
{
Stay();
}
});
});
}).AddTo(this);
}).AddTo(hitCompositeDisposable);
}).AddTo(hitCompositeDisposable);
}).AddTo(hitCompositeDisposable);
});
}
@ -233,21 +258,12 @@ namespace MyGame.Scenes.MiniGame.Scripts
public void AddCount()
{
SoundManager.Instance.PlaySE("se_minigame_ItemGet");
count++;
UpdateCount();
count.Value++;
}
private void UpdateCount()
private void ResetCount()
{
level1.SetActive(count >= level1Value);
level2.SetActive(count >= level2Value);
level3.SetActive(count >= level3Value);
}
public void ResetCount()
{
count = 0;
UpdateCount();
count.Value = 0;
}
}
}