店舗レベル表示の条件ロジックを追加/ ハートメーターの挙動修正
This commit is contained in:
parent
c32eb0bf7c
commit
04ff85725c
|
|
@ -94,6 +94,7 @@ GameObject:
|
||||||
- component: {fileID: 7740671670896384492}
|
- component: {fileID: 7740671670896384492}
|
||||||
- component: {fileID: 3756929251745663541}
|
- component: {fileID: 3756929251745663541}
|
||||||
- component: {fileID: 5400893423074421525}
|
- component: {fileID: 5400893423074421525}
|
||||||
|
- component: {fileID: 7906393928596777865}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: DontDestroyObject
|
m_Name: DontDestroyObject
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -175,6 +176,18 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 77ded0026daa40d4b872efbaf2c1195c, type: 3}
|
m_Script: {fileID: 11500000, guid: 77ded0026daa40d4b872efbaf2c1195c, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!114 &7906393928596777865
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3459593390050872226}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 6febd66062c34eb18c02d22a91eebab0, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &8739647597683206087
|
--- !u!1 &8739647597683206087
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,10 @@ public class BrotherConversation : MonoBehaviour
|
||||||
backgroundAnimator.SetTrigger(CloseTrigger);
|
backgroundAnimator.SetTrigger(CloseTrigger);
|
||||||
this.CallWaitForSeconds(.25f, () =>
|
this.CallWaitForSeconds(.25f, () =>
|
||||||
{
|
{
|
||||||
|
GameDataManager.GameData.ViewedShopLevel++;
|
||||||
|
GameDataManager.GameData.OrderConditionCount = 0;
|
||||||
|
GameDataManager.SaveGameData();
|
||||||
|
HeartMeter.Instance.SetShopLevel(GameDataManager.GameData.ViewedShopLevel, true);
|
||||||
TransitionManager.Instance.UnloadScene(GameScenes.Conversation);
|
TransitionManager.Instance.UnloadScene(GameScenes.Conversation);
|
||||||
});
|
});
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using UnityEngine.UI;
|
||||||
|
|
||||||
public class ShopLevelUp : MonoBehaviour
|
public class ShopLevelUp : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public static readonly string DataTag = "ShopLevelUpData";
|
||||||
private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger");
|
private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger");
|
||||||
private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger");
|
private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger");
|
||||||
|
|
||||||
|
|
@ -19,12 +20,9 @@ public class ShopLevelUp : MonoBehaviour
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
// レベルからスクリプト読み込み
|
var shopLevel = LocalCacheManager.Load<int>(DataTag);
|
||||||
var shopLevel = 5;
|
|
||||||
var scriptList = SpreadsheetDataManager.Instance.GetBaseDataList<BrotherScriptData>(Const.ScriptDataSheet);
|
var scriptList = SpreadsheetDataManager.Instance.GetBaseDataList<BrotherScriptData>(Const.ScriptDataSheet);
|
||||||
var targetScriptList = scriptList.Where(data => data.id == shopLevel).ToList();
|
var targetScriptList = scriptList.Where(data => data.id == shopLevel).ToList();
|
||||||
LocalCacheManager.Save(BrotherConversation.ScriptDataTag, targetScriptList);
|
|
||||||
|
|
||||||
closeButton.OnClickAsObservable().Subscribe(_ =>
|
closeButton.OnClickAsObservable().Subscribe(_ =>
|
||||||
{
|
{
|
||||||
transform.SetLocalScale(0);
|
transform.SetLocalScale(0);
|
||||||
|
|
@ -32,7 +30,17 @@ public class ShopLevelUp : MonoBehaviour
|
||||||
this.CallWaitForSeconds(.25f, () =>
|
this.CallWaitForSeconds(.25f, () =>
|
||||||
{
|
{
|
||||||
TransitionManager.Instance.UnloadScene(GameScenes.StoreLevel);
|
TransitionManager.Instance.UnloadScene(GameScenes.StoreLevel);
|
||||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.Conversation);
|
if (targetScriptList.Count > 0)
|
||||||
|
{
|
||||||
|
LocalCacheManager.Save(BrotherConversation.ScriptDataTag, targetScriptList);
|
||||||
|
TransitionManager.Instance.LoadSceneAdditive(GameScenes.Conversation);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GameDataManager.GameData.ViewedShopLevel++;
|
||||||
|
GameDataManager.SaveGameData();
|
||||||
|
HeartMeter.Instance.SetShopLevel(GameDataManager.GameData.ViewedShopLevel, true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ public class Shopping : MonoBehaviour
|
||||||
var shopDataList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopData>(Const.ShopDataSheet);
|
var shopDataList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopData>(Const.ShopDataSheet);
|
||||||
foreach (var shopData in shopDataList)
|
foreach (var shopData in shopDataList)
|
||||||
{
|
{
|
||||||
Debug.Log($"{shopData.name}, {shopData.Category}");
|
|
||||||
if (shopData.Category == ItemCategory.Special)
|
if (shopData.Category == ItemCategory.Special)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ public sealed class GameData {
|
||||||
public int Heart = 0;
|
public int Heart = 0;
|
||||||
[DataMember(Name = "Data22")]
|
[DataMember(Name = "Data22")]
|
||||||
public int[] Pans;
|
public int[] Pans;
|
||||||
// [DataMember(Name = "Data23")]
|
[DataMember(Name = "Data23")]
|
||||||
|
public int ViewedShopLevel;
|
||||||
[DataMember(Name = "Data24")]
|
[DataMember(Name = "Data24")]
|
||||||
public ProductRefillMode RefillMode;
|
public ProductRefillMode RefillMode;
|
||||||
[DataMember(Name = "Data25")]
|
[DataMember(Name = "Data25")]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using UniRx;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class GameDataObserver : SingletonMonoBehaviour<GameDataObserver>
|
||||||
|
{
|
||||||
|
[SerializeField] private FloatReactiveProperty checkInterval = new FloatReactiveProperty(.1f);
|
||||||
|
private IObservable<int> heartObserver;
|
||||||
|
public IObservable<int> Heart => heartObserver;
|
||||||
|
|
||||||
|
private IObservable<int> sceneCounter;
|
||||||
|
public IObservable<int> SceneCounter => sceneCounter;
|
||||||
|
|
||||||
|
public IObservable<bool> ShopLevelUpdate;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
checkInterval.AddTo(this);
|
||||||
|
var gameData = GameDataManager.GameData;
|
||||||
|
var levelList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopLevelData>(Const.ShopLevelDataSheet);
|
||||||
|
heartObserver = checkInterval
|
||||||
|
.Select(x =>
|
||||||
|
Observable.Interval(TimeSpan.FromSeconds(x))
|
||||||
|
.Select(_ => gameData.Heart)
|
||||||
|
.DistinctUntilChanged())
|
||||||
|
.Switch();
|
||||||
|
|
||||||
|
var shopLevelObserver = checkInterval
|
||||||
|
.Select(x =>
|
||||||
|
Observable.Interval(TimeSpan.FromSeconds(x))
|
||||||
|
.Select(_ => gameData.ViewedShopLevel)
|
||||||
|
.DistinctUntilChanged())
|
||||||
|
.Switch();
|
||||||
|
|
||||||
|
sceneCounter = checkInterval
|
||||||
|
.Select(x =>
|
||||||
|
Observable.Interval(TimeSpan.FromSeconds(x))
|
||||||
|
.Select(_ => UnityEngine.SceneManagement.SceneManager.sceneCount)
|
||||||
|
.DistinctUntilChanged()
|
||||||
|
// .Do(c => { Debug.Log($"sceneCount:{c}");})
|
||||||
|
)
|
||||||
|
.Switch();
|
||||||
|
|
||||||
|
ShopLevelUpdate = Observable.CombineLatest(heartObserver, shopLevelObserver, sceneCounter,
|
||||||
|
(heart, level, sceneCount) =>
|
||||||
|
{
|
||||||
|
var currentLevel = levelList.LastOrDefault(data => data.heart <= heart)?.shopLevel ?? 1;
|
||||||
|
return currentLevel > level && sceneCount == 1;
|
||||||
|
})
|
||||||
|
.DistinctUntilChanged()
|
||||||
|
.Publish(false)
|
||||||
|
.RefCount();
|
||||||
|
ShopLevelUpdate.Subscribe(x => { Debug.Log($"change:{x}"); });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6febd66062c34eb18c02d22a91eebab0
|
||||||
|
timeCreated: 1634180079
|
||||||
|
|
@ -12,12 +12,15 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
||||||
[SerializeField] private TextMeshProUGUI heartLevel;
|
[SerializeField] private TextMeshProUGUI heartLevel;
|
||||||
|
|
||||||
private Coroutine coroutine;
|
private Coroutine coroutine;
|
||||||
private List<int> levelList = new List<int>();
|
private List<ShopLevelData> shopLevelList = new List<ShopLevelData>();
|
||||||
private int currentHeartCount;
|
private int currentHeartCount;
|
||||||
private readonly ReactiveProperty<float> viewHeartCount = new ReactiveProperty<float>();
|
private readonly ReactiveProperty<float> viewHeartCount = new ReactiveProperty<float>();
|
||||||
public IReadOnlyReactiveProperty<int> ShopLevel => shopLevel;
|
public IReadOnlyReactiveProperty<int> ShopLevel => shopLevel;
|
||||||
private readonly ReactiveProperty<int> shopLevel = new ReactiveProperty<int>();
|
private readonly ReactiveProperty<int> shopLevel = new ReactiveProperty<int>();
|
||||||
private CompositeDisposable compositeDisposable = new CompositeDisposable();
|
private CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
private float minHeart;
|
||||||
|
private float maxHeart;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
|
@ -31,30 +34,24 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
||||||
compositeDisposable.AddTo(this);
|
compositeDisposable.AddTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize(int newShopLevel = 0, int newHeartCount = 0)
|
||||||
{
|
{
|
||||||
levelList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopLevelData>(Const.ShopLevelDataSheet).Select(shopLevelData => shopLevelData.heart).ToList();
|
|
||||||
compositeDisposable.Clear();
|
compositeDisposable.Clear();
|
||||||
shopLevel.Subscribe(x =>
|
shopLevelList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopLevelData>(Const.ShopLevelDataSheet);
|
||||||
{
|
|
||||||
heartLevel.text = $"{x}";
|
|
||||||
}).AddTo(compositeDisposable);
|
|
||||||
viewHeartCount.SkipLatestValueOnSubscribe().Subscribe(heartCount =>
|
viewHeartCount.SkipLatestValueOnSubscribe().Subscribe(heartCount =>
|
||||||
{
|
{
|
||||||
if (levelList.Empty())
|
if (shopLevelList.Count == shopLevel.Value)
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
shopLevel.Value = GetShopLevel(Mathf.FloorToInt(heartCount)) + 1;
|
|
||||||
if (levelList.Count == shopLevel.Value)
|
|
||||||
{
|
{
|
||||||
slider.value = 1;
|
slider.value = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
slider.value = (heartCount - levelList[shopLevel.Value - 1]) / (levelList[shopLevel.Value] - levelList[shopLevel.Value - 1]);
|
slider.value = Mathf.InverseLerp(minHeart, maxHeart, heartCount);
|
||||||
}
|
}
|
||||||
}).AddTo(compositeDisposable);
|
}).AddTo(compositeDisposable);
|
||||||
|
SetHeart(newHeartCount);
|
||||||
|
SetShopLevel(newShopLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHeart(int heartCount)
|
public void SetHeart(int heartCount)
|
||||||
|
|
@ -63,11 +60,23 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
||||||
viewHeartCount.SetValueAndForceNotify(heartCount);
|
viewHeartCount.SetValueAndForceNotify(heartCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetShopLevel(int heartCount)
|
public void SetShopLevel(int newShopLevel, bool animate = false)
|
||||||
{
|
{
|
||||||
return levelList.FindLastIndex(x => x <= heartCount);
|
shopLevel.Value = newShopLevel;
|
||||||
|
heartLevel.text = $"{newShopLevel}";
|
||||||
|
minHeart = shopLevelList.FirstOrDefault(data => data.shopLevel == newShopLevel)?.heart ?? 0;
|
||||||
|
maxHeart = shopLevelList.FirstOrDefault(data => data.shopLevel == newShopLevel + 1)?.heart ?? 0;
|
||||||
|
if (animate)
|
||||||
|
{
|
||||||
|
var tmpCount = currentHeartCount - (int)minHeart;
|
||||||
|
SetHeart((int)minHeart);
|
||||||
|
AddHeart(tmpCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
viewHeartCount.SetValueAndForceNotify(currentHeartCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddHeart(int value)
|
public void AddHeart(int value)
|
||||||
{
|
{
|
||||||
this.SafeStopCoroutine(coroutine);
|
this.SafeStopCoroutine(coroutine);
|
||||||
|
|
@ -78,7 +87,7 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
||||||
});
|
});
|
||||||
this.CallLerp(1f, f =>
|
this.CallLerp(1f, f =>
|
||||||
{
|
{
|
||||||
viewHeartCount.Value = Mathf.Min(currentHeartCount, viewHeartCount.Value + value * Time.deltaTime);
|
viewHeartCount.Value = Mathf.Min(currentHeartCount, viewHeartCount.Value + value * f);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue