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