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);
|
||||
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);
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel);
|
||||
ShopLevelUp.ShowDialog(gameData.ViewedShopLevel + 1);
|
||||
}).AddTo(this);
|
||||
|
||||
GameDataObserver.Instance.HeartObserver
|
||||
.DistinctUntilChanged()
|
||||
.Pairwise()
|
||||
.Subscribe(pair =>
|
||||
{
|
||||
HeartMeter.Instance.AddHeart(pair.Current - pair.Previous);
|
||||
}).AddTo(this);
|
||||
|
||||
counterView.Initialize(gameData.CornSeed);
|
||||
additionView.Initialize(0);
|
||||
SetData();
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ public class BulkOrder : MonoBehaviour
|
|||
CoinManager.Instance.AddCoin(bulkOrderData.rewardCoin + bonus);
|
||||
gameData.Coin = CoinManager.Instance.OwnCoin;
|
||||
gameData.Heart += bulkOrderData.rewardHeart;
|
||||
HeartMeter.Instance.AddHeart(bulkOrderData.rewardHeart);
|
||||
|
||||
// カウントリセット
|
||||
gameData.OrderConditionCount = 0;
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ public class KitchenManager : MonoBehaviour
|
|||
gameData.CornSeed = 90;
|
||||
gameData.Coin = 10;
|
||||
// 店舗レベル1達成表示
|
||||
LocalCacheManager.Save(ShopLevelUp.DataTag, 1);
|
||||
LocalCacheManager.Save(ShopLevelUp.CallbackTag, new Action(() =>
|
||||
ShopLevelUp.ShowDialog(1, () =>
|
||||
{
|
||||
TutorialManager.Instance.ShowTutorialConversation(1, () =>
|
||||
{
|
||||
|
|
@ -67,8 +66,7 @@ public class KitchenManager : MonoBehaviour
|
|||
DestroyImmediate(go);
|
||||
}).AddTo(this);
|
||||
});
|
||||
}));
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel);
|
||||
});
|
||||
}
|
||||
else if (TutorialManager.Instance.Index == 6)
|
||||
{
|
||||
|
|
@ -100,12 +98,28 @@ public class KitchenManager : MonoBehaviour
|
|||
|
||||
CoinManager.Instance.ChangeCoin(gameData.Coin);
|
||||
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)
|
||||
.Subscribe(x =>
|
||||
.DelaySubscription(TimeSpan.FromSeconds(.4f))
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
LocalCacheManager.Save(ShopLevelUp.DataTag, gameData.ViewedShopLevel + 1);
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel);
|
||||
if (gameData.isFirstPlay)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopLevelUp.ShowDialog(gameData.ViewedShopLevel + 1);
|
||||
}).AddTo(this);
|
||||
|
||||
GameDataObserver.Instance.HeartObserver
|
||||
.DistinctUntilChanged()
|
||||
.Pairwise()
|
||||
.Subscribe(pair =>
|
||||
{
|
||||
HeartMeter.Instance.AddHeart(pair.Current - pair.Previous);
|
||||
}).AddTo(this);
|
||||
|
||||
kitchenView.Initialize();
|
||||
|
|
|
|||
|
|
@ -200,9 +200,9 @@ public class Market : SingletonMonoBehaviour<Market>
|
|||
var flavors = orders.Select(x => displayFlavors[x]).ToList();
|
||||
var coin = SellPopcorn(flavors);
|
||||
|
||||
// 獲得処理
|
||||
gameData.Coin += coin;
|
||||
gameData.Heart += customers.Count;
|
||||
// 獲得処理(遅延追加用変数に加算)
|
||||
gameData.WaitAddCoin += coin;
|
||||
gameData.WaitAddHeart += customers.Count;
|
||||
GameDataManager.SaveGameData();
|
||||
|
||||
// 商品補充
|
||||
|
|
@ -226,12 +226,20 @@ public class Market : SingletonMonoBehaviour<Market>
|
|||
|
||||
this.CallWaitForSeconds(waitSellTime, () =>
|
||||
{
|
||||
// 獲得処理
|
||||
gameData.MoveCoin(coin);
|
||||
GameDataManager.SaveGameData();
|
||||
|
||||
sellObservable.OnNext(coin);
|
||||
sellOrderSubject.OnNext(orders);
|
||||
CheckStock(gameData.ShopStock);
|
||||
|
||||
this.CallWaitForSeconds(waitRefillTime, () =>
|
||||
{
|
||||
// 獲得処理
|
||||
gameData.MoveHeart(customers.Count);
|
||||
GameDataManager.SaveGameData();
|
||||
|
||||
refillSubject.OnNext((isReorder, refillList));
|
||||
foreach (var controller in customers)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,12 +74,16 @@ public class MarketManager : MonoBehaviour
|
|||
|
||||
CoinManager.Instance.ChangeCoin(gameData.Coin);
|
||||
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);
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel);
|
||||
ShopLevelUp.ShowDialog(gameData.ViewedShopLevel + 1);
|
||||
}).AddTo(this);
|
||||
|
||||
productDataList = SpreadsheetDataManager.Instance.GetBaseDataList<ProductData>(Const.ProductDataSheet);
|
||||
|
|
|
|||
|
|
@ -40,12 +40,24 @@ public class ProductManagement : MonoBehaviour
|
|||
var gameData = GameDataManager.GameData;
|
||||
CoinManager.Instance.ChangeCoin(gameData.Coin);
|
||||
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)
|
||||
.Subscribe(x =>
|
||||
.DelaySubscription(TimeSpan.FromSeconds(.4f))
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
LocalCacheManager.Save(ShopLevelUp.DataTag, gameData.ViewedShopLevel + 1);
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel);
|
||||
ShopLevelUp.ShowDialog(gameData.ViewedShopLevel + 1);
|
||||
}).AddTo(this);
|
||||
|
||||
GameDataObserver.Instance.HeartObserver
|
||||
.DistinctUntilChanged()
|
||||
.Pairwise()
|
||||
.Subscribe(pair =>
|
||||
{
|
||||
HeartMeter.Instance.AddHeart(pair.Current - pair.Previous);
|
||||
}).AddTo(this);
|
||||
|
||||
// 補充方法設定
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ using UnityEngine.UI;
|
|||
|
||||
public class ShopLevelUp : MonoBehaviour
|
||||
{
|
||||
public static readonly string DataTag = "ShopLevelUpData";
|
||||
public static readonly string CallbackTag = "ShopLevelUpCallback";
|
||||
private static readonly string DataTag = "ShopLevelUpData";
|
||||
private static readonly string CallbackTag = "ShopLevelUpCallback";
|
||||
private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger");
|
||||
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 shopLevelList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopLevelData>(Const.ShopLevelDataSheet);
|
||||
shopLevelText.text = shopLevel.ToString();
|
||||
achievementText.text = shopLevelList.First(data => data.shopLevel == shopLevel).achievement;
|
||||
recipeNameText.text = productList.First(data => data.shopLevel == shopLevel).name;
|
||||
achievementText.text = shopLevelList.FirstOrDefault(data => data.shopLevel == shopLevel)?.achievement ?? "";
|
||||
recipeNameText.text = productList.FirstOrDefault(data => data.shopLevel == shopLevel)?.name ?? "";
|
||||
|
||||
summaryObject.SetActive(false);
|
||||
this.CallWaitForSeconds(1f, () =>
|
||||
|
|
@ -87,4 +87,11 @@ public class ShopLevelUp : MonoBehaviour
|
|||
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;
|
||||
CoinManager.Instance.ChangeCoin(gameData.Coin);
|
||||
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)
|
||||
.Subscribe(x =>
|
||||
.DelaySubscription(TimeSpan.FromSeconds(.4f))
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
LocalCacheManager.Save(ShopLevelUp.DataTag, gameData.ViewedShopLevel + 1);
|
||||
TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel);
|
||||
ShopLevelUp.ShowDialog(gameData.ViewedShopLevel + 1);
|
||||
}).AddTo(this);
|
||||
|
||||
GameDataObserver.Instance.HeartObserver
|
||||
.DistinctUntilChanged()
|
||||
.Pairwise()
|
||||
.Subscribe(pair =>
|
||||
{
|
||||
HeartMeter.Instance.AddHeart(pair.Current - pair.Previous);
|
||||
}).AddTo(this);
|
||||
|
||||
// 一覧データ
|
||||
|
|
|
|||
|
|
@ -135,6 +135,12 @@ public sealed class GameData {
|
|||
// フライパン
|
||||
[DataMember(Name = "Data39")]
|
||||
public int SelectedPanId;
|
||||
|
||||
// 遅延追加用加算枠
|
||||
[DataMember(Name = "Data40")]
|
||||
public int WaitAddCoin;
|
||||
[DataMember(Name = "Data41")]
|
||||
public int WaitAddHeart;
|
||||
|
||||
// mission
|
||||
[DataMember(Name = "Data1001")]
|
||||
|
|
@ -291,6 +297,26 @@ public sealed class GameData {
|
|||
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){
|
||||
// newAvatarIdList.Remove(avatarData.id);
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ public class GameDataObserver : SingletonMonoBehaviour<GameDataObserver>
|
|||
private readonly BoolReactiveProperty updateMissionAchieved = new BoolReactiveProperty();
|
||||
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()
|
||||
{
|
||||
|
|
@ -49,26 +50,6 @@ public class GameDataObserver : SingletonMonoBehaviour<GameDataObserver>
|
|||
hasRecipeObserver.OnNext(gameData.MyRecipes.Length);
|
||||
deliveredBulkOrderObserver.OnNext(gameData.BulkOrderDeliveredCount);
|
||||
}).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);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
|
@ -11,14 +12,17 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
|||
[SerializeField] private Slider slider;
|
||||
[SerializeField] private TextMeshProUGUI heartLevel;
|
||||
[SerializeField] private GameObject maxObject;
|
||||
[SerializeField] private float duration = .5f;
|
||||
|
||||
private Coroutine coroutine;
|
||||
private List<ShopLevelData> shopLevelList = new List<ShopLevelData>();
|
||||
private int currentHeartCount;
|
||||
private int maxLevel;
|
||||
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||
private readonly ReactiveProperty<float> viewHeartCount = new ReactiveProperty<float>();
|
||||
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 maxHeart;
|
||||
|
|
@ -32,7 +36,11 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
|||
{
|
||||
shopLevel.AddTo(this);
|
||||
viewHeartCount.AddTo(this);
|
||||
fulledHeart.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)
|
||||
|
|
@ -57,7 +65,7 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
|||
SetShopLevel(newShopLevel);
|
||||
}
|
||||
|
||||
public void SetHeart(int heartCount)
|
||||
private void SetHeart(int heartCount)
|
||||
{
|
||||
currentHeartCount = heartCount;
|
||||
viewHeartCount.SetValueAndForceNotify(heartCount);
|
||||
|
|
@ -75,6 +83,7 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
|||
maxHeart = shopLevelList.FirstOrDefault(data => data.shopLevel == level + 1)?.heart ?? minHeart;
|
||||
if (animate)
|
||||
{
|
||||
fulledHeart.Value = false;
|
||||
var tmpCount = currentHeartCount - (int)minHeart;
|
||||
SetHeart((int)minHeart);
|
||||
AddHeart(tmpCount);
|
||||
|
|
@ -82,19 +91,27 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
|||
else
|
||||
{
|
||||
viewHeartCount.SetValueAndForceNotify(currentHeartCount);
|
||||
fulledHeart.Value = currentHeartCount >= maxHeart && shopLevel.Value < maxLevel;
|
||||
}
|
||||
}
|
||||
public void AddHeart(int value)
|
||||
{
|
||||
this.SafeStopCoroutine(coroutine);
|
||||
currentHeartCount += value;
|
||||
coroutine = this.CallWaitForSeconds(1f, () =>
|
||||
coroutine = this.CallWaitForSeconds(duration, () =>
|
||||
{
|
||||
SetHeart(currentHeartCount);
|
||||
});
|
||||
this.CallLerp(1f, f =>
|
||||
{
|
||||
viewHeartCount.Value = Mathf.Min(currentHeartCount, viewHeartCount.Value + value * f);
|
||||
});
|
||||
var fixValue = Mathf.Min(value, maxHeart);
|
||||
this.UpdateAsObservable()
|
||||
.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;
|
||||
|
||||
Input.multiTouchEnabled = false;
|
||||
|
||||
// 遅延させていたパラメータを追加
|
||||
GameDataManager.GameData.MoveAllWaitValue();
|
||||
GameDataManager.SaveGameData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue