飛び出し調整
This commit is contained in:
parent
3ec262fb01
commit
ba55d30275
|
|
@ -55,18 +55,25 @@ public class Corn : MonoBehaviour
|
|||
|
||||
private void Start()
|
||||
{
|
||||
rigidbody.MovePosition(new Vector2(Random.value * 2 - 1, Random.value * 2 - 1));
|
||||
rigidbody.SetRotation(Random.value * 360);
|
||||
rigidbody.MovePosition(Random.insideUnitCircle);
|
||||
rigidbody.SetRotation(Random.rotation);
|
||||
cornSkin.ChangeSkin(condition.Value);
|
||||
|
||||
// コーン飛び出し演出
|
||||
this.ObserveEveryValueChanged(x => x.rigidbody.velocity.magnitude)
|
||||
.Where(x => x >= cornSpillSpeed)
|
||||
.ThrottleFirstFrame(30) // 30フレーム間隔開ける
|
||||
.Select(_ => Random.value < .2f) // 演出を出す確率
|
||||
.FirstOrDefault()
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
spilled.Value = true;
|
||||
CornSpilled();
|
||||
var clone = Instantiate(cornSkin);
|
||||
clone.ChangeSkin(condition.Value);
|
||||
var cloneRigidBody = clone.gameObject.AddComponent<Rigidbody2D>();
|
||||
cloneRigidBody.gravityScale = 0;
|
||||
cloneRigidBody.AddForce(rigidbody.velocity.normalized * 20f, ForceMode2D.Impulse);
|
||||
this.CallWaitForSeconds(2f, () => Destroy(clone.gameObject));
|
||||
}).AddTo(this);
|
||||
|
||||
condition.Pairwise().Subscribe(x =>
|
||||
|
|
@ -111,7 +118,7 @@ public class Corn : MonoBehaviour
|
|||
private void CornPop()
|
||||
{
|
||||
cornSkin.ChangeSkin(condition.Value);
|
||||
rigidbody.AddForce(cornPopSpeed * new Vector2(Random.value * 2 - 1, Random.value * 2 - 1), ForceMode2D.Impulse);
|
||||
rigidbody.AddForce(cornPopSpeed * Random.insideUnitCircle, ForceMode2D.Impulse);
|
||||
animator.SetTrigger(HashCornGrow);
|
||||
VibrationManager.Instance.PlayVibrationOnce();
|
||||
}
|
||||
|
|
@ -124,16 +131,6 @@ public class Corn : MonoBehaviour
|
|||
this.CallWaitForSeconds(.8f, () => Destroy(effect));
|
||||
}
|
||||
|
||||
private void CornSpilled()
|
||||
{
|
||||
var clone = Instantiate(cornSkin);
|
||||
clone.ChangeSkin(condition.Value);
|
||||
var cloneRigidBody = clone.gameObject.AddComponent<Rigidbody2D>();
|
||||
cloneRigidBody.gravityScale = 0;
|
||||
cloneRigidBody.AddForce(rigidbody.velocity.normalized * cornSpillSpeed, ForceMode2D.Impulse);
|
||||
this.CallWaitForSeconds(2f, () => Destroy(clone.gameObject));
|
||||
}
|
||||
|
||||
public void SetCornProperty(float popTime, float burntDuration, float spillSpeed, float popSpeed)
|
||||
{
|
||||
cornPopTime = popTime;
|
||||
|
|
|
|||
Loading…
Reference in New Issue