Rx対応
This commit is contained in:
parent
02fa1b8161
commit
e7960e1c1e
|
|
@ -292,8 +292,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
SoundManager.Instance.ChangeVolumeUniqueBGM(1f);
|
SoundManager.Instance.ChangeVolumeUniqueBGM(1f);
|
||||||
stageManager.ResetStage();
|
stageManager.ResetStage();
|
||||||
player.transform.position = characterBeginPos;
|
player.transform.position = characterBeginPos;
|
||||||
player.Stay();
|
player.ResetPlayer();
|
||||||
player.ResetCount();
|
|
||||||
scoreCount.Value = 0;
|
scoreCount.Value = 0;
|
||||||
headerView.ChangeTimeCount(timeLimit);
|
headerView.ChangeTimeCount(timeLimit);
|
||||||
resultManager.Reset();
|
resultManager.Reset();
|
||||||
|
|
|
||||||
|
|
@ -31,25 +31,51 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
private bool isFlying;
|
private bool isFlying;
|
||||||
private bool isResult;
|
private bool isResult;
|
||||||
private bool isHit;
|
private bool isHit;
|
||||||
|
private bool isHole;
|
||||||
|
private bool isWall;
|
||||||
|
private float currentFallSpeed;
|
||||||
public bool IsHit => isHit;
|
public bool IsHit => isHit;
|
||||||
private readonly BoolReactiveProperty isHitStay = new BoolReactiveProperty();
|
private readonly BoolReactiveProperty isHitStay = new BoolReactiveProperty();
|
||||||
private IDisposable hitDisposable;
|
private readonly CompositeDisposable hitCompositeDisposable = new CompositeDisposable();
|
||||||
private IDisposable jumpHoldDisposable;
|
private IDisposable jumpHoldDisposable;
|
||||||
private Coroutine jumpCoroutine;
|
private Coroutine jumpCoroutine;
|
||||||
private Coroutine jumpFallCoroutine;
|
private Coroutine jumpFallCoroutine;
|
||||||
private Vector3 basePos;
|
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> OnHitItem => itemHitCollider.OnTriggerEnter2DAsObservable().TakeUntilDestroy(this);
|
||||||
public IObservable<Collider2D> OnHitObstacle => obstacleHitCollider.OnTriggerEnter2DAsObservable().TakeUntilDestroy(this);
|
public IObservable<Collider2D> OnHitObstacle => obstacleHitCollider.OnTriggerEnter2DAsObservable().TakeUntilDestroy(this);
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
isHitStay.AddTo(this);
|
isHitStay.AddTo(this);
|
||||||
|
count.AddTo(this);
|
||||||
|
hitCompositeDisposable.AddTo(this);
|
||||||
animator = GetComponent<Animator>();
|
animator = GetComponent<Animator>();
|
||||||
basePos = transform.localPosition;
|
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)
|
if (!force && isHit)
|
||||||
{
|
{
|
||||||
|
|
@ -79,7 +105,6 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundManager.Instance.PlaySE("se_minigame_Jump");
|
|
||||||
animator?.Play("Brother_pink_jump", 0, 0);
|
animator?.Play("Brother_pink_jump", 0, 0);
|
||||||
isJump = true;
|
isJump = true;
|
||||||
isFall = false;
|
isFall = false;
|
||||||
|
|
@ -166,7 +191,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
Instantiate(hitEffectPrefab, hitPos, Quaternion.identity, transform.parent);
|
Instantiate(hitEffectPrefab, hitPos, Quaternion.identity, transform.parent);
|
||||||
animator?.Play("Brother_pink_FallDown");
|
animator?.Play("Brother_pink_FallDown");
|
||||||
isHit = true;
|
isHit = true;
|
||||||
hitDisposable?.Dispose();
|
hitCompositeDisposable?.Clear();
|
||||||
|
|
||||||
// ヒット以外動作停止
|
// ヒット以外動作停止
|
||||||
this.SafeStopCoroutine(jumpCoroutine);
|
this.SafeStopCoroutine(jumpCoroutine);
|
||||||
|
|
@ -198,10 +223,10 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
isJump = false;
|
isJump = false;
|
||||||
isFall = false;
|
isFall = false;
|
||||||
isFlying = false;
|
isFlying = false;
|
||||||
this.CallWaitForSeconds(hitTime, () =>
|
Observable.Timer(TimeSpan.FromSeconds(hitTime)).Subscribe(_ => { }, () =>
|
||||||
{
|
{
|
||||||
isHitStay.Value = true;
|
isHitStay.Value = true;
|
||||||
this.CallWaitForSeconds(hitWaitTime, () =>
|
Observable.Timer(TimeSpan.FromSeconds(hitWaitTime)).Subscribe(_ => { }, () =>
|
||||||
{
|
{
|
||||||
isHit = false;
|
isHit = false;
|
||||||
isHitStay.Value = false;
|
isHitStay.Value = false;
|
||||||
|
|
@ -213,9 +238,9 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
{
|
{
|
||||||
Stay();
|
Stay();
|
||||||
}
|
}
|
||||||
});
|
}).AddTo(hitCompositeDisposable);
|
||||||
});
|
}).AddTo(hitCompositeDisposable);
|
||||||
}).AddTo(this);
|
}).AddTo(hitCompositeDisposable);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,21 +258,12 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
public void AddCount()
|
public void AddCount()
|
||||||
{
|
{
|
||||||
SoundManager.Instance.PlaySE("se_minigame_ItemGet");
|
SoundManager.Instance.PlaySE("se_minigame_ItemGet");
|
||||||
count++;
|
count.Value++;
|
||||||
UpdateCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateCount()
|
private void ResetCount()
|
||||||
{
|
{
|
||||||
level1.SetActive(count >= level1Value);
|
count.Value = 0;
|
||||||
level2.SetActive(count >= level2Value);
|
|
||||||
level3.SetActive(count >= level3Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetCount()
|
|
||||||
{
|
|
||||||
count = 0;
|
|
||||||
UpdateCount();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue