コーン飛び出し演出実装
This commit is contained in:
parent
fae77f841d
commit
a9f1d3e530
|
@ -2720,7 +2720,7 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 1448897407}
|
||||
m_Layer: 0
|
||||
m_Name: ' cooking'
|
||||
m_Name: cooking
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
|
|
@ -35,6 +35,8 @@ public class Corn : MonoBehaviour
|
|||
private float cornGrowSpeed;
|
||||
private float cornSpillSpeed;
|
||||
private float cornPopSpeed;
|
||||
|
||||
private float worldWidth;
|
||||
|
||||
public IReadOnlyReactiveProperty<CornCondition> Condition => condition;
|
||||
private readonly ReactiveProperty<CornCondition> condition = new ReactiveProperty<CornCondition>(CornCondition.Seed);
|
||||
|
@ -52,6 +54,9 @@ public class Corn : MonoBehaviour
|
|||
|
||||
spriteTransform = spriteRenderer.transform;
|
||||
rotationResolverTransform = spriteTransform.parent.parent;
|
||||
|
||||
var rightTop = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));
|
||||
worldWidth = rightTop.x;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
@ -67,9 +72,9 @@ public class Corn : MonoBehaviour
|
|||
condition.Value = CornCondition.Spilled;
|
||||
}).AddTo(this);
|
||||
|
||||
condition.Subscribe(x =>
|
||||
condition.Pairwise().Subscribe(x =>
|
||||
{
|
||||
switch (x)
|
||||
switch (x.Current)
|
||||
{
|
||||
case CornCondition.Seed:
|
||||
break;
|
||||
|
@ -80,7 +85,7 @@ public class Corn : MonoBehaviour
|
|||
CornBurnt();
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
CornSpilled();
|
||||
CornSpilled(x.Previous);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(x), x, null);
|
||||
|
@ -129,9 +134,36 @@ public class Corn : MonoBehaviour
|
|||
Instantiate(effectBurnt, transform);
|
||||
}
|
||||
|
||||
private void CornSpilled()
|
||||
private void CornSpilled(CornCondition prevCondition)
|
||||
{
|
||||
GetComponent<Collider2D>().enabled = false;
|
||||
// フライパンに追従しないようにparent解除
|
||||
transform.parent = null;
|
||||
|
||||
Observable.Timer(TimeSpan.FromSeconds(Random.Range(.5f, .9f))).Subscribe(_ =>
|
||||
{
|
||||
Destroy(gameObject);
|
||||
switch (prevCondition)
|
||||
{
|
||||
case CornCondition.Seed:
|
||||
VibrationManager.Instance.PlayVibrationOnce();
|
||||
break;
|
||||
case CornCondition.Simple:
|
||||
case CornCondition.Burnt:
|
||||
// 画面KO再生(同時飛び出し時ランダム)
|
||||
var animation = Instantiate(spilledCornAnimationPrefab, new Vector2(Random.value * worldWidth * 2 - worldWidth, Random.value * 2 * 2 - 2), Quaternion.identity);
|
||||
VibrationManager.Instance.PlayVibrationOnce();
|
||||
Observable.Timer(TimeSpan.FromSeconds(1.5f)).Subscribe(__ =>
|
||||
{
|
||||
Destroy(animation);
|
||||
});
|
||||
break;
|
||||
case CornCondition.Spilled:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(prevCondition), prevCondition, null);
|
||||
}
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
public void SetCornProperty(float popTime, float burntDuration, float spillSpeed, float popSpeed)
|
||||
|
|
Loading…
Reference in New Issue