From 224e6ffd62c4192cf3d682c9bfb1ae5ac9e8ad64 Mon Sep 17 00:00:00 2001 From: kimura Date: Tue, 1 Feb 2022 18:23:24 +0900 Subject: [PATCH] =?UTF-8?q?=E6=AD=A9=E3=81=BF=E8=A1=A8=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E9=83=A8=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/Main/Scripts/Information.cs | 60 +++++++++++-------- .../Main/Scripts/ShopHistoryItemView.cs | 6 +- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/Information.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/Information.cs index de6e112d..9c727753 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/Information.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/Information.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using I2.Loc; using UniRx; @@ -41,6 +42,8 @@ public class Information : MonoBehaviour [SerializeField] private Text shopLevelText; [SerializeField] private Text progressText; + private bool isOdd; + private void Start() { closeButton.OnClickAsObservable().Take(1).Subscribe(_ => @@ -88,33 +91,16 @@ public class Information : MonoBehaviour // shopLevel historyTarget.DestroyAllChildrens(); - var shopLevelIndex = 1; - foreach (var levelData in shopLevelList) + SetHistory(shopLevelList[0], new List(), false); + + for (var index = 1; index < shopLevelList.Count; index++) { + var levelData = shopLevelList[index]; var scriptList = shopScriptList.Where(data => data.id == levelData.shopLevel).ToList(); - var view = Instantiate(historyPrefab, historyTarget); - view.SetOddBG(shopLevelIndex % 2 == 0); - shopLevelIndex++; - if (levelData.shopLevel > gameData.ViewedShopLevel) - { - view.SetUnreleased(true); - continue; - } - view.SetData(levelData); - if (scriptList.Count > 0) - { - view.PlayButton.ThrottleFirst(TimeSpan.FromSeconds(1f)).Subscribe(_ => - { - LocalCacheManager.Save(BrotherConversation.ScriptDataTag, scriptList); - TransitionManager.Instance.LoadSceneAdditive(GameScenes.Conversation); - }).AddTo(view); - } - else - { - view.SetButtonAcive(false); - } + SetHistory(levelData, scriptList, levelData.shopLevel > gameData.ViewedShopLevel); } - + + // product productTarget.DestroyAllChildrens(); if (totalStockList.Sum(data => data.Stock) == 0) @@ -164,4 +150,30 @@ public class Information : MonoBehaviour scrollRect.verticalNormalizedPosition = 1; shopInfoButton.onClick.Invoke(); } + + private void SetHistory(ShopLevelData levelData, List scriptList, bool unreleased, bool withoutLevelText = false) + { + var view = Instantiate(historyPrefab, historyTarget); + isOdd = !isOdd; + view.SetOddBG(isOdd); + if (unreleased) + { + view.SetUnreleased(true); + return; + } + + view.SetData(levelData, withoutLevelText); + if (scriptList.Count > 0) + { + view.PlayButton.ThrottleFirst(TimeSpan.FromSeconds(1f)).Subscribe(_ => + { + LocalCacheManager.Save(BrotherConversation.ScriptDataTag, scriptList); + TransitionManager.Instance.LoadSceneAdditive(GameScenes.Conversation); + }).AddTo(view); + } + else + { + view.SetButtonAcive(false); + } + } } diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/ShopHistoryItemView.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/ShopHistoryItemView.cs index f22bb3ca..62f9149f 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/ShopHistoryItemView.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/ShopHistoryItemView.cs @@ -5,16 +5,16 @@ using UnityEngine.UI; public class ShopHistoryItemView : MonoBehaviour { - private static readonly string acivementFormat = "Lv.{0} {1}"; + private static readonly string levelTextFormat = "Lv.{0} "; [SerializeField] private Text achievementText; [SerializeField] private Button playButton; [SerializeField] private GameObject oddColorBG; [SerializeField] private GameObject viewObject; [SerializeField] private GameObject unreleasedObject; public IObservable PlayButton => playButton.OnClickAsObservable().TakeUntilDestroy(this); - public void SetData(ShopLevelData levelData) + public void SetData(ShopLevelData levelData, bool withoutLevelText) { - achievementText.text = String.Format(acivementFormat, levelData.shopLevel, levelData.Achievement); + achievementText.text = (withoutLevelText ? "" : String.Format(levelTextFormat, levelData.shopLevel)) + levelData.Achievement; } public void SetUnreleased(bool active)