コード整理
This commit is contained in:
		
							parent
							
								
									96cc78c671
								
							
						
					
					
						commit
						7d770e166c
					
				|  | @ -46,15 +46,7 @@ public class ShopListView : MonoBehaviour | |||
|             index = tabs.Count; | ||||
|             tabs.Add((tabCategory, Instantiate(scrollRect.content, scrollRect.content.parent))); | ||||
|         } | ||||
|         var itemView = Instantiate(itemViewPrefab, tabs[index].content); | ||||
|         itemView.SetData(shopData); | ||||
|         // show detail view | ||||
|         itemView.DetailButtonObservable.Subscribe(_ => | ||||
|         { | ||||
|             LocalCacheManager.Save(ShopItemDetailView.ItemDetailTag, shopData); | ||||
|             TransitionManager.Instance.LoadSceneAdditive(GameScenes.ShoppingExplanation); | ||||
|         }).AddTo(itemView); | ||||
|         return itemView; | ||||
|         return Instantiate(itemViewPrefab, tabs[index].content); | ||||
|     } | ||||
| 
 | ||||
|     private ItemCategory GetTabCategory(ItemCategory category) | ||||
|  |  | |||
|  | @ -9,18 +9,21 @@ public class Shopping : MonoBehaviour | |||
| { | ||||
|     [SerializeField] private ShopListView listView; | ||||
|     // Start is called before the first frame update | ||||
|     private Subject<int> changeCoinSubject = new Subject<int>(); | ||||
|     void Start() | ||||
|     { | ||||
|         changeCoinSubject.AddTo(this); | ||||
|          | ||||
|         var gameData = GameDataManager.GameData; | ||||
|         CoinManager.Instance.ChangeCoin(gameData.coin); | ||||
|         HeartMeter.Instance.SetHeart(gameData.Heart); | ||||
|         var changeCoinSubject = new Subject<int>().AddTo(this); | ||||
|          | ||||
|         // 一覧データ | ||||
|         var shopDataList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopData>(Const.ShopDataSheet); | ||||
|         foreach (var shopData in shopDataList) | ||||
|         { | ||||
|             var itemView = listView.AddItemView(shopData); | ||||
|             itemView.SetData(shopData); | ||||
|             itemView.SetStockCount(GetItemAmount(shopData)); | ||||
|             // コインを監視して購入可能状態を切り替え | ||||
|             changeCoinSubject.Subscribe(ownCoin => | ||||
|  | @ -47,6 +50,12 @@ public class Shopping : MonoBehaviour | |||
|                     LocalCacheManager.Save(ShopItemPurchaseView.ItemPurchaseTag, (shopData, GetItemAmount(shopData), new Action<int>(x => purchaseSubject.OnNext(x)))); | ||||
|                     TransitionManager.Instance.LoadSceneAdditive(GameScenes.Purchase); | ||||
|                 }).AddTo(itemView); | ||||
|             // show detail view | ||||
|             itemView.DetailButtonObservable.Subscribe(_ => | ||||
|             { | ||||
|                 LocalCacheManager.Save(ShopItemDetailView.ItemDetailTag, shopData); | ||||
|                 TransitionManager.Instance.LoadSceneAdditive(GameScenes.ShoppingExplanation); | ||||
|             }).AddTo(itemView); | ||||
|         } | ||||
|         changeCoinSubject.OnNext(CoinManager.Instance.OwnCoin); | ||||
|     } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue