時短ボタンの購読場所変更/ リファクタ
This commit is contained in:
parent
231115b19a
commit
2ac4eb8cef
|
|
@ -102,11 +102,39 @@ public class CornField : MonoBehaviour
|
||||||
|
|
||||||
SetCornField();
|
SetCornField();
|
||||||
|
|
||||||
|
// 強化ボタン
|
||||||
upgradeButton.OnClickAsObservable().ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
upgradeButton.OnClickAsObservable().ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
||||||
{
|
{
|
||||||
CornFieldReinforcement.ShowDialog(() => SetCornField());
|
CornFieldReinforcement.ShowDialog(() => SetCornField());
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
|
||||||
|
// 時短ボタン
|
||||||
|
promoteGrowthButton.OnClickAsObservable().Subscribe(_ =>
|
||||||
|
{
|
||||||
|
VibrationManager.Instance.PlayVibrationOnce();
|
||||||
|
foreach (var plantLine in plantLines)
|
||||||
|
{
|
||||||
|
if (!(gameData.PlantLineDataList.FirstOrDefault(data => data.Type == plantLine.LineName) is PlantLineData plantLineData))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < plantLine.Seedlings.Count; i++)
|
||||||
|
{
|
||||||
|
if (Random.Range(0, 2) == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var progressData = gameData.SeedlingDataList.First(data => data.type == plantLineData.Type).Seedlings[i];
|
||||||
|
progressData.FirstTime = progressData.FirstTime.AddSeconds(-1);
|
||||||
|
plantLine.Seedlings[i].PromoteGrowth(progressData.FirstTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 設定のセーブ
|
||||||
|
GameDataManager.SaveGameData();
|
||||||
|
}).AddTo(this);
|
||||||
|
|
||||||
|
// 肥料ボタン
|
||||||
fertilizerButtonView.RewardButton.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
fertilizerButtonView.RewardButton.ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
||||||
{
|
{
|
||||||
GetRewardDialog.ShowCornFieldDialog(() =>
|
GetRewardDialog.ShowCornFieldDialog(() =>
|
||||||
|
|
@ -132,24 +160,23 @@ public class CornField : MonoBehaviour
|
||||||
// 既存の株は成長済みにする
|
// 既存の株は成長済みにする
|
||||||
foreach (var plantLine in plantLines)
|
foreach (var plantLine in plantLines)
|
||||||
{
|
{
|
||||||
if (gameData.PlantLineDataList.FirstOrDefault(data => data.Type == plantLine.LineName) is PlantLineData plantLineData)
|
if (!(gameData.PlantLineDataList.FirstOrDefault(data => data.Type == plantLine.LineName) is PlantLineData plantLineData))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < plantLine.Seedlings.Count; i++)
|
continue;
|
||||||
{
|
}
|
||||||
var progressData = gameData.SeedlingDataList.First(data => data.type == plantLineData.Type).Seedlings[i];
|
for (int i = 0; i < plantLine.Seedlings.Count; i++)
|
||||||
var seedling = plantLine.Seedlings[i];
|
{
|
||||||
progressData.FirstTime = progressData.FirstTime.AddSeconds(-maxPeriod);
|
var progressData = gameData.SeedlingDataList.First(data => data.type == plantLineData.Type).Seedlings[i];
|
||||||
seedling.PromoteGrowth(progressData.FirstTime);
|
progressData.FirstTime = progressData.FirstTime.AddSeconds(-maxPeriod);
|
||||||
// エフェクト出すだけ
|
plantLine.Seedlings[i].PromoteGrowth(progressData.FirstTime);
|
||||||
// push.Subscribe(unit =>
|
// エフェクト出すだけ
|
||||||
// {
|
// push.Subscribe(unit =>
|
||||||
// if (Random.value < .5f)
|
// {
|
||||||
// {
|
// if (Random.value < .5f)
|
||||||
// seedling.PromoteGrowth(progressData.FirstTime);
|
// {
|
||||||
// }
|
// seedling.PromoteGrowth(progressData.FirstTime);
|
||||||
// }).AddTo(this);
|
// }
|
||||||
|
// }).AddTo(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Observable.Timer(TimeSpan.FromSeconds(1f), TimeSpan.FromSeconds(1f))
|
Observable.Timer(TimeSpan.FromSeconds(1f), TimeSpan.FromSeconds(1f))
|
||||||
|
|
@ -256,7 +283,7 @@ public class CornField : MonoBehaviour
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCornField(bool useFertilizer = false)
|
private void SetCornField(bool useFertilizer = false)
|
||||||
{
|
{
|
||||||
compositeDisposable.Clear();
|
compositeDisposable.Clear();
|
||||||
var gameData = GameDataManager.GameData;
|
var gameData = GameDataManager.GameData;
|
||||||
|
|
@ -369,22 +396,22 @@ public class CornField : MonoBehaviour
|
||||||
|
|
||||||
// 新しい苗
|
// 新しい苗
|
||||||
var newGene = GenerateSeedlingGene(plantLineData.Level);
|
var newGene = GenerateSeedlingGene(plantLineData.Level);
|
||||||
#if DEVELOPMENT_BUILD || UNITY_EDITOR
|
|
||||||
if (UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "DebugFastGrowing", false))
|
|
||||||
{
|
|
||||||
newGene.Period = newGene.Period / 3;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (useFertilizer)
|
if (useFertilizer)
|
||||||
{
|
{
|
||||||
newGene.Period = Random.Range(2, 4);
|
newGene.Period = Random.Range(2, 4);
|
||||||
}
|
}
|
||||||
seedling.SetSeedlingGene(newGene.FirstTime, newGene.Period, newGene.Level);
|
|
||||||
progressData.Level = newGene.Level;
|
progressData.Level = newGene.Level;
|
||||||
progressData.Period = newGene.Period;
|
progressData.Period = newGene.Period;
|
||||||
progressData.FirstTime = newGene.FirstTime;
|
progressData.FirstTime = newGene.FirstTime;
|
||||||
GameDataManager.SaveGameData();
|
GameDataManager.SaveGameData();
|
||||||
|
|
||||||
|
seedling.SetSeedlingGene(newGene.FirstTime, newGene.Period, newGene.Level);
|
||||||
|
#if DEVELOPMENT_BUILD || UNITY_EDITOR
|
||||||
|
if (UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "DebugFastGrowing", false))
|
||||||
|
{
|
||||||
|
seedling.SetSeedlingGene(newGene.FirstTime, newGene.Period / 3, newGene.Level);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// チュートリアル時新しい苗を隠す
|
// チュートリアル時新しい苗を隠す
|
||||||
if (gameData.isFirstPlay)
|
if (gameData.isFirstPlay)
|
||||||
{
|
{
|
||||||
|
|
@ -394,32 +421,6 @@ public class CornField : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 時短ボタン
|
|
||||||
promoteGrowthButton.OnClickAsObservable().Subscribe(_ =>
|
|
||||||
{
|
|
||||||
VibrationManager.Instance.PlayVibrationOnce();
|
|
||||||
foreach (var plantLine in plantLines)
|
|
||||||
{
|
|
||||||
if (gameData.PlantLineDataList.FirstOrDefault(data => data.Type == plantLine.LineName) is PlantLineData plantLineData)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < plantLine.Seedlings.Count; i++)
|
|
||||||
{
|
|
||||||
if (Random.Range(0, 2) == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var progressData = gameData.SeedlingDataList.First(data => data.type == plantLineData.Type).Seedlings[i];
|
|
||||||
var seedling = plantLine.Seedlings[i];
|
|
||||||
progressData.FirstTime = progressData.FirstTime.AddSeconds(-1);
|
|
||||||
seedling.PromoteGrowth(progressData.FirstTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 設定のセーブ
|
|
||||||
GameDataManager.SaveGameData();
|
|
||||||
}).AddTo(compositeDisposable);
|
|
||||||
|
|
||||||
// 強化ボタン通知
|
// 強化ボタン通知
|
||||||
var upgradePrice = int.MaxValue;
|
var upgradePrice = int.MaxValue;
|
||||||
if (fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.Machine && x.level == gameData.MachineLevel + 1)?.price is int nextMachinePrice)
|
if (fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.Machine && x.level == gameData.MachineLevel + 1)?.price is int nextMachinePrice)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue