Merge branch 'feature/addMiniGame' of bitbucket.org:usaya/popcorn into feature/addMiniGame

This commit is contained in:
koya_15 2022-07-01 12:43:31 +09:00
commit ff570feaa9
3 changed files with 32 additions and 29 deletions

View File

@ -256,9 +256,15 @@ namespace MyGame.Scenes.MiniGame.Scripts
} }
#endif #endif
x.enabled = false; x.enabled = false;
if (player.IsHit)
{
return;
}
switch (item.ItemType) switch (item.ItemType)
{ {
case StageItem.Type.Item1: case StageItem.Type.Item1:
item.Effect();
scoreCount.Value += item.Point; scoreCount.Value += item.Point;
player.AddCount(); player.AddCount();
break; break;

View File

@ -18,8 +18,9 @@ namespace MyGame.Scenes.MiniGame.Scripts
[SerializeField] private GameObject level3; [SerializeField] private GameObject level3;
private Animator animator; private Animator animator;
private bool isJump; private bool isJump;
private bool isPreHit; private bool isHit;
private readonly BoolReactiveProperty isHit = new BoolReactiveProperty(); public bool IsHit => isHit;
private readonly BoolReactiveProperty isHitStay = new BoolReactiveProperty();
private IDisposable hitDisposable; private IDisposable hitDisposable;
private Coroutine jumpCoroutine; private Coroutine jumpCoroutine;
private Vector3 basePos; private Vector3 basePos;
@ -27,14 +28,14 @@ namespace MyGame.Scenes.MiniGame.Scripts
private void Start() private void Start()
{ {
isHit.AddTo(this); isHitStay.AddTo(this);
animator = GetComponent<Animator>(); animator = GetComponent<Animator>();
basePos = transform.localPosition; basePos = transform.localPosition;
} }
public void Stay(bool force = false) public void Stay(bool force = false)
{ {
if (!force && isPreHit) if (!force && isHit)
{ {
return; return;
} }
@ -43,12 +44,12 @@ namespace MyGame.Scenes.MiniGame.Scripts
public void Move() public void Move()
{ {
if (isHit.Value) if (isHitStay.Value)
{ {
return; return;
} }
transform.AddPositionX(speed * Time.deltaTime); transform.AddPositionX(speed * Time.deltaTime);
if (isJump || isPreHit) if (isJump || isHit)
{ {
return; return;
} }
@ -57,7 +58,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
public void Jump() public void Jump()
{ {
if (isJump || isPreHit) if (isJump || isHit)
{ {
return; return;
} }
@ -79,13 +80,13 @@ namespace MyGame.Scenes.MiniGame.Scripts
// こける // こける
public void Hit() public void Hit()
{ {
if (isPreHit) if (isHit)
{ {
return; return;
} }
SoundManager.Instance.PlaySE("se_minigame_Collide"); SoundManager.Instance.PlaySE("se_minigame_Collide");
animator?.Play("Brother_pink_FallDown"); animator?.Play("Brother_pink_FallDown");
isPreHit = true; isHit = true;
hitDisposable?.Dispose(); hitDisposable?.Dispose();
this.SafeStopCoroutine(jumpCoroutine); this.SafeStopCoroutine(jumpCoroutine);
@ -101,11 +102,11 @@ namespace MyGame.Scenes.MiniGame.Scripts
{ {
}, () => }, () =>
{ {
isHit.Value = true; isHitStay.Value = true;
this.CallWaitForSeconds(hitWaitTime, () => this.CallWaitForSeconds(hitWaitTime, () =>
{ {
isPreHit = false; isHit = false;
isHit.Value = false; isHitStay.Value = false;
Stay(); Stay();
}); });
}); });

View File

@ -20,10 +20,7 @@ namespace MyGame.Scenes.MiniGame.Scripts
public int Point => point; public int Point => point;
private void Start() public void Effect()
{
this.OnTriggerEnter2DAsObservable()
.Subscribe(_ =>
{ {
// effect // effect
switch (itemType) switch (itemType)
@ -37,7 +34,6 @@ namespace MyGame.Scenes.MiniGame.Scripts
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
}).AddTo(this);
} }
public void ResetItem() public void ResetItem()