歩み表示内部修正

This commit is contained in:
kimura 2022-02-01 18:23:24 +09:00
parent 0a678bcd5c
commit 224e6ffd62
2 changed files with 39 additions and 27 deletions

View File

@ -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<BrotherScriptData>(), 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<BrotherScriptData> 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);
}
}
}

View File

@ -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<Unit> 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)