お店の歩み、チュートリアル表示対応

This commit is contained in:
kimura 2022-02-02 11:17:23 +09:00
parent 8c28789973
commit a278bd16c3
3 changed files with 54 additions and 18 deletions

View File

@ -91,7 +91,17 @@ public class Information : MonoBehaviour
// shopLevel
historyTarget.DestroyAllChildrens();
SetHistory(shopLevelList[0], new List<BrotherScriptData>(), false);
var tutorialDataList = SpreadsheetDataManager.Instance.GetBaseDataList<BrotherScriptData>(Const.TutorialScriptDataSheet);
var mainList = tutorialDataList.Where(data => Const.MainTutorial.Contains(data.id)).OrderBy(data => Array.IndexOf(Const.MainTutorial, data.id)).ToList();
var fieldList = tutorialDataList.Where(data => Const.FieldTutorial.Contains(data.id)).OrderBy(data => Array.IndexOf(Const.FieldTutorial, data.id)).ToList();
var shoppingList = tutorialDataList.Where(data => Const.ShoppingTutorial.Contains(data.id)).OrderBy(data => Array.IndexOf(Const.ShoppingTutorial, data.id)).ToList();
var managementList = tutorialDataList.Where(data => Const.ManagementTutorial.Contains(data.id)).OrderBy(data => Array.IndexOf(Const.ManagementTutorial, data.id)).ToList();
SetHistory(shopLevelList[0], mainList, false);
// tutorial用のSetHistoryが必要
SetHistory(ScriptLocalization.Item.ShopHistoryText0001, fieldList);
SetHistory(ScriptLocalization.Item.ShopHistoryText0002, shoppingList);
SetHistory(ScriptLocalization.Item.ShopHistoryText0003, managementList);
for (var index = 1; index < shopLevelList.Count; index++)
{
@ -151,29 +161,46 @@ public class Information : MonoBehaviour
shopInfoButton.onClick.Invoke();
}
private void SetHistory(ShopLevelData levelData, List<BrotherScriptData> scriptList, bool unreleased, bool withoutLevelText = false)
private void SetHistory(ShopLevelData levelData, List<BrotherScriptData> scriptList, bool unreleased)
{
var view = Instantiate(historyPrefab, historyTarget);
isOdd = !isOdd;
view.SetOddBG(isOdd);
var view = CreateItemView();
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.SetData(levelData);
SetScript(view, scriptList);
}
private void SetHistory(string text, List<BrotherScriptData> scriptList)
{
var view = CreateItemView();
view.SetAchievementText(text);
SetScript(view, scriptList);
}
private ShopHistoryItemView CreateItemView()
{
var view = Instantiate(historyPrefab, historyTarget);
isOdd = !isOdd;
view.SetOddBG(isOdd);
return view;
}
private static void SetScript(ShopHistoryItemView view, List<BrotherScriptData> scriptList)
{
if (scriptList.Count <= 0)
{
view.SetButtonAcive(false);
return;
}
view.PlayButton.ThrottleFirst(TimeSpan.FromSeconds(1f)).Subscribe(_ =>
{
LocalCacheManager.Save(BrotherConversation.ScriptDataTag, scriptList);
TransitionManager.Instance.LoadSceneAdditive(GameScenes.Conversation);
}).AddTo(view);
}
}

View File

@ -5,16 +5,21 @@ using UnityEngine.UI;
public class ShopHistoryItemView : MonoBehaviour
{
private static readonly string levelTextFormat = "Lv.{0} ";
private static readonly string levelTextFormat = "Lv.{0} {1}";
[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, bool withoutLevelText)
public void SetData(ShopLevelData levelData)
{
achievementText.text = (withoutLevelText ? "" : String.Format(levelTextFormat, levelData.shopLevel)) + levelData.Achievement;
SetAchievementText(String.Format(levelTextFormat, levelData.shopLevel, levelData.Achievement));
}
public void SetAchievementText(string text)
{
achievementText.text = $"  {text}";
}
public void SetUnreleased(bool active)

View File

@ -18,6 +18,10 @@ public static class Const {
public static readonly int NotSetMaterialId = 0;
public static readonly string RedColorString = "#fb6346";
public static readonly int DailyMissionResetOffset = 0;
public static readonly int[] MainTutorial = { 1, 10, 3, 11, 4 };
public static readonly int[] FieldTutorial = { 5, 12, 6 };
public static readonly int[] ShoppingTutorial = { 7, 13, 8};
public static readonly int[] ManagementTutorial = { 9 };
// tag
public static readonly string GameDataTag = "GameData";