CornManagerに飛び出し演出処理を追加
This commit is contained in:
parent
b2dbea36b2
commit
daf2ce6d9d
|
|
@ -9354,6 +9354,8 @@ MonoBehaviour:
|
||||||
cornSpawnTarget: {fileID: 1440136003}
|
cornSpawnTarget: {fileID: 1440136003}
|
||||||
cornPrefab: {fileID: 5499754490129207122, guid: 2b790fd908bd14de4a601c21374fb55b,
|
cornPrefab: {fileID: 5499754490129207122, guid: 2b790fd908bd14de4a601c21374fb55b,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
spilledCornAnimationPrefab: {fileID: 2449901118440757730, guid: 7e7fbf241bd7f461fb46363ff0c6be3e,
|
||||||
|
type: 3}
|
||||||
cornSpawnCount: 100
|
cornSpawnCount: 100
|
||||||
maxFailedCornCount: 60
|
maxFailedCornCount: 60
|
||||||
baseGrowSpeed: 1
|
baseGrowSpeed: 1
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||||
using UniRx;
|
using UniRx;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
public enum CornResult
|
public enum CornResult
|
||||||
{
|
{
|
||||||
|
|
@ -16,6 +17,7 @@ public class CornManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private Transform cornSpawnTarget;
|
[SerializeField] private Transform cornSpawnTarget;
|
||||||
[SerializeField] private Corn cornPrefab;
|
[SerializeField] private Corn cornPrefab;
|
||||||
|
[SerializeField] private GameObject spilledCornAnimationPrefab;
|
||||||
[SerializeField] private int cornSpawnCount = 20;
|
[SerializeField] private int cornSpawnCount = 20;
|
||||||
[SerializeField] private int maxFailedCornCount = 10;
|
[SerializeField] private int maxFailedCornCount = 10;
|
||||||
[SerializeField, ReadOnly] private float baseGrowSpeed = 1f;
|
[SerializeField, ReadOnly] private float baseGrowSpeed = 1f;
|
||||||
|
|
@ -28,10 +30,14 @@ public class CornManager : MonoBehaviour
|
||||||
public IReadOnlyReactiveProperty<CornResult> Result => result;
|
public IReadOnlyReactiveProperty<CornResult> Result => result;
|
||||||
private readonly ReactiveProperty<CornResult> result = new ReactiveProperty<CornResult>();
|
private readonly ReactiveProperty<CornResult> result = new ReactiveProperty<CornResult>();
|
||||||
|
|
||||||
|
private float worldWidth;
|
||||||
|
private float worldHeight;
|
||||||
|
private static readonly float maxSpilledHeight = 4f;
|
||||||
private Corn[] cornArray;
|
private Corn[] cornArray;
|
||||||
private bool isHot;
|
private bool isHot;
|
||||||
private bool isCompleted;
|
private bool isCompleted;
|
||||||
private List<IObservable<CornCondition>> cornConditions = new List<IObservable<CornCondition>>();
|
private readonly List<IObservable<CornCondition>> cornConditions = new List<IObservable<CornCondition>>();
|
||||||
|
private readonly Subject<CornCondition> cornSpilledSubject = new Subject<CornCondition>();
|
||||||
private readonly ReactiveProperty<float> cornGrowSpeed = new FloatReactiveProperty(0f);
|
private readonly ReactiveProperty<float> cornGrowSpeed = new FloatReactiveProperty(0f);
|
||||||
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
|
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
|
@ -47,6 +53,9 @@ public class CornManager : MonoBehaviour
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
var leftTop = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));
|
||||||
|
worldWidth = leftTop.x;
|
||||||
|
worldHeight = leftTop.y;
|
||||||
cornArray = new Corn[cornSpawnCount];
|
cornArray = new Corn[cornSpawnCount];
|
||||||
result.AddTo(this);
|
result.AddTo(this);
|
||||||
cornGrowSpeed.AddTo(this);
|
cornGrowSpeed.AddTo(this);
|
||||||
|
|
@ -55,6 +64,19 @@ public class CornManager : MonoBehaviour
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
// コーン飛び出し制御
|
||||||
|
// 5フレームごとに2回など演出の回数を制御
|
||||||
|
cornSpilledSubject
|
||||||
|
.Where(x => x != CornCondition.Seed) // Seedは演出なし
|
||||||
|
.Where(_ => !isCompleted) // 終了後は飛び出さない
|
||||||
|
.BatchFrame(5, FrameCountType.EndOfFrame) // 指定フレーム分まとめる
|
||||||
|
.Subscribe(x =>
|
||||||
|
{
|
||||||
|
foreach (var condition in x.RandomChoose(2))
|
||||||
|
{
|
||||||
|
SpawnSpilledAnimation(condition);
|
||||||
|
}
|
||||||
|
}).AddTo(this);
|
||||||
#if DEVELOPMENT_BUILD || UNITY_EDITOR
|
#if DEVELOPMENT_BUILD || UNITY_EDITOR
|
||||||
cornCountSlider.wholeNumbers = true;
|
cornCountSlider.wholeNumbers = true;
|
||||||
cornCountSlider.value = cornSpawnCount;
|
cornCountSlider.value = cornSpawnCount;
|
||||||
|
|
@ -108,16 +130,31 @@ public class CornManager : MonoBehaviour
|
||||||
corn.ChangeGrowSpeed(x);
|
corn.ChangeGrowSpeed(x);
|
||||||
}).AddTo(compositeDisposable);
|
}).AddTo(compositeDisposable);
|
||||||
|
|
||||||
// コーンが弾けたとき、GrowSpeedを再設定する
|
|
||||||
corn.Condition
|
corn.Condition
|
||||||
.Where(x => x == CornCondition.Simple)
|
.Pairwise()
|
||||||
.FirstOrDefault()
|
.Subscribe(condition =>
|
||||||
.Subscribe(_ =>
|
|
||||||
{
|
{
|
||||||
// ThermalCondition.Hot以外では焦げ進行なし
|
switch (condition.Current)
|
||||||
if (!isHot)
|
|
||||||
{
|
{
|
||||||
corn.ChangeGrowSpeed(0f);
|
case CornCondition.Seed:
|
||||||
|
break;
|
||||||
|
case CornCondition.Simple:
|
||||||
|
// コーンが弾けたとき、GrowSpeedを再設定する
|
||||||
|
// ThermalCondition.Hot以外では焦げ進行なし
|
||||||
|
if (!isHot)
|
||||||
|
{
|
||||||
|
corn.ChangeGrowSpeed(0f);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CornCondition.Burnt:
|
||||||
|
break;
|
||||||
|
case CornCondition.Spilled:
|
||||||
|
// 同時に飛び出したとき用に演出をばらつかせる
|
||||||
|
this.CallWaitForSeconds(Random.Range(0f, .5f), () => cornSpilledSubject.OnNext(condition.Previous));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(condition), condition, null);
|
||||||
}
|
}
|
||||||
}).AddTo(compositeDisposable);
|
}).AddTo(compositeDisposable);
|
||||||
|
|
||||||
|
|
@ -178,6 +215,18 @@ public class CornManager : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SpawnSpilledAnimation(CornCondition condition)
|
||||||
|
{
|
||||||
|
// Result表示より下の範囲にランダム表示
|
||||||
|
var position = new Vector2((Random.value * 2 - 1) * worldWidth, Mathf.Lerp(-worldHeight, maxSpilledHeight, Random.value));
|
||||||
|
// 画面KO再生
|
||||||
|
var animation = Instantiate(spilledCornAnimationPrefab, position, Quaternion.identity);
|
||||||
|
// KOコーンスキン変更
|
||||||
|
animation.GetComponent<CornSpilled>().ChangeCornSkin(condition);
|
||||||
|
VibrationManager.Instance.PlayVibrationDoubleStrong();
|
||||||
|
this.CallWaitForSeconds(1.5f, () => Destroy(animation));
|
||||||
|
}
|
||||||
|
|
||||||
private void SetResult(CornResult resultValue)
|
private void SetResult(CornResult resultValue)
|
||||||
{
|
{
|
||||||
cornGrowSpeed.Value = 0f;
|
cornGrowSpeed.Value = 0f;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue