add customize 読み込みとview
This commit is contained in:
parent
993456972b
commit
d5ce642d03
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace MyGame.Scenes.marketing.Scripts
|
||||
{
|
||||
public class ButtonOnOff : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button button;
|
||||
[SerializeField] private GameObject onObject;
|
||||
[SerializeField] private GameObject offObject;
|
||||
public IObservable<Unit> OnClickObservable => button.OnClickAsObservable().TakeUntilDestroy(this);
|
||||
|
||||
public void SetActive(bool active)
|
||||
{
|
||||
onObject.SetActive(active);
|
||||
offObject.SetActive(!active);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 24f017f833cd4fb984accf667ea61c9e
|
||||
timeCreated: 1652183474
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace MyGame.Scenes.marketing.Scripts
|
||||
{
|
||||
public class MarketView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform signBoardTarget;
|
||||
[SerializeField] private Transform decoration1Target;
|
||||
[SerializeField] private Transform cartTarget;
|
||||
[SerializeField] private Transform stockTarget;
|
||||
[SerializeField] private Transform decoration2Target;
|
||||
[SerializeField] private Transform category6Target;
|
||||
|
||||
public void SetItem(ShopCustomizeData customizeData)
|
||||
{
|
||||
var target = GetTarget(customizeData.Category);
|
||||
target.DestroyAllChildrens();
|
||||
Instantiate(customizeData.GetPrefab(), target);
|
||||
}
|
||||
|
||||
private Transform GetTarget(ShopCustomizeCategory category)
|
||||
{
|
||||
switch (category)
|
||||
{
|
||||
case ShopCustomizeCategory.Category1:
|
||||
return signBoardTarget;
|
||||
case ShopCustomizeCategory.Category2:
|
||||
return decoration1Target;
|
||||
case ShopCustomizeCategory.Category3:
|
||||
return cartTarget;
|
||||
case ShopCustomizeCategory.Category4:
|
||||
return stockTarget;
|
||||
case ShopCustomizeCategory.Category5:
|
||||
return decoration2Target;
|
||||
case ShopCustomizeCategory.Category6:
|
||||
return category6Target;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5bfa266420af43d6acc01f297b04ba13
|
||||
timeCreated: 1652255004
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MyGame.Scenes.marketing.Scripts
|
||||
{
|
||||
public class ShopCustomize : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private MarketView marketView;
|
||||
[SerializeField] private ShopCustomizeView customizeView;
|
||||
[SerializeField] private ShopCustomizeSelector customizeSelector;
|
||||
private void Start()
|
||||
{
|
||||
var gameData = GameDataManager.GameData;
|
||||
var customizeDataList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopCustomizeData>(Const.ShopCustomizeDataSheet);
|
||||
var customizeLevelList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopCustomizeLevelData>(Const.ShopCustomizeLevelDataSheet);
|
||||
var customizeBonusList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopCustomizeBonusData>(Const.ShopCustomizeBonusDataSheet);
|
||||
|
||||
customizeView.SetLevel(gameData.ShopCustomizeLevel);
|
||||
customizeView.OnCloseObservable.Subscribe(_ =>
|
||||
{
|
||||
// unload scene
|
||||
}).AddTo(this);
|
||||
customizeView.OnClickInfoObservable.Subscribe(_ =>
|
||||
{
|
||||
// info dialog
|
||||
}).AddTo(this);
|
||||
customizeSelector.Initialize();
|
||||
// カード生成
|
||||
var categories = (ShopCustomizeCategory[])Enum.GetValues(typeof(ShopCustomizeCategory));
|
||||
foreach (var category in categories)
|
||||
{
|
||||
var list = customizeDataList.Where(data => data.Category == category).ToList();
|
||||
var selectedId = gameData.ShopCustomizeSettings.GetSetting(category);
|
||||
ShopCustomizeItem selectedItem = null;
|
||||
foreach (var customizeData in list)
|
||||
{
|
||||
var item = customizeSelector.GenerateItem(category);
|
||||
item.SetData(customizeData);
|
||||
// 現在設定しているのアイテムを選択
|
||||
if (customizeData.id == selectedId)
|
||||
{
|
||||
selectedItem = item;
|
||||
}
|
||||
if (gameData.ShopCustomizeLevel > customizeData.level)
|
||||
{
|
||||
item.SetState(ShopCustomizeItemState.Lock);
|
||||
}
|
||||
if (gameData.ShopCustomizeMyItems.Contains(customizeData.id))
|
||||
{
|
||||
item.SetState(ShopCustomizeItemState.Purchased);
|
||||
}
|
||||
item.SelectObservable.Subscribe(_ =>
|
||||
{
|
||||
selectedItem.SetState(ShopCustomizeItemState.Purchased);
|
||||
selectedItem = item;
|
||||
item.SetState(ShopCustomizeItemState.Selected);
|
||||
marketView.SetItem(customizeData);
|
||||
}).AddTo(this);
|
||||
item.DetailObservable.Subscribe(_ =>
|
||||
{
|
||||
// item detail dialog
|
||||
}).AddTo(this);
|
||||
item.PurchaseObservable.Subscribe(_ =>
|
||||
{
|
||||
// purchase dialog
|
||||
item.SetState(ShopCustomizeItemState.Purchased);
|
||||
}).AddTo(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d61792503dd74c7496bad02d10fed632
|
||||
timeCreated: 1652170481
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace MyGame.Scenes.marketing.Scripts
|
||||
{
|
||||
public class ShopCustomizeSelector : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private ButtonOnOff signBoardButton;
|
||||
[SerializeField] private ButtonOnOff decoration1Button;
|
||||
[SerializeField] private ButtonOnOff cartButton;
|
||||
[SerializeField] private ButtonOnOff stockButton;
|
||||
[SerializeField] private ButtonOnOff decoration2Button;
|
||||
[SerializeField] private ButtonOnOff category6Button;
|
||||
[SerializeField] private ShopCustomizeItem itemPrefab;
|
||||
[SerializeField] private Transform listPrefab;
|
||||
[SerializeField] private ScrollRect scrollRect;
|
||||
|
||||
private readonly Dictionary<ShopCustomizeCategory, Transform> targetDict = new Dictionary<ShopCustomizeCategory, Transform>();
|
||||
private readonly Dictionary<ShopCustomizeCategory, ButtonOnOff> buttonDict = new Dictionary<ShopCustomizeCategory, ButtonOnOff>();
|
||||
private readonly CompositeDisposable initializeCompositeDisposable = new CompositeDisposable();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
var content = scrollRect.content;
|
||||
content.DestroyAllChildrens();
|
||||
var categories = (ShopCustomizeCategory[])Enum.GetValues(typeof(ShopCustomizeCategory));
|
||||
foreach (var category in categories)
|
||||
{
|
||||
targetDict.Add(category, Instantiate(listPrefab, content));
|
||||
}
|
||||
buttonDict.Add(ShopCustomizeCategory.Category1, signBoardButton);
|
||||
buttonDict.Add(ShopCustomizeCategory.Category2, decoration1Button);
|
||||
buttonDict.Add(ShopCustomizeCategory.Category3, cartButton);
|
||||
buttonDict.Add(ShopCustomizeCategory.Category4, stockButton);
|
||||
buttonDict.Add(ShopCustomizeCategory.Category5, decoration2Button);
|
||||
// buttonDict.Add(ShopCustomizeCategory.Category6, category6Button);
|
||||
|
||||
initializeCompositeDisposable.Dispose();
|
||||
buttonDict.Select(pair => pair.Value.OnClickObservable.Select(_ => pair.Key))
|
||||
.Merge()
|
||||
.ThrottleFirst(TimeSpan.FromSeconds(.2f))
|
||||
.Subscribe(ChangeCategory).AddTo(initializeCompositeDisposable);
|
||||
}
|
||||
|
||||
public ShopCustomizeItem GenerateItem(ShopCustomizeCategory category)
|
||||
{
|
||||
return Instantiate(itemPrefab, targetDict[category]);
|
||||
}
|
||||
|
||||
public void SetScroll()
|
||||
{
|
||||
// 描画計算
|
||||
// shopInfoObject.SetActive(true);
|
||||
// recordObject.SetActive(true);
|
||||
Observable.TimerFrame(0, FrameCountType.EndOfFrame).Subscribe(_ =>
|
||||
{
|
||||
// LayoutRebuilder.ForceRebuildLayoutImmediate(recordObject.transform as RectTransform);
|
||||
// LayoutRebuilder.ForceRebuildLayoutImmediate(shopInfoObject.transform as RectTransform);
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private void ChangeCategory(ShopCustomizeCategory category)
|
||||
{
|
||||
foreach (var pair in targetDict)
|
||||
{
|
||||
pair.Value.gameObject.SetActive(pair.Key == category);
|
||||
buttonDict[pair.Key]?.SetActive(pair.Key == category);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ec03eac508f44666a880fdf0d030b6c5
|
||||
timeCreated: 1652170481
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace MyGame.Scenes.marketing.Scripts
|
||||
{
|
||||
public class ShopCustomizeView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Text levelText;
|
||||
[SerializeField] private Button closeButton;
|
||||
[SerializeField] private Button infoButton;
|
||||
|
||||
public IObservable<Unit> OnCloseObservable => closeButton.OnClickAsObservable().TakeUntilDestroy(this);
|
||||
public IObservable<Unit> OnClickInfoObservable => infoButton.OnClickAsObservable().TakeUntilDestroy(this);
|
||||
|
||||
public void SetLevel(int value)
|
||||
{
|
||||
levelText.text = $"Lv.{value}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4d5f36a2319942d39435ee1478359cda
|
||||
timeCreated: 1652170481
|
||||
Loading…
Reference in New Issue