fix scroll game view
This commit is contained in:
parent
71efba8db6
commit
4f5b4461d4
|
|
@ -9,37 +9,12 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
{
|
{
|
||||||
[SerializeField] private Text text;
|
[SerializeField] private Text text;
|
||||||
[SerializeField] private Text timeText;
|
[SerializeField] private Text timeText;
|
||||||
private readonly ReactiveProperty<int> itemCount = new ReactiveProperty<int>();
|
|
||||||
private readonly ReactiveProperty<float> timeCount = new ReactiveProperty<float>();
|
|
||||||
|
|
||||||
private void Start()
|
public void ChangeItemCount(int value) => text.text = value.ToString();
|
||||||
{
|
|
||||||
itemCount.AddTo(this);
|
|
||||||
timeCount.AddTo(this);
|
|
||||||
itemCount.Subscribe(x =>
|
|
||||||
{
|
|
||||||
text.text = $"{x}";
|
|
||||||
}).AddTo(this);
|
|
||||||
timeCount.Subscribe(x =>
|
|
||||||
{
|
|
||||||
timeText.text = $"のこり{x:0}秒";
|
|
||||||
}).AddTo(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetView()
|
|
||||||
{
|
|
||||||
itemCount.Value = 0;
|
|
||||||
timeCount.Value = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddCount(int value)
|
|
||||||
{
|
|
||||||
itemCount.Value += value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangeTimeCount(float newTime)
|
public void ChangeTimeCount(float newTime)
|
||||||
{
|
{
|
||||||
timeCount.Value = newTime;
|
timeText.text = $"{newTime:0}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
using System;
|
||||||
|
using UniRx;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
|
@ -5,14 +7,36 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
{
|
{
|
||||||
public class StageSelectItemView : MonoBehaviour
|
public class StageSelectItemView : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private Text stageName;
|
// [SerializeField] private Text stageName;
|
||||||
[SerializeField] private Text stageHiScore;
|
[SerializeField] private Text stageHiScore;
|
||||||
[SerializeField] private Button button;
|
[SerializeField] private Button button;
|
||||||
|
[SerializeField] private GameObject lockObject;
|
||||||
|
private readonly IntReactiveProperty hiScore = new IntReactiveProperty();
|
||||||
|
private int needScore;
|
||||||
|
|
||||||
public void SetStageName(string text) => stageName.text = text;
|
private void Start()
|
||||||
|
{
|
||||||
|
hiScore.AddTo(this);
|
||||||
|
hiScore.Subscribe(val =>
|
||||||
|
{
|
||||||
|
stageHiScore.text = $"ハイスコア:{val}";
|
||||||
|
}).AddTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetStageHiScore(int num) => stageHiScore.text = num.ToString();
|
public void SetStageHiScore(int num) => hiScore.Value = num;
|
||||||
|
|
||||||
public Button Button => button;
|
public IObservable<Unit> OnClick => button.OnClickAsObservable().TakeUntilDestroy(this);
|
||||||
|
|
||||||
|
public void SetData(ScrollGameStageData stageData)
|
||||||
|
{
|
||||||
|
needScore = stageData.needScore;
|
||||||
|
// stageName.text = stageData.id.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetStageActive(bool active)
|
||||||
|
{
|
||||||
|
button.enabled = active;
|
||||||
|
lockObject.SetActive(!active);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
|
@ -5,15 +7,40 @@ namespace MyGame.Scenes.MiniGame.Scripts
|
||||||
{
|
{
|
||||||
public class StageSelectView : MonoBehaviour
|
public class StageSelectView : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private Text nameText;
|
[SerializeField] private Text titleText;
|
||||||
[SerializeField] private ScrollRect scrollRect;
|
[SerializeField] private Text itemText;
|
||||||
|
[SerializeField] private Text recipeText;
|
||||||
|
// [SerializeField] private Text itemNeedScoreText;
|
||||||
|
[SerializeField] private Text recipeNeedScoreText;
|
||||||
[SerializeField] private Text totalScore;
|
[SerializeField] private Text totalScore;
|
||||||
[SerializeField] private StageSelectItemView itemViewPrefab;
|
[SerializeField] private GameObject recipeObject;
|
||||||
|
[SerializeField] private ScrollRect scrollRect;
|
||||||
|
[SerializeField] private StageSelectItemView[] itemViewList;
|
||||||
|
|
||||||
public ScrollRect ScrollRect => scrollRect;
|
public ScrollRect ScrollRect => scrollRect;
|
||||||
|
public StageSelectItemView[] ItemViewList => itemViewList;
|
||||||
|
|
||||||
public void SetName(string text) => nameText.text = text;
|
public void SetScore(int num) => totalScore.text = $"累計スコア:{num}";
|
||||||
|
|
||||||
public void SetScore(int num) => totalScore.text = num.ToString();
|
public void SetPlaceData(ScrollGamePlaceData[] placeDataList)
|
||||||
|
{
|
||||||
|
// titleText.text = placeDataList[0].placeId.ToString();
|
||||||
|
var shopDataList = SpreadsheetDataManager.Instance.GetBaseDataList<ShopData>(Const.ShopDataSheet);
|
||||||
|
var productDataList = SpreadsheetDataManager.Instance.GetBaseDataList<ProductData>(Const.ProductDataSheet);
|
||||||
|
foreach (var placeData in placeDataList)
|
||||||
|
{
|
||||||
|
if (placeData.itemId != 0)
|
||||||
|
{
|
||||||
|
var shopData = shopDataList.FirstOrDefault(data => data.itemId == placeData.itemId && data.Category == ItemCategory.Material);
|
||||||
|
itemText.text = $"貰える材料: {shopData.Name}";
|
||||||
|
// itemNeedScoreText.text = placeData.needScore.ToString();
|
||||||
|
}else if (placeData.recipeId != 0)
|
||||||
|
{
|
||||||
|
var productData = productDataList.FirstOrDefault(data => data.id == placeData.recipeId);
|
||||||
|
recipeText.text = $"達成報酬: {productData.Name}";
|
||||||
|
recipeNeedScoreText.text = $"必要スコア:{placeData.needScore}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue