受け取り処理を追加
This commit is contained in:
parent
45983e2b70
commit
9d75cd73f9
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UniRx;
|
using UniRx;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -23,21 +24,10 @@ namespace MyGame.Scenes.Main.Scripts
|
||||||
var autoCookDataList = SpreadsheetDataManager.Instance.GetBaseDataList<AutoCookData>(Const.AutoCookDataSheet);
|
var autoCookDataList = SpreadsheetDataManager.Instance.GetBaseDataList<AutoCookData>(Const.AutoCookDataSheet);
|
||||||
var autoCookData = autoCookDataList.First(data => data.level == gameData.AutoCookLevel);
|
var autoCookData = autoCookDataList.First(data => data.level == gameData.AutoCookLevel);
|
||||||
|
|
||||||
closeButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
|
||||||
{
|
|
||||||
LocalCacheManager.Load<Action>(CallbackTag, null)?.Invoke();
|
|
||||||
LocalCacheManager.Remove(CallbackTag);
|
|
||||||
transform.parent.SetLocalScale(0);
|
|
||||||
backgroundAnimator.SetTrigger(CloseTrigger);
|
|
||||||
this.CallWaitForSeconds(.25f, () =>
|
|
||||||
{
|
|
||||||
TransitionManager.Instance.UnloadScene(GameScenes.AutomaticCookingComplete);
|
|
||||||
});
|
|
||||||
}).AddTo(this);
|
|
||||||
|
|
||||||
|
|
||||||
// アイテムのリスト生成
|
// アイテムのリスト生成
|
||||||
var productList = SpreadsheetDataManager.Instance.GetBaseDataList<ProductData>(Const.ProductDataSheet);
|
var productList = SpreadsheetDataManager.Instance.GetBaseDataList<ProductData>(Const.ProductDataSheet);
|
||||||
|
var productCount = Mathf.CeilToInt((float)autoCookData.earnCount / Const.TankCapacity);
|
||||||
|
var earnIds = gameData.AutoCookProducts.Take(productCount).ToArray();
|
||||||
var earnProductArray = productList
|
var earnProductArray = productList
|
||||||
.Where(data => earnIds.Contains(data.id))
|
.Where(data => earnIds.Contains(data.id))
|
||||||
.Select(data => new ProductData(data, 1){volume = Const.TankCapacity})
|
.Select(data => new ProductData(data, 1){volume = Const.TankCapacity})
|
||||||
|
|
@ -50,9 +40,87 @@ namespace MyGame.Scenes.Main.Scripts
|
||||||
// リストの最後のポップコーン数を上書き
|
// リストの最後のポップコーン数を上書き
|
||||||
earnProductArray.Last().volume = lastProductAmount;
|
earnProductArray.Last().volume = lastProductAmount;
|
||||||
|
|
||||||
|
// タンクの空き確認
|
||||||
|
var emptyTankCount = gameData.StorageTanks.Count(tank => tank.IsEmpty);
|
||||||
|
var discardProductList = new List<ProductData>();
|
||||||
|
|
||||||
|
// 価格が高い順に破棄対象にする
|
||||||
|
foreach (var productData in earnProductArray.OrderBy(data => data.price))
|
||||||
|
{
|
||||||
|
if (productData.volume == Const.TankCapacity)
|
||||||
|
{
|
||||||
|
if (emptyTankCount > 0)
|
||||||
|
{
|
||||||
|
emptyTankCount--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
discardProductList.Add(productData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (gameData.StorageTanks.Exists(data => data.FlavorId == productData.id && data.Capacity - data.Stock >= productData.volume))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
discardProductList.Add(productData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closeButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||||
|
{
|
||||||
|
LocalCacheManager.Load<Action>(CallbackTag, null)?.Invoke();
|
||||||
|
LocalCacheManager.Remove(CallbackTag);
|
||||||
|
transform.parent.SetLocalScale(0);
|
||||||
|
backgroundAnimator.SetTrigger(CloseTrigger);
|
||||||
|
this.CallWaitForSeconds(.25f, () =>
|
||||||
|
{
|
||||||
|
TransitionManager.Instance.UnloadScene(GameScenes.AutomaticCookingComplete);
|
||||||
|
});
|
||||||
|
}).AddTo(this);
|
||||||
|
|
||||||
|
if (discardProductList.Count > 0)
|
||||||
|
{
|
||||||
|
getButton.OnClickAsObservable().ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
||||||
|
{
|
||||||
|
TransitionManager.Instance.UnloadScene(GameScenes.AutomaticCookingComplete);
|
||||||
|
AutoCookCaution.ShowDialog((earnProductArray, discardProductList), () =>
|
||||||
|
{
|
||||||
|
LocalCacheManager.Load<Action>(CallbackTag, null)?.Invoke();
|
||||||
|
LocalCacheManager.Remove(CallbackTag);
|
||||||
|
});
|
||||||
|
}).AddTo(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getButton.OnClickAsObservable().ThrottleFirst(TimeSpan.FromSeconds(.3f)).Subscribe(_ =>
|
||||||
|
{
|
||||||
|
// コーン獲得
|
||||||
|
foreach (var productData in earnProductArray)
|
||||||
|
{
|
||||||
|
CookingResult.AddStock(productData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自動調理セーブ
|
||||||
|
gameData.AutoCookProducts = Array.Empty<int>();
|
||||||
|
var maxLevel = autoCookDataList.Last().level;
|
||||||
|
if (gameData.AutoCookLevel < maxLevel)
|
||||||
|
{
|
||||||
|
gameData.AutoCookUsesCount++;
|
||||||
|
if (gameData.AutoCookUsesCount >= autoCookData.clearCount)
|
||||||
|
{
|
||||||
|
gameData.AutoCookUsesCount = 0;
|
||||||
|
gameData.AutoCookLevel++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GameDataManager.SaveGameData();
|
||||||
|
closeButton.onClick.Invoke();
|
||||||
|
}).AddTo(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 完成したポップコーンを表示
|
||||||
for (int i = 0; i < popcorns.Length; i++)
|
for (int i = 0; i < popcorns.Length; i++)
|
||||||
{
|
{
|
||||||
if (i < count)
|
if (i < productCount)
|
||||||
{
|
{
|
||||||
popcorns[i].SetView(earnProductArray[i]);
|
popcorns[i].SetView(earnProductArray[i]);
|
||||||
popcorns[i].SetActive(true);
|
popcorns[i].SetActive(true);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue