Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop
This commit is contained in:
		
						commit
						5b93d75ec3
					
				|  | @ -1864,10 +1864,10 @@ RectTransform: | ||||||
|   m_Father: {fileID: 357117903} |   m_Father: {fileID: 357117903} | ||||||
|   m_RootOrder: 2 |   m_RootOrder: 2 | ||||||
|   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||||
|   m_AnchorMin: {x: 0.5, y: 0.5} |   m_AnchorMin: {x: 0, y: 0.5} | ||||||
|   m_AnchorMax: {x: 0.5, y: 0.5} |   m_AnchorMax: {x: 0, y: 0.5} | ||||||
|   m_AnchoredPosition: {x: 116, y: -144} |   m_AnchoredPosition: {x: 508.4, y: -144} | ||||||
|   m_SizeDelta: {x: 300, y: 82} |   m_SizeDelta: {x: 333.3928, y: 82} | ||||||
|   m_Pivot: {x: 0.5, y: 0.5} |   m_Pivot: {x: 0.5, y: 0.5} | ||||||
| --- !u!114 &1313878218 | --- !u!114 &1313878218 | ||||||
| MonoBehaviour: | MonoBehaviour: | ||||||
|  | @ -1923,7 +1923,7 @@ MonoBehaviour: | ||||||
|   m_fontSizeMin: 18 |   m_fontSizeMin: 18 | ||||||
|   m_fontSizeMax: 72 |   m_fontSizeMax: 72 | ||||||
|   m_fontStyle: 1 |   m_fontStyle: 1 | ||||||
|   m_HorizontalAlignment: 2 |   m_HorizontalAlignment: 1 | ||||||
|   m_VerticalAlignment: 256 |   m_VerticalAlignment: 256 | ||||||
|   m_textAlignment: 65535 |   m_textAlignment: 65535 | ||||||
|   m_characterSpacing: 0 |   m_characterSpacing: 0 | ||||||
|  | @ -12077,6 +12077,7 @@ MonoBehaviour: | ||||||
|   popcornImage: {fileID: 977215194} |   popcornImage: {fileID: 977215194} | ||||||
|   popcornText: {fileID: 2078519775} |   popcornText: {fileID: 2078519775} | ||||||
|   popcornTextPerfect: {fileID: 1906782496} |   popcornTextPerfect: {fileID: 1906782496} | ||||||
|  |   quantityText: {fileID: 1313878218} | ||||||
|   rarityText: {fileID: 1459407280} |   rarityText: {fileID: 1459407280} | ||||||
|   rarityView: {fileID: 1086724006} |   rarityView: {fileID: 1086724006} | ||||||
|   detailObject: {fileID: 1030818594} |   detailObject: {fileID: 1030818594} | ||||||
|  |  | ||||||
|  | @ -1,4 +1,6 @@ | ||||||
| using System; | using System; | ||||||
|  | using System.Linq; | ||||||
|  | using TMPro; | ||||||
| using UniRx; | using UniRx; | ||||||
| using UnityEngine; | using UnityEngine; | ||||||
| using UnityEngine.UI; | using UnityEngine.UI; | ||||||
|  | @ -6,6 +8,7 @@ using UnityEngine.UI; | ||||||
| public class CookingResult : MonoBehaviour | public class CookingResult : MonoBehaviour | ||||||
| { | { | ||||||
|     private static readonly string RarityTextFormat = "売値 +{0}% UP"; |     private static readonly string RarityTextFormat = "売値 +{0}% UP"; | ||||||
|  |     private static readonly string QuantityTextFormat = "x{0}"; | ||||||
|     [SerializeField] private GameObject smokeEffect; |     [SerializeField] private GameObject smokeEffect; | ||||||
|     [SerializeField] private GameObject glitterEffect; |     [SerializeField] private GameObject glitterEffect; | ||||||
|     [SerializeField] private Button centerOkButton; |     [SerializeField] private Button centerOkButton; | ||||||
|  | @ -15,6 +18,7 @@ public class CookingResult : MonoBehaviour | ||||||
|     [SerializeField] private Image popcornImage; |     [SerializeField] private Image popcornImage; | ||||||
|     [SerializeField] private Text popcornText; |     [SerializeField] private Text popcornText; | ||||||
|     [SerializeField] private Text popcornTextPerfect; |     [SerializeField] private Text popcornTextPerfect; | ||||||
|  |     [SerializeField] private TextMeshProUGUI quantityText; | ||||||
|     [SerializeField] private Text rarityText; |     [SerializeField] private Text rarityText; | ||||||
|     [SerializeField] private RarityView rarityView; |     [SerializeField] private RarityView rarityView; | ||||||
|     [SerializeField] private GameObject detailObject; |     [SerializeField] private GameObject detailObject; | ||||||
|  | @ -28,9 +32,9 @@ public class CookingResult : MonoBehaviour | ||||||
|     { |     { | ||||||
|         var (recipe, rarityData, resultData, successAction) = LocalCacheManager.Load<(RecipeData, RarityData, CornResult, Action)>(PopcornGameManager.CookingResultDataTag); |         var (recipe, rarityData, resultData, successAction) = LocalCacheManager.Load<(RecipeData, RarityData, CornResult, Action)>(PopcornGameManager.CookingResultDataTag); | ||||||
|         var result = new ReactiveProperty<CornResult>(resultData).AddTo(this); |         var result = new ReactiveProperty<CornResult>(resultData).AddTo(this); | ||||||
|  |         SetData(recipe, rarityData); | ||||||
|         result.Subscribe(r => |         result.Subscribe(r => | ||||||
|         { |         { | ||||||
|             SetData(recipe, rarityData); |  | ||||||
|             SetUI(r); |             SetUI(r); | ||||||
|             if (r != CornResult.Failure) |             if (r != CornResult.Failure) | ||||||
|             { |             { | ||||||
|  | @ -42,6 +46,13 @@ public class CookingResult : MonoBehaviour | ||||||
|         centerOkButton.OnClickAsObservable().Subscribe(_ => |         centerOkButton.OnClickAsObservable().Subscribe(_ => | ||||||
|         { |         { | ||||||
|             // 獲得、遷移 |             // 獲得、遷移 | ||||||
|  |             AddStock(recipe, rarityData.Rarity); | ||||||
|  |             TransitionManager.Instance.LoadScene(GameScenes.Main); | ||||||
|  |         }).AddTo(this); | ||||||
|  |         leftOkButton.OnClickAsObservable().Subscribe(_ => | ||||||
|  |         { | ||||||
|  |             // 獲得、遷移 | ||||||
|  |             AddStock(recipe); | ||||||
|             TransitionManager.Instance.LoadScene(GameScenes.Main); |             TransitionManager.Instance.LoadScene(GameScenes.Main); | ||||||
|         }).AddTo(this); |         }).AddTo(this); | ||||||
|         perfectButton.OnClickAsObservable().Subscribe(_ => |         perfectButton.OnClickAsObservable().Subscribe(_ => | ||||||
|  | @ -49,11 +60,6 @@ public class CookingResult : MonoBehaviour | ||||||
|             // 広告視聴後、結果上書き |             // 広告視聴後、結果上書き | ||||||
|             result.Value = CornResult.Perfect; |             result.Value = CornResult.Perfect; | ||||||
|         }).AddTo(this); |         }).AddTo(this); | ||||||
|         leftOkButton.OnClickAsObservable().Subscribe(_ => |  | ||||||
|         { |  | ||||||
|             // 獲得、遷移 |  | ||||||
|             TransitionManager.Instance.LoadScene(GameScenes.Main); |  | ||||||
|         }).AddTo(this); |  | ||||||
|         destructionButton.OnClickAsObservable().Subscribe(_ => |         destructionButton.OnClickAsObservable().Subscribe(_ => | ||||||
|         { |         { | ||||||
|             // 遷移 |             // 遷移 | ||||||
|  | @ -66,6 +72,7 @@ public class CookingResult : MonoBehaviour | ||||||
|         // popcornImage |         // popcornImage | ||||||
|         popcornText.text = recipe.Name; |         popcornText.text = recipe.Name; | ||||||
|         popcornTextPerfect.text = recipe.Name; |         popcornTextPerfect.text = recipe.Name; | ||||||
|  |         quantityText.text = string.Format(QuantityTextFormat, recipe.Volume); | ||||||
|         rarityText.text = string.Format(RarityTextFormat, rarity.rate - 100); |         rarityText.text = string.Format(RarityTextFormat, rarity.rate - 100); | ||||||
|         rarityView.SetRarity(rarity.Rarity); |         rarityView.SetRarity(rarity.Rarity); | ||||||
|     } |     } | ||||||
|  | @ -88,5 +95,40 @@ public class CookingResult : MonoBehaviour | ||||||
|         explainObject.SetActive(result == CornResult.Good); |         explainObject.SetActive(result == CornResult.Good); | ||||||
|         explainWithRarityObject.SetActive(result == CornResult.Perfect); |         explainWithRarityObject.SetActive(result == CornResult.Perfect); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     private void AddStock(RecipeData recipe, ProductRarity rarity = ProductRarity.Normal) | ||||||
|  |     { | ||||||
|  |         var gameData = GameDataManager.GameData; | ||||||
|  |         // 店頭の空きに追加 | ||||||
|  |         var remain = recipe.Volume; | ||||||
|  |         var shopSpace = Market.ShopStockCount - gameData.ShopStock.Count; | ||||||
|  |         var stockCount = Mathf.Min(shopSpace, remain); | ||||||
|  |         gameData.ShopStock.AddRange(Enumerable.Repeat(recipe.RecipeId, stockCount)); | ||||||
|  |         remain -= stockCount; | ||||||
|  | 
 | ||||||
|  |         // 空きのタンクを確認 | ||||||
|  |         gameData.StorageTanks | ||||||
|  |             .Where(tank => tank.IsEmpty || tank.FlavorId == recipe.RecipeId && !tank.IsFull) | ||||||
|  |             .Select((tank, i) => (i, space: tank.Capacity - tank.Stock)) | ||||||
|  |             .OrderBy(x => x.space) | ||||||
|  |             .ToList() | ||||||
|  |             .ForEach(x => | ||||||
|  |             { | ||||||
|  |                 if (remain == 0) | ||||||
|  |                 { | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |                 // タンクが空ならフレーバー設定 | ||||||
|  |                 if (gameData.StorageTanks[x.i].IsEmpty) | ||||||
|  |                 { | ||||||
|  |                     gameData.StorageTanks[x.i].FlavorId = recipe.RecipeId; | ||||||
|  |                 } | ||||||
|  |                 // タンクに追加 | ||||||
|  |                 stockCount = Mathf.Min(x.space, remain); | ||||||
|  |                 gameData.StorageTanks[x.i].AddStock(rarity, stockCount); | ||||||
|  |                 remain -= stockCount; | ||||||
|  |             }); | ||||||
|  |         GameDataManager.SaveGameData(); | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -114,7 +114,6 @@ public class PopcornGameManager : MonoBehaviour | ||||||
|                 { |                 { | ||||||
|                     var recipe = LocalCacheManager.Load<RecipeData>(CookingDataTag); |                     var recipe = LocalCacheManager.Load<RecipeData>(CookingDataTag); | ||||||
|                     LocalCacheManager.Save(CookingResultDataTag, (recipe, new RarityData{id = 5, rate = 120}, result, new Action(() => cornManager.SetCornsActive(false)))); |                     LocalCacheManager.Save(CookingResultDataTag, (recipe, new RarityData{id = 5, rate = 120}, result, new Action(() => cornManager.SetCornsActive(false)))); | ||||||
|                     AddStock(recipe); |  | ||||||
|                     TransitionManager.Instance.LoadSceneAdditive(GameScenes.CookingResults); |                     TransitionManager.Instance.LoadSceneAdditive(GameScenes.CookingResults); | ||||||
|                 }); |                 }); | ||||||
|             }).AddTo(compositeDisposable); |             }).AddTo(compositeDisposable); | ||||||
|  | @ -132,55 +131,4 @@ public class PopcornGameManager : MonoBehaviour | ||||||
|          |          | ||||||
|         state.Value = GameState.Guide; |         state.Value = GameState.Guide; | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|     private void AddStock(RecipeData recipe) |  | ||||||
|     { |  | ||||||
|         var gameData = GameDataManager.GameData; |  | ||||||
|         // 店頭の空きに追加 |  | ||||||
|         var remain = recipe.Volume; |  | ||||||
|         var shopSpace = Market.ShopStockCount - gameData.ShopStock.Count; |  | ||||||
|         if (shopSpace > 0) |  | ||||||
|         { |  | ||||||
|             var stockCount = Mathf.Min(shopSpace, remain); |  | ||||||
|             for (int i = 0; i < stockCount; i++) |  | ||||||
|             { |  | ||||||
|                 gameData.ShopStock.Add(recipe.RecipeId); |  | ||||||
|             } |  | ||||||
|             remain -= stockCount; |  | ||||||
|         } |  | ||||||
|         if (remain == 0) |  | ||||||
|         { |  | ||||||
|             GameDataManager.SaveGameData(); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|         // 同じフレーバーのタンクを確認 |  | ||||||
|         var index = gameData.StorageTanks.FindIndex(x => x.FlavorId == recipe.RecipeId); |  | ||||||
|         if (index != -1) |  | ||||||
|         { |  | ||||||
|             // 同じフレーバーのタンクの空きに追加 |  | ||||||
|             var tank = gameData.StorageTanks[index]; |  | ||||||
|             var tankSpace = tank.Capacity - tank.Stock; |  | ||||||
|             if (tankSpace > 0) |  | ||||||
|             { |  | ||||||
|                 var stockCount = Mathf.Min(tankSpace, remain); |  | ||||||
|                 tank.Stock += stockCount; |  | ||||||
|                 gameData.StorageTanks[index] = tank; |  | ||||||
|                 remain -= stockCount; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         if (remain == 0) |  | ||||||
|         { |  | ||||||
|             GameDataManager.SaveGameData(); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|         // 空のタンクに追加 |  | ||||||
|         var emptyTankIndex = gameData.StorageTanks.FindIndex(x => x.Stock == 0); |  | ||||||
|         if (emptyTankIndex != -1) |  | ||||||
|         { |  | ||||||
|             gameData.StorageTanks[emptyTankIndex].FlavorId = recipe.RecipeId; |  | ||||||
|             gameData.StorageTanks[emptyTankIndex].Stock = remain; |  | ||||||
|             GameDataManager.SaveGameData(); |  | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -14,6 +14,8 @@ public class StorageTank | ||||||
|         set => SetStock(ProductRarity.Normal, value); |         set => SetStock(ProductRarity.Normal, value); | ||||||
|     } |     } | ||||||
|     public List<ProductStockData> Stocks = new List<ProductStockData>(); |     public List<ProductStockData> Stocks = new List<ProductStockData>(); | ||||||
|  |     public bool IsEmpty => Stock == 0; | ||||||
|  |     public bool IsFull => Stock == Capacity; | ||||||
| 
 | 
 | ||||||
|     public void SetStock(ProductRarity rarity, int stock) |     public void SetStock(ProductRarity rarity, int stock) | ||||||
|     { |     { | ||||||
|  | @ -22,8 +24,8 @@ public class StorageTank | ||||||
|      |      | ||||||
|     public void AddStock(ProductRarity rarity, int stock) |     public void AddStock(ProductRarity rarity, int stock) | ||||||
|     { |     { | ||||||
|         var stockData = Stocks.First(x => x.Rarity == rarity); |         var stockData = Stocks.FirstOrDefault(x => x.Rarity == rarity); | ||||||
|         if (stockData is null) |         if (stockData is default(ProductStockData)) | ||||||
|         { |         { | ||||||
|             Stocks.Add(new ProductStockData{FlavorId = FlavorId, Rarity = rarity, Stock = stock}); |             Stocks.Add(new ProductStockData{FlavorId = FlavorId, Rarity = rarity, Stock = stock}); | ||||||
|             return; |             return; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue