ゲーム進捗で判定が変化する機能追加
This commit is contained in:
parent
56a409b908
commit
64b300c4c6
|
|
@ -4309,6 +4309,9 @@ MonoBehaviour:
|
||||||
thermalControl: {fileID: 1870432535}
|
thermalControl: {fileID: 1870432535}
|
||||||
thermoMeter: {fileID: 1928679192}
|
thermoMeter: {fileID: 1928679192}
|
||||||
cornManager: {fileID: 1870432536}
|
cornManager: {fileID: 1870432536}
|
||||||
|
panColliderChanger: {fileID: 2137549896}
|
||||||
|
gameProgress: 0
|
||||||
|
resultDelay: 1.8
|
||||||
--- !u!4 &1870432534
|
--- !u!4 &1870432534
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -4904,6 +4907,18 @@ Transform:
|
||||||
type: 3}
|
type: 3}
|
||||||
m_PrefabInstance: {fileID: 2137549891}
|
m_PrefabInstance: {fileID: 2137549891}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &2137549896 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 6144151140781756319, guid: b6b05cbc51c744ac2ad95a8b229d4ddd,
|
||||||
|
type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 2137549891}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 0921292620c649ef8f75f013ff51c349, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &2603874726320550220
|
--- !u!1 &2603874726320550220
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ public class CornManager : MonoBehaviour
|
||||||
public ReactiveProperty<GameState> GameState => gameState;
|
public ReactiveProperty<GameState> GameState => gameState;
|
||||||
private readonly ReactiveProperty<GameState> gameState = new ReactiveProperty<GameState>();
|
private readonly ReactiveProperty<GameState> gameState = new ReactiveProperty<GameState>();
|
||||||
|
|
||||||
|
public IReadOnlyReactiveProperty<float> Progress => progress;
|
||||||
|
private readonly ReactiveProperty<float> progress = new ReactiveProperty<float>(0f);
|
||||||
|
|
||||||
private Corn[] cornArray;
|
private Corn[] cornArray;
|
||||||
private bool isHot;
|
private bool isHot;
|
||||||
private bool isCompleted;
|
private bool isCompleted;
|
||||||
|
|
@ -65,6 +68,8 @@ public class CornManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
cornArray = new Corn[cornSpawnCount];
|
cornArray = new Corn[cornSpawnCount];
|
||||||
result.AddTo(this);
|
result.AddTo(this);
|
||||||
|
gameState.AddTo(this);
|
||||||
|
progress.AddTo(this);
|
||||||
cornGrowSpeed.AddTo(this);
|
cornGrowSpeed.AddTo(this);
|
||||||
compositeDisposable.AddTo(this);
|
compositeDisposable.AddTo(this);
|
||||||
}
|
}
|
||||||
|
|
@ -126,6 +131,7 @@ public class CornManager : MonoBehaviour
|
||||||
isCompleted = false;
|
isCompleted = false;
|
||||||
compositeDisposable.Clear();
|
compositeDisposable.Clear();
|
||||||
cornConditions.Clear();
|
cornConditions.Clear();
|
||||||
|
progress.Value = 0f;
|
||||||
for (int i = 0; i < cornArray.Length; i++)
|
for (int i = 0; i < cornArray.Length; i++)
|
||||||
{
|
{
|
||||||
if (cornArray[i] != null)
|
if (cornArray[i] != null)
|
||||||
|
|
@ -197,6 +203,13 @@ public class CornManager : MonoBehaviour
|
||||||
|
|
||||||
var cornConditionsObservable = Observable.CombineLatest(cornConditions).Publish().RefCount();
|
var cornConditionsObservable = Observable.CombineLatest(cornConditions).Publish().RefCount();
|
||||||
|
|
||||||
|
cornConditionsObservable
|
||||||
|
.Select(x => x.Count(cond => cond != CornCondition.Seed))
|
||||||
|
.Subscribe(x =>
|
||||||
|
{
|
||||||
|
progress.Value = (float)x / cornArray.Length;
|
||||||
|
}).AddTo(compositeDisposable);
|
||||||
|
|
||||||
// すべてのコーンがSeedではなくなった場合
|
// すべてのコーンがSeedではなくなった場合
|
||||||
cornConditionsObservable
|
cornConditionsObservable
|
||||||
// .Do(x => { Debug.Log($"done:{x.Count(y => y != CornCondition.Seed):00} fail:{x.Count(y => y == CornCondition.Burnt || y == CornCondition.Spilled):00}");})
|
// .Do(x => { Debug.Log($"done:{x.Count(y => y != CornCondition.Seed):00} fail:{x.Count(y => y == CornCondition.Burnt || y == CornCondition.Spilled):00}");})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MyGame.Scenes.Cooking.Scripts;
|
||||||
using MyGame.Scripts;
|
using MyGame.Scripts;
|
||||||
using UniRx;
|
using UniRx;
|
||||||
using UniRx.Diagnostics;
|
using UniRx.Diagnostics;
|
||||||
|
|
@ -29,6 +30,11 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
[SerializeField] private ThermalControl thermalControl;
|
[SerializeField] private ThermalControl thermalControl;
|
||||||
[SerializeField] private ThermoMeter thermoMeter;
|
[SerializeField] private ThermoMeter thermoMeter;
|
||||||
[SerializeField] private CornManager cornManager;
|
[SerializeField] private CornManager cornManager;
|
||||||
|
[SerializeField] private PanColliderChanger panColliderChanger;
|
||||||
|
|
||||||
|
[Space]
|
||||||
|
[SerializeField, ReadOnly] private float gameProgress;
|
||||||
|
[SerializeField] private float resultDelay = 1.2f;
|
||||||
|
|
||||||
private readonly ReactiveProperty<GameState> state = new ReactiveProperty<GameState>(GameState.Guide);
|
private readonly ReactiveProperty<GameState> state = new ReactiveProperty<GameState>(GameState.Guide);
|
||||||
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
|
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||||
|
|
@ -71,6 +77,12 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cornManager.Progress.Subscribe(x =>
|
||||||
|
{
|
||||||
|
gameProgress = x;
|
||||||
|
panColliderChanger.ChangeState(x);
|
||||||
|
}).AddTo(this);
|
||||||
|
|
||||||
ResetGame();
|
ResetGame();
|
||||||
|
|
||||||
if (!GameDataManager.GameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
if (!GameDataManager.GameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay))
|
||||||
|
|
@ -120,6 +132,7 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
gameView.SetPan(panData.GetPrefab());
|
gameView.SetPan(panData.GetPrefab());
|
||||||
thermalControl.SetPanData(panData);
|
thermalControl.SetPanData(panData);
|
||||||
cornManager.SetCornsActive(true);
|
cornManager.SetCornsActive(true);
|
||||||
|
panColliderChanger.Reset();
|
||||||
compositeDisposable.Clear();
|
compositeDisposable.Clear();
|
||||||
cornManager.Result.SkipLatestValueOnSubscribe()
|
cornManager.Result.SkipLatestValueOnSubscribe()
|
||||||
.Take(1)
|
.Take(1)
|
||||||
|
|
@ -127,7 +140,7 @@ public class PopcornGameManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
state.Value = GameState.Result;
|
state.Value = GameState.Result;
|
||||||
// リザルト表示遅延
|
// リザルト表示遅延
|
||||||
Observable.Timer(TimeSpan.FromSeconds(1.2f)).Subscribe(_ =>
|
Observable.Timer(TimeSpan.FromSeconds(resultDelay)).Subscribe(_ =>
|
||||||
{
|
{
|
||||||
LocalCacheManager.Save(CookingResultDataTag, (rarityData, result, new Action(() => cornManager.SetCornsActive(false))));
|
LocalCacheManager.Save(CookingResultDataTag, (rarityData, result, new Action(() => cornManager.SetCornsActive(false))));
|
||||||
LocalCacheManager.Save(RestartCallbackTag, new Action(ResetGame));
|
LocalCacheManager.Save(RestartCallbackTag, new Action(ResetGame));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue