時短ボタンの購読場所変更/ リファクタ
This commit is contained in:
parent
231115b19a
commit
2ac4eb8cef
|
|
@ -102,11 +102,39 @@ public class CornField : MonoBehaviour
|
|||
|
||||
SetCornField();
|
||||
|
||||
// 強化ボタン
|
||||
upgradeButton.OnClickAsObservable().ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
||||
{
|
||||
CornFieldReinforcement.ShowDialog(() => SetCornField());
|
||||
}).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(_ =>
|
||||
{
|
||||
GetRewardDialog.ShowCornFieldDialog(() =>
|
||||
|
|
@ -132,24 +160,23 @@ public class CornField : MonoBehaviour
|
|||
// 既存の株は成長済みにする
|
||||
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++)
|
||||
{
|
||||
var progressData = gameData.SeedlingDataList.First(data => data.type == plantLineData.Type).Seedlings[i];
|
||||
var seedling = plantLine.Seedlings[i];
|
||||
progressData.FirstTime = progressData.FirstTime.AddSeconds(-maxPeriod);
|
||||
seedling.PromoteGrowth(progressData.FirstTime);
|
||||
// エフェクト出すだけ
|
||||
// push.Subscribe(unit =>
|
||||
// {
|
||||
// if (Random.value < .5f)
|
||||
// {
|
||||
// seedling.PromoteGrowth(progressData.FirstTime);
|
||||
// }
|
||||
// }).AddTo(this);
|
||||
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < plantLine.Seedlings.Count; i++)
|
||||
{
|
||||
var progressData = gameData.SeedlingDataList.First(data => data.type == plantLineData.Type).Seedlings[i];
|
||||
progressData.FirstTime = progressData.FirstTime.AddSeconds(-maxPeriod);
|
||||
plantLine.Seedlings[i].PromoteGrowth(progressData.FirstTime);
|
||||
// エフェクト出すだけ
|
||||
// push.Subscribe(unit =>
|
||||
// {
|
||||
// if (Random.value < .5f)
|
||||
// {
|
||||
// seedling.PromoteGrowth(progressData.FirstTime);
|
||||
// }
|
||||
// }).AddTo(this);
|
||||
}
|
||||
}
|
||||
Observable.Timer(TimeSpan.FromSeconds(1f), TimeSpan.FromSeconds(1f))
|
||||
|
|
@ -256,7 +283,7 @@ public class CornField : MonoBehaviour
|
|||
}).AddTo(this);
|
||||
}
|
||||
|
||||
public void SetCornField(bool useFertilizer = false)
|
||||
private void SetCornField(bool useFertilizer = false)
|
||||
{
|
||||
compositeDisposable.Clear();
|
||||
var gameData = GameDataManager.GameData;
|
||||
|
|
@ -369,22 +396,22 @@ public class CornField : MonoBehaviour
|
|||
|
||||
// 新しい苗
|
||||
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)
|
||||
{
|
||||
newGene.Period = Random.Range(2, 4);
|
||||
}
|
||||
seedling.SetSeedlingGene(newGene.FirstTime, newGene.Period, newGene.Level);
|
||||
progressData.Level = newGene.Level;
|
||||
progressData.Period = newGene.Period;
|
||||
progressData.FirstTime = newGene.FirstTime;
|
||||
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)
|
||||
{
|
||||
|
|
@ -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;
|
||||
if (fieldData.FirstOrDefault(x => x.Type == CornFieldUpgradeType.Machine && x.level == gameData.MachineLevel + 1)?.price is int nextMachinePrice)
|
||||
|
|
|
|||
Loading…
Reference in New Issue