畑強化周り追加
This commit is contained in:
parent
52381b065f
commit
559162dc8a
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,62 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using UniRx;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class FacilityExpantion : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private GameObject content;
|
||||||
|
[SerializeField] private Button menuButton;
|
||||||
|
[SerializeField] private Button closeButton;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
content.transform.parent.gameObject.SetActive(false);
|
||||||
|
menuButton.OnClickAsObservable().Subscribe(_ =>
|
||||||
|
{
|
||||||
|
content.transform.parent.gameObject.SetActive(true);
|
||||||
|
});
|
||||||
|
closeButton.OnClickAsObservable().Subscribe(_ =>
|
||||||
|
{
|
||||||
|
content.transform.parent.gameObject.SetActive(false);
|
||||||
|
});
|
||||||
|
// 設備一覧を表示
|
||||||
|
var items = content.GetComponentsInChildren<FacilityExpantionItem>();
|
||||||
|
// 適用できるかどうか判定
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
if (!GameDataManager.GameData.PlantLineTypes.Exists(x => x.type == item.Type))
|
||||||
|
{
|
||||||
|
item.SetItem(false, CornFieldRank.Rank1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
item.SetItem(true, GameDataManager.GameData.PlantLineTypes.First(x => x.type == item.Type).level);
|
||||||
|
item.ClickObservable.Subscribe(_ =>
|
||||||
|
{
|
||||||
|
// 購入時コイン比較後、コイン減算(ここコイン増加と処理がかぶるとややこしい(Batchとかで処理するといいかも
|
||||||
|
// 購入した設備はセーブする(設備ごとの処理int増やすなど
|
||||||
|
}).AddTo(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetPrice(bool hasField, CornFieldRank level)
|
||||||
|
{
|
||||||
|
if (!hasField)
|
||||||
|
{
|
||||||
|
return 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case CornFieldRank.Rank1:
|
||||||
|
return 500;
|
||||||
|
case CornFieldRank.Rank2:
|
||||||
|
return 500;
|
||||||
|
case CornFieldRank.Rank3:
|
||||||
|
return 500;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(level), level, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2737c6833764451799b01f31c062873d
|
||||||
|
timeCreated: 1627964670
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
using System;
|
||||||
|
using UniRx;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class FacilityExpantionItem : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private PlantLineType type;
|
||||||
|
[SerializeField] private Text text;
|
||||||
|
[SerializeField] private Text buttonText;
|
||||||
|
[SerializeField] private Button button;
|
||||||
|
public PlantLineType Type => type;
|
||||||
|
public IObservable<Unit> ClickObservable => button.OnClickAsObservable();
|
||||||
|
private readonly ReactiveProperty<bool> isAvailable = new ReactiveProperty<bool>();
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
isAvailable.AddTo(this);
|
||||||
|
isAvailable.SubscribeToInteractable(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetItem(bool hasField, CornFieldRank level)
|
||||||
|
{
|
||||||
|
if (hasField)
|
||||||
|
{
|
||||||
|
// 強化
|
||||||
|
buttonText.text = GetButtonText(level);
|
||||||
|
text.text = GetLevelUpText(level);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 畑の拡張
|
||||||
|
buttonText.text = $"購入";
|
||||||
|
text.text = $"畑を拡張します\n収穫できる株が4つ増えます";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetCoin(int coin)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetButtonText(CornFieldRank level)
|
||||||
|
{
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case CornFieldRank.Rank1:
|
||||||
|
case CornFieldRank.Rank2:
|
||||||
|
case CornFieldRank.Rank3:
|
||||||
|
return $"購入";
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(level), level, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetLevelUpText(CornFieldRank level)
|
||||||
|
{
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case CornFieldRank.Rank1:
|
||||||
|
return $"畑の質を強化\nx1 -> x2";
|
||||||
|
case CornFieldRank.Rank2:
|
||||||
|
return $"畑の質を強化\nx2 -> x3";
|
||||||
|
case CornFieldRank.Rank3:
|
||||||
|
return $"最大値です";
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(level), level, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 902f2e4f44b64ff59cc3aca9a5ff89e5
|
||||||
|
timeCreated: 1627970679
|
||||||
Loading…
Reference in New Issue