Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop
This commit is contained in:
		
						commit
						0f51898a41
					
				|  | @ -83,13 +83,26 @@ public class CornField : MonoBehaviour | ||||||
|          |          | ||||||
|         CoinManager.Instance.ChangeCoin(gameData.Coin); |         CoinManager.Instance.ChangeCoin(gameData.Coin); | ||||||
|         HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); |         HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); | ||||||
|         GameDataObserver.Instance.ShopLevelUpdate |          | ||||||
|             .Where(x => x && !isFertilizing) |         // ハートゲージがフルかつダイアログが開いていない場合レベルアップ | ||||||
|             .Subscribe(x => |         GameDataObserver.Instance.SceneCounter | ||||||
|  |             .DistinctUntilChanged() | ||||||
|  |             .CombineLatest(HeartMeter.Instance.FulledHeart, (count, fulled) => count == 1 && fulled) | ||||||
|  |             .Where(x => x) | ||||||
|  |             .DelaySubscription(TimeSpan.FromSeconds(.4f)) | ||||||
|  |             .Subscribe(_ => | ||||||
|             { |             { | ||||||
|                 LocalCacheManager.Save(ShopLevelUp.DataTag, gameData.ViewedShopLevel + 1); |                 ShopLevelUp.ShowDialog(gameData.ViewedShopLevel + 1); | ||||||
|                 TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel); |  | ||||||
|             }).AddTo(this); |             }).AddTo(this); | ||||||
|  | 
 | ||||||
|  |         GameDataObserver.Instance.HeartObserver | ||||||
|  |             .DistinctUntilChanged() | ||||||
|  |             .Pairwise() | ||||||
|  |             .Subscribe(pair => | ||||||
|  |             { | ||||||
|  |                 HeartMeter.Instance.AddHeart(pair.Current - pair.Previous); | ||||||
|  |             }).AddTo(this); | ||||||
|  |          | ||||||
|         counterView.Initialize(gameData.CornSeed); |         counterView.Initialize(gameData.CornSeed); | ||||||
|         additionView.Initialize(0); |         additionView.Initialize(0); | ||||||
|         SetData(); |         SetData(); | ||||||
|  |  | ||||||
|  | @ -115,7 +115,6 @@ public class BulkOrder : MonoBehaviour | ||||||
|                 CoinManager.Instance.AddCoin(bulkOrderData.rewardCoin + bonus); |                 CoinManager.Instance.AddCoin(bulkOrderData.rewardCoin + bonus); | ||||||
|                 gameData.Coin = CoinManager.Instance.OwnCoin; |                 gameData.Coin = CoinManager.Instance.OwnCoin; | ||||||
|                 gameData.Heart += bulkOrderData.rewardHeart; |                 gameData.Heart += bulkOrderData.rewardHeart; | ||||||
|                 HeartMeter.Instance.AddHeart(bulkOrderData.rewardHeart); |  | ||||||
|                  |                  | ||||||
|                 // カウントリセット |                 // カウントリセット | ||||||
|                 gameData.OrderConditionCount = 0; |                 gameData.OrderConditionCount = 0; | ||||||
|  |  | ||||||
|  | @ -54,8 +54,7 @@ public class KitchenManager : MonoBehaviour | ||||||
|                 gameData.CornSeed = 90; |                 gameData.CornSeed = 90; | ||||||
|                 gameData.Coin = 10; |                 gameData.Coin = 10; | ||||||
|                 // 店舗レベル1達成表示 |                 // 店舗レベル1達成表示 | ||||||
|                 LocalCacheManager.Save(ShopLevelUp.DataTag, 1); |                 ShopLevelUp.ShowDialog(1, () => | ||||||
|                 LocalCacheManager.Save(ShopLevelUp.CallbackTag, new Action(() => |  | ||||||
|                 { |                 { | ||||||
|                     TutorialManager.Instance.ShowTutorialConversation(1, () => |                     TutorialManager.Instance.ShowTutorialConversation(1, () => | ||||||
|                     { |                     { | ||||||
|  | @ -67,8 +66,7 @@ public class KitchenManager : MonoBehaviour | ||||||
|                             DestroyImmediate(go); |                             DestroyImmediate(go); | ||||||
|                         }).AddTo(this); |                         }).AddTo(this); | ||||||
|                     }); |                     }); | ||||||
|                 })); |                 }); | ||||||
|                 TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel); |  | ||||||
|             } |             } | ||||||
|             else if (TutorialManager.Instance.Index == 6) |             else if (TutorialManager.Instance.Index == 6) | ||||||
|             { |             { | ||||||
|  | @ -100,12 +98,28 @@ public class KitchenManager : MonoBehaviour | ||||||
|          |          | ||||||
|         CoinManager.Instance.ChangeCoin(gameData.Coin); |         CoinManager.Instance.ChangeCoin(gameData.Coin); | ||||||
|         HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); |         HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); | ||||||
|         GameDataObserver.Instance.ShopLevelUpdate |          | ||||||
|  |         // ハートゲージがフルかつダイアログが開いていない場合レベルアップ | ||||||
|  |         GameDataObserver.Instance.SceneCounter | ||||||
|  |             .DistinctUntilChanged() | ||||||
|  |             .CombineLatest(HeartMeter.Instance.FulledHeart, (count, fulled) => count == 1 && fulled) | ||||||
|             .Where(x => x) |             .Where(x => x) | ||||||
|             .Subscribe(x => |             .DelaySubscription(TimeSpan.FromSeconds(.4f)) | ||||||
|  |             .Subscribe(_ => | ||||||
|             { |             { | ||||||
|                 LocalCacheManager.Save(ShopLevelUp.DataTag, gameData.ViewedShopLevel + 1); |                 if (gameData.isFirstPlay) | ||||||
|                 TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel); |                 { | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |                 ShopLevelUp.ShowDialog(gameData.ViewedShopLevel + 1); | ||||||
|  |             }).AddTo(this); | ||||||
|  | 
 | ||||||
|  |         GameDataObserver.Instance.HeartObserver | ||||||
|  |             .DistinctUntilChanged() | ||||||
|  |             .Pairwise() | ||||||
|  |             .Subscribe(pair => | ||||||
|  |             { | ||||||
|  |                 HeartMeter.Instance.AddHeart(pair.Current - pair.Previous); | ||||||
|             }).AddTo(this); |             }).AddTo(this); | ||||||
| 
 | 
 | ||||||
|         kitchenView.Initialize(); |         kitchenView.Initialize(); | ||||||
|  |  | ||||||
|  | @ -200,9 +200,9 @@ public class Market : SingletonMonoBehaviour<Market> | ||||||
|             var flavors = orders.Select(x => displayFlavors[x]).ToList(); |             var flavors = orders.Select(x => displayFlavors[x]).ToList(); | ||||||
|             var coin = SellPopcorn(flavors); |             var coin = SellPopcorn(flavors); | ||||||
|              |              | ||||||
|             // 獲得処理 |             // 獲得処理(遅延追加用変数に加算) | ||||||
|             gameData.Coin += coin; |             gameData.WaitAddCoin += coin; | ||||||
|             gameData.Heart += customers.Count; |             gameData.WaitAddHeart += customers.Count; | ||||||
|             GameDataManager.SaveGameData(); |             GameDataManager.SaveGameData(); | ||||||
|              |              | ||||||
|             // 商品補充 |             // 商品補充 | ||||||
|  | @ -226,12 +226,20 @@ public class Market : SingletonMonoBehaviour<Market> | ||||||
| 
 | 
 | ||||||
|             this.CallWaitForSeconds(waitSellTime, () => |             this.CallWaitForSeconds(waitSellTime, () => | ||||||
|             { |             { | ||||||
|  |                 // 獲得処理 | ||||||
|  |                 gameData.MoveCoin(coin); | ||||||
|  |                 GameDataManager.SaveGameData(); | ||||||
|  |                  | ||||||
|                 sellObservable.OnNext(coin); |                 sellObservable.OnNext(coin); | ||||||
|                 sellOrderSubject.OnNext(orders); |                 sellOrderSubject.OnNext(orders); | ||||||
|                 CheckStock(gameData.ShopStock); |                 CheckStock(gameData.ShopStock); | ||||||
| 
 | 
 | ||||||
|                 this.CallWaitForSeconds(waitRefillTime, () => |                 this.CallWaitForSeconds(waitRefillTime, () => | ||||||
|                 { |                 { | ||||||
|  |                     // 獲得処理 | ||||||
|  |                     gameData.MoveHeart(customers.Count); | ||||||
|  |                     GameDataManager.SaveGameData(); | ||||||
|  | 
 | ||||||
|                     refillSubject.OnNext((isReorder, refillList)); |                     refillSubject.OnNext((isReorder, refillList)); | ||||||
|                     foreach (var controller in customers) |                     foreach (var controller in customers) | ||||||
|                     { |                     { | ||||||
|  |  | ||||||
|  | @ -74,12 +74,16 @@ public class MarketManager : MonoBehaviour | ||||||
| 
 | 
 | ||||||
|         CoinManager.Instance.ChangeCoin(gameData.Coin); |         CoinManager.Instance.ChangeCoin(gameData.Coin); | ||||||
|         HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); |         HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); | ||||||
|         GameDataObserver.Instance.ShopLevelUpdate |          | ||||||
|             .Where(x => x && !market.IsPromotion.Value) |         // ハートゲージがフルかつダイアログが開いていない場合レベルアップ | ||||||
|             .Subscribe(x => |         GameDataObserver.Instance.SceneCounter | ||||||
|  |             .DistinctUntilChanged() | ||||||
|  |             .CombineLatest(HeartMeter.Instance.FulledHeart, (count, fulled) => count == 1 && fulled) | ||||||
|  |             .Where(x => x) | ||||||
|  |             .DelaySubscription(TimeSpan.FromSeconds(.4f)) | ||||||
|  |             .Subscribe(_ => | ||||||
|             { |             { | ||||||
|                 LocalCacheManager.Save(ShopLevelUp.DataTag, gameData.ViewedShopLevel + 1); |                 ShopLevelUp.ShowDialog(gameData.ViewedShopLevel + 1); | ||||||
|                 TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel); |  | ||||||
|             }).AddTo(this); |             }).AddTo(this); | ||||||
|          |          | ||||||
|         productDataList = SpreadsheetDataManager.Instance.GetBaseDataList<ProductData>(Const.ProductDataSheet); |         productDataList = SpreadsheetDataManager.Instance.GetBaseDataList<ProductData>(Const.ProductDataSheet); | ||||||
|  |  | ||||||
|  | @ -40,12 +40,24 @@ public class ProductManagement : MonoBehaviour | ||||||
|         var gameData = GameDataManager.GameData; |         var gameData = GameDataManager.GameData; | ||||||
|         CoinManager.Instance.ChangeCoin(gameData.Coin); |         CoinManager.Instance.ChangeCoin(gameData.Coin); | ||||||
|         HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); |         HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); | ||||||
|         GameDataObserver.Instance.ShopLevelUpdate |          | ||||||
|  |         // ハートゲージがフルかつダイアログが開いていない場合レベルアップ | ||||||
|  |         GameDataObserver.Instance.SceneCounter | ||||||
|  |             .DistinctUntilChanged() | ||||||
|  |             .CombineLatest(HeartMeter.Instance.FulledHeart, (count, fulled) => count == 1 && fulled) | ||||||
|             .Where(x => x) |             .Where(x => x) | ||||||
|             .Subscribe(x => |             .DelaySubscription(TimeSpan.FromSeconds(.4f)) | ||||||
|  |             .Subscribe(_ => | ||||||
|             { |             { | ||||||
|                 LocalCacheManager.Save(ShopLevelUp.DataTag, gameData.ViewedShopLevel + 1); |                 ShopLevelUp.ShowDialog(gameData.ViewedShopLevel + 1); | ||||||
|                 TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel); |             }).AddTo(this); | ||||||
|  | 
 | ||||||
|  |         GameDataObserver.Instance.HeartObserver | ||||||
|  |             .DistinctUntilChanged() | ||||||
|  |             .Pairwise() | ||||||
|  |             .Subscribe(pair => | ||||||
|  |             { | ||||||
|  |                 HeartMeter.Instance.AddHeart(pair.Current - pair.Previous); | ||||||
|             }).AddTo(this); |             }).AddTo(this); | ||||||
| 
 | 
 | ||||||
|         // 補充方法設定 |         // 補充方法設定 | ||||||
|  |  | ||||||
|  | @ -9,8 +9,8 @@ using UnityEngine.UI; | ||||||
| 
 | 
 | ||||||
| public class ShopLevelUp : MonoBehaviour | public class ShopLevelUp : MonoBehaviour | ||||||
| { | { | ||||||
|     public static readonly string DataTag = "ShopLevelUpData"; |     private static readonly string DataTag = "ShopLevelUpData"; | ||||||
|     public static readonly string CallbackTag = "ShopLevelUpCallback"; |     private static readonly string CallbackTag = "ShopLevelUpCallback"; | ||||||
|     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"); | ||||||
|      |      | ||||||
|  | @ -58,8 +58,8 @@ public class ShopLevelUp : MonoBehaviour | ||||||
|         var productList = SpreadsheetDataManager.Instance.GetBaseDataList<ProductData>(Const.ProductDataSheet); |         var productList = SpreadsheetDataManager.Instance.GetBaseDataList<ProductData>(Const.ProductDataSheet); | ||||||
|         var shopLevelList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopLevelData>(Const.ShopLevelDataSheet); |         var shopLevelList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopLevelData>(Const.ShopLevelDataSheet); | ||||||
|         shopLevelText.text = shopLevel.ToString(); |         shopLevelText.text = shopLevel.ToString(); | ||||||
|         achievementText.text = shopLevelList.First(data => data.shopLevel == shopLevel).achievement; |         achievementText.text = shopLevelList.FirstOrDefault(data => data.shopLevel == shopLevel)?.achievement ?? ""; | ||||||
|         recipeNameText.text = productList.First(data => data.shopLevel == shopLevel).name; |         recipeNameText.text = productList.FirstOrDefault(data => data.shopLevel == shopLevel)?.name ?? ""; | ||||||
| 
 | 
 | ||||||
|         summaryObject.SetActive(false); |         summaryObject.SetActive(false); | ||||||
|         this.CallWaitForSeconds(1f, () => |         this.CallWaitForSeconds(1f, () => | ||||||
|  | @ -87,4 +87,11 @@ public class ShopLevelUp : MonoBehaviour | ||||||
|             LocalCacheManager.Remove(CallbackTag); |             LocalCacheManager.Remove(CallbackTag); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public static void ShowDialog(int level, Action onComplete = null) | ||||||
|  |     { | ||||||
|  |         LocalCacheManager.Save(DataTag, level); | ||||||
|  |         LocalCacheManager.Save(CallbackTag, onComplete); | ||||||
|  |         TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -19,12 +19,24 @@ public class Shopping : MonoBehaviour | ||||||
|         var gameData = GameDataManager.GameData; |         var gameData = GameDataManager.GameData; | ||||||
|         CoinManager.Instance.ChangeCoin(gameData.Coin); |         CoinManager.Instance.ChangeCoin(gameData.Coin); | ||||||
|         HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); |         HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); | ||||||
|         GameDataObserver.Instance.ShopLevelUpdate |          | ||||||
|  |         // ハートゲージがフルかつダイアログが開いていない場合レベルアップ | ||||||
|  |         GameDataObserver.Instance.SceneCounter | ||||||
|  |             .DistinctUntilChanged() | ||||||
|  |             .CombineLatest(HeartMeter.Instance.FulledHeart, (count, fulled) => count == 1 && fulled) | ||||||
|             .Where(x => x) |             .Where(x => x) | ||||||
|             .Subscribe(x => |             .DelaySubscription(TimeSpan.FromSeconds(.4f)) | ||||||
|  |             .Subscribe(_ => | ||||||
|             { |             { | ||||||
|                 LocalCacheManager.Save(ShopLevelUp.DataTag, gameData.ViewedShopLevel + 1); |                 ShopLevelUp.ShowDialog(gameData.ViewedShopLevel + 1); | ||||||
|                 TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel); |             }).AddTo(this); | ||||||
|  | 
 | ||||||
|  |         GameDataObserver.Instance.HeartObserver | ||||||
|  |             .DistinctUntilChanged() | ||||||
|  |             .Pairwise() | ||||||
|  |             .Subscribe(pair => | ||||||
|  |             { | ||||||
|  |                 HeartMeter.Instance.AddHeart(pair.Current - pair.Previous); | ||||||
|             }).AddTo(this); |             }).AddTo(this); | ||||||
|          |          | ||||||
|         // 一覧データ |         // 一覧データ | ||||||
|  |  | ||||||
|  | @ -135,6 +135,12 @@ public sealed class GameData { | ||||||
|     // フライパン |     // フライパン | ||||||
|     [DataMember(Name = "Data39")]  |     [DataMember(Name = "Data39")]  | ||||||
|     public int SelectedPanId; |     public int SelectedPanId; | ||||||
|  | 
 | ||||||
|  |     // 遅延追加用加算枠 | ||||||
|  |     [DataMember(Name = "Data40")]  | ||||||
|  |     public int WaitAddCoin; | ||||||
|  |     [DataMember(Name = "Data41")]  | ||||||
|  |     public int WaitAddHeart; | ||||||
|      |      | ||||||
|     // mission |     // mission | ||||||
|     [DataMember(Name = "Data1001")]  |     [DataMember(Name = "Data1001")]  | ||||||
|  | @ -291,6 +297,26 @@ public sealed class GameData { | ||||||
|         kitchenRefreshTime = DateTime.UtcNow.ToBinary(); |         kitchenRefreshTime = DateTime.UtcNow.ToBinary(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public void MoveCoin(int value) | ||||||
|  |     { | ||||||
|  |         // 退避していたコインを加算 | ||||||
|  |         WaitAddCoin -= value; | ||||||
|  |         Coin += value; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void MoveHeart(int value) | ||||||
|  |     { | ||||||
|  |         WaitAddHeart -= value; | ||||||
|  |         Heart += value; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void MoveAllWaitValue() | ||||||
|  |     { | ||||||
|  |         Debug.Log($"WaitAddValue:{WaitAddCoin},{WaitAddHeart}"); | ||||||
|  |         MoveCoin(WaitAddCoin); | ||||||
|  |         MoveHeart(WaitAddHeart); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     // public void ChangeAvatar(AvatarData avatarData){ |     // public void ChangeAvatar(AvatarData avatarData){ | ||||||
|     //     newAvatarIdList.Remove(avatarData.id); |     //     newAvatarIdList.Remove(avatarData.id); | ||||||
|     // } |     // } | ||||||
|  |  | ||||||
|  | @ -23,7 +23,8 @@ public class GameDataObserver : SingletonMonoBehaviour<GameDataObserver> | ||||||
|     private readonly BoolReactiveProperty updateMissionAchieved = new BoolReactiveProperty(); |     private readonly BoolReactiveProperty updateMissionAchieved = new BoolReactiveProperty(); | ||||||
|     public IReadOnlyReactiveProperty<bool> UpdateMissionAchieved => updateMissionAchieved; |     public IReadOnlyReactiveProperty<bool> UpdateMissionAchieved => updateMissionAchieved; | ||||||
| 
 | 
 | ||||||
|     public IObservable<bool> ShopLevelUpdate { get; private set; } |     public IObservable<int> HeartObserver => heartObserver; | ||||||
|  |     public IObservable<int> SceneCounter => sceneCounter; | ||||||
| 
 | 
 | ||||||
|     private void Start() |     private void Start() | ||||||
|     { |     { | ||||||
|  | @ -49,26 +50,6 @@ public class GameDataObserver : SingletonMonoBehaviour<GameDataObserver> | ||||||
|                 hasRecipeObserver.OnNext(gameData.MyRecipes.Length); |                 hasRecipeObserver.OnNext(gameData.MyRecipes.Length); | ||||||
|                 deliveredBulkOrderObserver.OnNext(gameData.BulkOrderDeliveredCount); |                 deliveredBulkOrderObserver.OnNext(gameData.BulkOrderDeliveredCount); | ||||||
|             }).AddTo(this); |             }).AddTo(this); | ||||||
| 
 |  | ||||||
|         ShopLevelUpdate = Observable.CombineLatest( |  | ||||||
|                 heartObserver.DistinctUntilChanged(), |  | ||||||
|                 sceneCounter.DistinctUntilChanged().Delay(TimeSpan.FromSeconds(.4f)), |  | ||||||
|                 (heart, sceneCount) => |  | ||||||
|                 { |  | ||||||
|                     var viewedLevel = GameDataManager.GameData.ViewedShopLevel; |  | ||||||
|                     if (viewedLevel == 0 && GameDataManager.GameData.isFirstPlay) |  | ||||||
|                     { |  | ||||||
|                         return false; |  | ||||||
|                     } |  | ||||||
|                     var currentLevel = levelList.LastOrDefault(data => data.heart <= heart)?.shopLevel ?? 1; |  | ||||||
|                     return currentLevel > viewedLevel && sceneCount == 1; |  | ||||||
|                 }) |  | ||||||
|             .DistinctUntilChanged() |  | ||||||
|             .Publish(false) |  | ||||||
|             .RefCount(); |  | ||||||
| #if UNITY_EDITOR |  | ||||||
|         // ShopLevelUpdate.Subscribe(x => { Debug.Log($"change:{x}"); }); |  | ||||||
| #endif |  | ||||||
|          |          | ||||||
|         // ミッション達成チェッカー |         // ミッション達成チェッカー | ||||||
|         var missionList = SpreadsheetDataManager.Instance.GetBaseDataList<MissionData>(Const.MissionDataSheet); |         var missionList = SpreadsheetDataManager.Instance.GetBaseDataList<MissionData>(Const.MissionDataSheet); | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ using System.Collections.Generic; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using TMPro; | using TMPro; | ||||||
| using UniRx; | using UniRx; | ||||||
|  | using UniRx.Triggers; | ||||||
| using UnityEngine; | using UnityEngine; | ||||||
| using UnityEngine.UI; | using UnityEngine.UI; | ||||||
| 
 | 
 | ||||||
|  | @ -11,14 +12,17 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter> | ||||||
|     [SerializeField] private Slider slider; |     [SerializeField] private Slider slider; | ||||||
|     [SerializeField] private TextMeshProUGUI heartLevel; |     [SerializeField] private TextMeshProUGUI heartLevel; | ||||||
|     [SerializeField] private GameObject maxObject; |     [SerializeField] private GameObject maxObject; | ||||||
|  |     [SerializeField] private float duration = .5f; | ||||||
| 
 | 
 | ||||||
|     private Coroutine coroutine; |     private Coroutine coroutine; | ||||||
|     private List<ShopLevelData> shopLevelList = new List<ShopLevelData>(); |     private List<ShopLevelData> shopLevelList = new List<ShopLevelData>(); | ||||||
|     private int currentHeartCount; |     private int currentHeartCount; | ||||||
|     private int maxLevel; |     private int maxLevel; | ||||||
|  |     private readonly CompositeDisposable compositeDisposable = new CompositeDisposable(); | ||||||
|     private readonly ReactiveProperty<float> viewHeartCount = new ReactiveProperty<float>(); |     private readonly ReactiveProperty<float> viewHeartCount = new ReactiveProperty<float>(); | ||||||
|     private readonly ReactiveProperty<int> shopLevel = new ReactiveProperty<int>(); |     private readonly ReactiveProperty<int> shopLevel = new ReactiveProperty<int>(); | ||||||
|     private CompositeDisposable compositeDisposable = new CompositeDisposable(); |     private readonly ReactiveProperty<bool> fulledHeart = new ReactiveProperty<bool>(); | ||||||
|  |     public IObservable<bool> FulledHeart => fulledHeart.DistinctUntilChanged(); | ||||||
| 
 | 
 | ||||||
|     private float minHeart; |     private float minHeart; | ||||||
|     private float maxHeart; |     private float maxHeart; | ||||||
|  | @ -32,7 +36,11 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter> | ||||||
|     { |     { | ||||||
|         shopLevel.AddTo(this); |         shopLevel.AddTo(this); | ||||||
|         viewHeartCount.AddTo(this); |         viewHeartCount.AddTo(this); | ||||||
|  |         fulledHeart.AddTo(this); | ||||||
|         compositeDisposable.AddTo(this); |         compositeDisposable.AddTo(this); | ||||||
|  | #if UNITY_EDITOR | ||||||
|  |         fulledHeart.Subscribe(x => { Debug.Log($"fulled:{x}"); }); | ||||||
|  | #endif | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void Initialize(int newShopLevel = 0, int newHeartCount = 0) |     public void Initialize(int newShopLevel = 0, int newHeartCount = 0) | ||||||
|  | @ -57,7 +65,7 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter> | ||||||
|         SetShopLevel(newShopLevel); |         SetShopLevel(newShopLevel); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     public void SetHeart(int heartCount) |     private void SetHeart(int heartCount) | ||||||
|     { |     { | ||||||
|         currentHeartCount = heartCount; |         currentHeartCount = heartCount; | ||||||
|         viewHeartCount.SetValueAndForceNotify(heartCount); |         viewHeartCount.SetValueAndForceNotify(heartCount); | ||||||
|  | @ -75,6 +83,7 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter> | ||||||
|         maxHeart = shopLevelList.FirstOrDefault(data => data.shopLevel == level + 1)?.heart ?? minHeart; |         maxHeart = shopLevelList.FirstOrDefault(data => data.shopLevel == level + 1)?.heart ?? minHeart; | ||||||
|         if (animate) |         if (animate) | ||||||
|         { |         { | ||||||
|  |             fulledHeart.Value = false; | ||||||
|             var tmpCount = currentHeartCount - (int)minHeart; |             var tmpCount = currentHeartCount - (int)minHeart; | ||||||
|             SetHeart((int)minHeart); |             SetHeart((int)minHeart); | ||||||
|             AddHeart(tmpCount); |             AddHeart(tmpCount); | ||||||
|  | @ -82,19 +91,27 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter> | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             viewHeartCount.SetValueAndForceNotify(currentHeartCount); |             viewHeartCount.SetValueAndForceNotify(currentHeartCount); | ||||||
|  |             fulledHeart.Value = currentHeartCount >= maxHeart && shopLevel.Value < maxLevel; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     public void AddHeart(int value) |     public void AddHeart(int value) | ||||||
|     { |     { | ||||||
|         this.SafeStopCoroutine(coroutine); |         this.SafeStopCoroutine(coroutine); | ||||||
|         currentHeartCount += value; |         currentHeartCount += value; | ||||||
|         coroutine = this.CallWaitForSeconds(1f, () => |         coroutine = this.CallWaitForSeconds(duration, () => | ||||||
|         { |         { | ||||||
|             SetHeart(currentHeartCount); |             SetHeart(currentHeartCount); | ||||||
|         }); |         }); | ||||||
|         this.CallLerp(1f, f => |         var fixValue = Mathf.Min(value, maxHeart); | ||||||
|         { |         this.UpdateAsObservable() | ||||||
|             viewHeartCount.Value = Mathf.Min(currentHeartCount, viewHeartCount.Value + value * f); |             .Select(_ => Time.deltaTime / duration) | ||||||
|         }); |             .Take(TimeSpan.FromSeconds(duration)) | ||||||
|  |             .Subscribe(t => | ||||||
|  |             { | ||||||
|  |                 viewHeartCount.Value += fixValue * t; | ||||||
|  |             }, () => | ||||||
|  |             { | ||||||
|  |                 fulledHeart.Value = currentHeartCount >= maxHeart && shopLevel.Value < maxLevel; | ||||||
|  |             }).AddTo(this); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | @ -27,5 +27,9 @@ public sealed class InitializeUnitySettings : MonoBehaviour { | ||||||
|         Application.targetFrameRate = 60; |         Application.targetFrameRate = 60; | ||||||
| 
 | 
 | ||||||
|         Input.multiTouchEnabled = false; |         Input.multiTouchEnabled = false; | ||||||
|  |          | ||||||
|  |         // 遅延させていたパラメータを追加 | ||||||
|  |         GameDataManager.GameData.MoveAllWaitValue(); | ||||||
|  |         GameDataManager.SaveGameData(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue