カスタマイズ機能 ハイライト実装

This commit is contained in:
kimura 2022-05-13 14:20:03 +09:00
parent 37a2199cb2
commit 0fbf6f33f9
2 changed files with 23 additions and 4 deletions

View File

@ -28,7 +28,14 @@ namespace MyGame.Scenes.marketing.Scripts
{ {
ShopCustomizeInfoDialog.ShowDialog(); ShopCustomizeInfoDialog.ShowDialog();
}).AddTo(this); }).AddTo(this);
customizeSelector.Initialize();
customizeSelector.Initialize(ShopCustomizeCategory.Category1);
customizeSelector.SelecedCategory.Pairwise().Subscribe(x =>
{
marketView.SetHighlight(x.Previous, false);
marketView.SetHighlight(x.Current, true);
}).AddTo(this);
// カード生成 // カード生成
var categories = (ShopCustomizeCategory[])Enum.GetValues(typeof(ShopCustomizeCategory)); var categories = (ShopCustomizeCategory[])Enum.GetValues(typeof(ShopCustomizeCategory));
foreach (var category in categories) foreach (var category in categories)
@ -65,6 +72,10 @@ namespace MyGame.Scenes.marketing.Scripts
item.SetState(ShopCustomizeItemState.Selected); item.SetState(ShopCustomizeItemState.Selected);
gameData.ShopCustomizeSettings.SetSetting(customizeData); gameData.ShopCustomizeSettings.SetSetting(customizeData);
marketView.SetItem(customizeData); marketView.SetItem(customizeData);
if (customizeSelector.SelecedCategory.Value == category)
{
marketView.SetHighlight(category, true);
}
}).AddTo(this); }).AddTo(this);
item.DetailObservable.Subscribe(_ => item.DetailObservable.Subscribe(_ =>
{ {

View File

@ -19,11 +19,18 @@ namespace MyGame.Scenes.marketing.Scripts
[SerializeField] private Transform listPrefab; [SerializeField] private Transform listPrefab;
[SerializeField] private ScrollRect scrollRect; [SerializeField] private ScrollRect scrollRect;
public IReadOnlyReactiveProperty<ShopCustomizeCategory> SelecedCategory => selectedCategory;
private readonly ReactiveProperty<ShopCustomizeCategory> selectedCategory = new ReactiveProperty<ShopCustomizeCategory>();
private readonly Dictionary<ShopCustomizeCategory, Transform> targetDict = new Dictionary<ShopCustomizeCategory, Transform>(); private readonly Dictionary<ShopCustomizeCategory, Transform> targetDict = new Dictionary<ShopCustomizeCategory, Transform>();
private readonly Dictionary<ShopCustomizeCategory, ButtonOnOff> buttonDict = new Dictionary<ShopCustomizeCategory, ButtonOnOff>(); private readonly Dictionary<ShopCustomizeCategory, ButtonOnOff> buttonDict = new Dictionary<ShopCustomizeCategory, ButtonOnOff>();
private readonly CompositeDisposable initializeCompositeDisposable = new CompositeDisposable(); private readonly CompositeDisposable initializeCompositeDisposable = new CompositeDisposable();
public void Initialize() private void Start()
{
selectedCategory.AddTo(this);
}
public void Initialize(ShopCustomizeCategory firstSelectCategory)
{ {
var viewport = scrollRect.viewport; var viewport = scrollRect.viewport;
viewport.DestroyAllChildrens(); viewport.DestroyAllChildrens();
@ -42,10 +49,11 @@ namespace MyGame.Scenes.marketing.Scripts
initializeCompositeDisposable.Clear(); initializeCompositeDisposable.Clear();
buttonDict.Select(pair => pair.Value.OnClickObservable.Select(_ => pair.Key)) buttonDict.Select(pair => pair.Value.OnClickObservable.Select(_ => pair.Key))
.Merge() .Merge()
.StartWith(ShopCustomizeCategory.Category1) .StartWith(firstSelectCategory)
.ThrottleFirst(TimeSpan.FromSeconds(.2f)) .ThrottleFirst(TimeSpan.FromSeconds(.2f))
.Subscribe(ChangeCategory) .Subscribe(x => selectedCategory.Value = x)
.AddTo(initializeCompositeDisposable); .AddTo(initializeCompositeDisposable);
selectedCategory.Subscribe(ChangeCategory).AddTo(this);
} }
public ShopCustomizeItem GenerateItem(ShopCustomizeCategory category) public ShopCustomizeItem GenerateItem(ShopCustomizeCategory category)