畑強化データからの読み込みに対応
This commit is contained in:
parent
62856fe7e8
commit
5a8fb41fcb
|
|
@ -57,6 +57,8 @@ public class CornField : MonoBehaviour
|
||||||
counterView.Initialize(gameData.cornSeed);
|
counterView.Initialize(gameData.cornSeed);
|
||||||
SetData();
|
SetData();
|
||||||
|
|
||||||
|
var fieldData = SpreadsheetDataManager.Instance.GetBaseDataList<FieldUpgradeData>(Const.FieldUpgradeDataSheet);
|
||||||
|
|
||||||
// 畑リセット
|
// 畑リセット
|
||||||
foreach (var line in plantLines)
|
foreach (var line in plantLines)
|
||||||
{
|
{
|
||||||
|
|
@ -146,8 +148,8 @@ public class CornField : MonoBehaviour
|
||||||
seedling.Harvested.Subscribe(_ =>
|
seedling.Harvested.Subscribe(_ =>
|
||||||
{
|
{
|
||||||
VibrationManager.Instance.PlayVibrationOnce();
|
VibrationManager.Instance.PlayVibrationOnce();
|
||||||
var harvestCount = GetHarvestCount(lineData.Seedlings[index].Level);
|
var harvestCount = fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.FieldCenter && x.level == (int)lineData.Seedlings[index].Level)?.harvested ?? 1;
|
||||||
var harvestedCorn = GetHarvestedCornCount(gameData.MachineLevel);
|
var harvestedCorn = fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.Machine && x.level == gameData.MachineLevel)?.harvested ?? 20;
|
||||||
gameData.cornSeed += harvestedCorn * harvestCount;
|
gameData.cornSeed += harvestedCorn * harvestCount;
|
||||||
var seedlingTransform = seedling.transform;
|
var seedlingTransform = seedling.transform;
|
||||||
for (int j = 0; j < harvestCount; j++)
|
for (int j = 0; j < harvestCount; j++)
|
||||||
|
|
@ -245,40 +247,4 @@ public class CornField : MonoBehaviour
|
||||||
{
|
{
|
||||||
return new SeedlingData(DateTime.Now, Random.Range(minPeriod, maxPeriod + 1), level);
|
return new SeedlingData(DateTime.Now, Random.Range(minPeriod, maxPeriod + 1), level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetHarvestCount(CornFieldRank rank)
|
|
||||||
{
|
|
||||||
switch (rank)
|
|
||||||
{
|
|
||||||
case CornFieldRank.Rank1:
|
|
||||||
return 1;
|
|
||||||
case CornFieldRank.Rank2:
|
|
||||||
return 2;
|
|
||||||
case CornFieldRank.Rank3:
|
|
||||||
return 3;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(rank), rank, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int GetHarvestedCornCount(int level)
|
|
||||||
{
|
|
||||||
switch (level)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return 20;
|
|
||||||
case 2:
|
|
||||||
return 25;
|
|
||||||
case 3:
|
|
||||||
return 30;
|
|
||||||
case 4:
|
|
||||||
return 35;
|
|
||||||
case 5:
|
|
||||||
return 40;
|
|
||||||
case 6:
|
|
||||||
return 45;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(level), level, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,26 +18,55 @@ public class CornFieldReinforcement : MonoBehaviour
|
||||||
TransitionManager.Instance.UnloadScene(GameScenes.Reinforcement);
|
TransitionManager.Instance.UnloadScene(GameScenes.Reinforcement);
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
var gameData = GameDataManager.GameData;
|
var gameData = GameDataManager.GameData;
|
||||||
var price = 100;
|
var fieldData = SpreadsheetDataManager.Instance.GetBaseDataList<FieldUpgradeData>(Const.FieldUpgradeDataSheet);
|
||||||
|
|
||||||
foreach (var view in reinforcementViews)
|
foreach (var view in reinforcementViews)
|
||||||
{
|
{
|
||||||
if (gameData.PlantLineDataList.FirstOrDefault(x => x.Type == view.LineType) is PlantLineData lineData)
|
if (gameData.PlantLineDataList.FirstOrDefault(x => x.Type == view.LineType) is PlantLineData lineData)
|
||||||
{
|
{
|
||||||
view.SetReinforcement(lineData, price);
|
// Max
|
||||||
|
if (lineData.Level == CornFieldRank.Rank3)
|
||||||
|
{
|
||||||
|
view.SetButtonActive(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var nextHarvestPrice = fieldData.FirstOrDefault(x => x.Type == x.PlantTypeToUpgradeType(lineData.Type) && x.level == (int)GetNextRank(lineData.Level))?.price ?? 1;
|
||||||
|
view.SetButtonActive(nextHarvestPrice <= CoinManager.Instance.OwnCoin);
|
||||||
|
view.SetReinforcement(lineData, nextHarvestPrice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var price = fieldData.FirstOrDefault(x => x.Type == x.PlantTypeToUpgradeType(view.LineType) && x.level == (int)CornFieldRank.Rank1)?.price ?? 1;
|
||||||
|
view.SetButtonActive(price <= CoinManager.Instance.OwnCoin);
|
||||||
view.SetRelease(price);
|
view.SetRelease(price);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
machineUpgradeView.SetData(gameData.MachineLevel, price);
|
// Max
|
||||||
}
|
var maxLevel = fieldData.Where(x => x.Type == CornFieldUpgradeType.Machine).Max(x => x.level);
|
||||||
|
if (gameData.MachineLevel == maxLevel)
|
||||||
}
|
|
||||||
|
|
||||||
public class UpgradeData
|
|
||||||
{
|
{
|
||||||
public int category;
|
machineUpgradeView.SetButtonActive(false);
|
||||||
public int price;
|
}
|
||||||
public int spec;
|
else
|
||||||
|
{
|
||||||
|
var nextMachinePrice = fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.Machine && x.level == gameData.MachineLevel + 1)?.price ?? 1;
|
||||||
|
machineUpgradeView.SetButtonActive(nextMachinePrice <= CoinManager.Instance.OwnCoin);
|
||||||
|
machineUpgradeView.SetData(gameData.MachineLevel, nextMachinePrice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CornFieldRank GetNextRank(CornFieldRank rank)
|
||||||
|
{
|
||||||
|
switch (rank)
|
||||||
|
{
|
||||||
|
case CornFieldRank.Rank1:
|
||||||
|
return CornFieldRank.Rank2;
|
||||||
|
case CornFieldRank.Rank2:
|
||||||
|
return CornFieldRank.Rank3;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(rank), rank, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UniRx;
|
using UniRx;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -40,18 +41,16 @@ public class CornFieldReinforcementView : MonoBehaviour
|
||||||
{
|
{
|
||||||
reinforcementWindow.SetActive(true);
|
reinforcementWindow.SetActive(true);
|
||||||
releaseWindow.SetActive(false);
|
releaseWindow.SetActive(false);
|
||||||
if (data.Level == CornFieldRank.Rank3)
|
var nextRank = CornFieldReinforcement.GetNextRank(data.Level);
|
||||||
{
|
var fieldData = SpreadsheetDataManager.Instance.GetBaseDataList<FieldUpgradeData>(Const.FieldUpgradeDataSheet);
|
||||||
reinforcementWindow.SetActive(false);
|
var currentHarvestCount = fieldData.FirstOrDefault(x => x.Type == x.PlantTypeToUpgradeType(data.Type) && x.level == (int)data.Level)?.harvested ?? 1;
|
||||||
disableButton.SetActive(true);
|
var nextHarvestCount = fieldData.FirstOrDefault(x => x.Type == x.PlantTypeToUpgradeType(data.Type) && x.level == (int)nextRank)?.harvested ?? 1;
|
||||||
return;
|
|
||||||
}
|
|
||||||
reinforcePriceText.text = price.ToString();
|
reinforcePriceText.text = price.ToString();
|
||||||
currentSeedling.SetSeedling(data.Level);
|
currentSeedling.SetSeedling(data.Level);
|
||||||
currentSignBoard.text = string.Format(SigbBoardFormat, CornField.GetHarvestCount(data.Level));
|
currentSignBoard.text = string.Format(SigbBoardFormat, currentHarvestCount);
|
||||||
nextSeedling.SetSeedling(GetNextRank(data.Level));
|
nextSeedling.SetSeedling(nextRank);
|
||||||
nextSignBoard.text = string.Format(SigbBoardFormat, CornField.GetHarvestCount(GetNextRank(data.Level)));
|
nextSignBoard.text = string.Format(SigbBoardFormat, nextHarvestCount);
|
||||||
reinforceText.text = string.Format(ReinforceFormat, CornField.GetHarvestCount(GetNextRank(data.Level)));
|
reinforceText.text = string.Format(ReinforceFormat, nextHarvestCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRelease(int price)
|
public void SetRelease(int price)
|
||||||
|
|
@ -62,18 +61,14 @@ public class CornFieldReinforcementView : MonoBehaviour
|
||||||
releaseText.text = string.Format(ReleaseFormat, GetPlantTypeText(lineType));
|
releaseText.text = string.Format(ReleaseFormat, GetPlantTypeText(lineType));
|
||||||
}
|
}
|
||||||
|
|
||||||
private CornFieldRank GetNextRank(CornFieldRank rank)
|
public void SetButtonActive(bool active)
|
||||||
{
|
{
|
||||||
switch (rank)
|
dialogButton.gameObject.SetActive(active);
|
||||||
{
|
dialogButton2.gameObject.SetActive(active);
|
||||||
case CornFieldRank.Rank1:
|
disableButton.SetActive(!active);
|
||||||
return CornFieldRank.Rank2;
|
disableButton2.SetActive(!active);
|
||||||
case CornFieldRank.Rank2:
|
|
||||||
return CornFieldRank.Rank3;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(rank), rank, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetPlantTypeText(PlantLineType type)
|
private string GetPlantTypeText(PlantLineType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using UniRx;
|
using UniRx;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class MachineUpgradeView : MonoBehaviour
|
public class MachineUpgradeView : MonoBehaviour
|
||||||
{
|
{
|
||||||
private static readonly string SigbBoardFormat = "x{0}";
|
private static readonly string SignBoardFormat = "x{0}";
|
||||||
[SerializeField] private Text priceText;
|
[SerializeField] private Text priceText;
|
||||||
[SerializeField] private Text currentHarvestedText;
|
[SerializeField] private Text currentHarvestedText;
|
||||||
[SerializeField] private Text nextHarvestedText;
|
[SerializeField] private Text nextHarvestedText;
|
||||||
[SerializeField] private Button dialogButton;
|
[SerializeField] private Button dialogButton;
|
||||||
[SerializeField] private GameObject disableButton;
|
[SerializeField] private GameObject disableButton;
|
||||||
private static readonly int MaxMachineLevel = 6;
|
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
|
@ -24,13 +24,17 @@ public class MachineUpgradeView : MonoBehaviour
|
||||||
|
|
||||||
public void SetData(int level, int price)
|
public void SetData(int level, int price)
|
||||||
{
|
{
|
||||||
if (level == MaxMachineLevel)
|
var fieldData = SpreadsheetDataManager.Instance.GetBaseDataList<FieldUpgradeData>(Const.FieldUpgradeDataSheet);
|
||||||
{
|
var currentHarvestedCorn = fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.Machine && x.level == level)?.harvested ?? 20;
|
||||||
disableButton.SetActive(true);
|
var nextHarvestedCorn = fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.Machine && x.level == level + 1)?.harvested ?? 20;
|
||||||
return;
|
|
||||||
}
|
|
||||||
priceText.text = price.ToString();
|
priceText.text = price.ToString();
|
||||||
currentHarvestedText.text = CornField.GetHarvestedCornCount(level).ToString();
|
currentHarvestedText.text = string.Format(SignBoardFormat, currentHarvestedCorn.ToString());
|
||||||
nextHarvestedText.text = CornField.GetHarvestedCornCount(level+1).ToString();
|
nextHarvestedText.text = string.Format(SignBoardFormat, nextHarvestedCorn.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetButtonActive(bool active)
|
||||||
|
{
|
||||||
|
dialogButton.gameObject.SetActive(active);
|
||||||
|
disableButton.SetActive(!active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue