コーン状態から「飛び出し(spilled)」削除
This commit is contained in:
parent
640246f598
commit
3ec262fb01
|
|
@ -11,7 +11,6 @@ public enum CornCondition
|
|||
Seed,
|
||||
Simple,
|
||||
Burnt,
|
||||
Spilled
|
||||
}
|
||||
|
||||
[RequireComponent(typeof(Rigidbody2D))]
|
||||
|
|
@ -35,6 +34,8 @@ public class Corn : MonoBehaviour
|
|||
|
||||
public IReadOnlyReactiveProperty<CornCondition> Condition => condition;
|
||||
private readonly ReactiveProperty<CornCondition> condition = new ReactiveProperty<CornCondition>(CornCondition.Seed);
|
||||
public IReadOnlyReactiveProperty<bool> Spilled => spilled;
|
||||
private readonly ReactiveProperty<bool> spilled = new ReactiveProperty<bool>();
|
||||
|
||||
|
||||
// 角度調整
|
||||
|
|
@ -58,14 +59,15 @@ public class Corn : MonoBehaviour
|
|||
rigidbody.SetRotation(Random.value * 360);
|
||||
cornSkin.ChangeSkin(condition.Value);
|
||||
|
||||
// コーンが飛んでいく
|
||||
// コーン飛び出し演出
|
||||
this.ObserveEveryValueChanged(x => x.rigidbody.velocity.magnitude)
|
||||
.Where(x => x >= cornSpillSpeed)
|
||||
.FirstOrDefault()
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
condition.Value = CornCondition.Spilled;
|
||||
}).AddTo(this);
|
||||
{
|
||||
spilled.Value = true;
|
||||
CornSpilled();
|
||||
}).AddTo(this);
|
||||
|
||||
condition.Pairwise().Subscribe(x =>
|
||||
{
|
||||
|
|
@ -79,9 +81,6 @@ public class Corn : MonoBehaviour
|
|||
case CornCondition.Burnt:
|
||||
CornBurnt();
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
CornSpilled(x.Previous);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(x), x, null);
|
||||
}
|
||||
|
|
@ -98,11 +97,6 @@ public class Corn : MonoBehaviour
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if (condition.Value == CornCondition.Spilled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cornGrowTime += Time.deltaTime * cornGrowSpeed;
|
||||
if (cornGrowTime >= cornBurntTime)
|
||||
{
|
||||
|
|
@ -130,10 +124,10 @@ public class Corn : MonoBehaviour
|
|||
this.CallWaitForSeconds(.8f, () => Destroy(effect));
|
||||
}
|
||||
|
||||
private void CornSpilled(CornCondition prevCondition)
|
||||
private void CornSpilled()
|
||||
{
|
||||
var clone = Instantiate(cornSkin);
|
||||
clone.ChangeSkin(prevCondition);
|
||||
clone.ChangeSkin(condition.Value);
|
||||
var cloneRigidBody = clone.gameObject.AddComponent<Rigidbody2D>();
|
||||
cloneRigidBody.gravityScale = 0;
|
||||
cloneRigidBody.AddForce(rigidbody.velocity.normalized * cornSpillSpeed, ForceMode2D.Impulse);
|
||||
|
|
|
|||
|
|
@ -178,15 +178,18 @@ public class CornManager : MonoBehaviour
|
|||
// ミス数加算
|
||||
missCount.Value++;
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
// 同時に飛び出したとき用に演出をばらつかせる
|
||||
corn.CallWaitForSeconds(Random.Range(0f, .5f), () => cornSpilledSubject.OnNext(condition.Previous));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||
}
|
||||
}).AddTo(compositeDisposable);
|
||||
|
||||
corn.Spilled
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
// 同時に飛び出したとき用に演出をばらつかせる
|
||||
corn.CallWaitForSeconds(Random.Range(0f, .5f), () => cornSpilledSubject.OnNext(corn.Condition.Value));
|
||||
}).AddTo(compositeDisposable);
|
||||
|
||||
cornConditions.Add(corn.Condition);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@ public class CornMissEffect : MonoBehaviour
|
|||
burntSprite.SetActive(true);
|
||||
spilledSprite.SetActive(false);
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
burntSprite.SetActive(false);
|
||||
spilledSprite.SetActive(true);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ public class CornSkin : MonoBehaviour
|
|||
case CornCondition.Burnt:
|
||||
spriteRenderer.sprite = cornBurntSprite;
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ public class CornSpilled : MonoBehaviour
|
|||
spilledCornRenderer.sprite = spilledBurntCornSprite;
|
||||
spilledCornGrainRenderer.sprite = spilledBurntCornGrainSprite;
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue