ResultにPrice表示追加/続けて調理機能を追加
This commit is contained in:
parent
c33f4bc4cd
commit
dfb907eea6
File diff suppressed because it is too large
Load Diff
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using MyGame.Scenes.Cooking.Scripts;
|
||||
using MyGame.Scripts;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
|
|
@ -10,12 +11,13 @@ public class CookingResult : MonoBehaviour
|
|||
{
|
||||
private static readonly string BulkOrderRarityTextFormat = "大成功ボーナス獲得";
|
||||
private static readonly string QuantityTextFormat = "x{0}";
|
||||
private static readonly float BulkOrderExplainHeight = 200f;
|
||||
[SerializeField] private GameObject smokeEffect;
|
||||
[SerializeField] private GameObject glitterEffect;
|
||||
[SerializeField] private Button centerOkButton;
|
||||
[SerializeField] private Button perfectButton;
|
||||
[SerializeField] private Button leftOkButton;
|
||||
[SerializeField] private Button okButton;
|
||||
[SerializeField] private Button destructionButton;
|
||||
[SerializeField] private Button makeOneButton;
|
||||
[SerializeField] private Transform popcornTarget;
|
||||
[SerializeField] private Text popcornText;
|
||||
[SerializeField] private Text popcornTextPerfect;
|
||||
|
|
@ -28,6 +30,7 @@ public class CookingResult : MonoBehaviour
|
|||
[SerializeField] private GameObject perfectResultObject;
|
||||
[SerializeField] private GameObject goodResultObject;
|
||||
[SerializeField] private GameObject failureResultObject;
|
||||
[SerializeField] private ResultCoinView coinView;
|
||||
|
||||
ReactiveProperty<CornResult> result = new ReactiveProperty<CornResult>();
|
||||
|
||||
|
|
@ -41,11 +44,19 @@ public class CookingResult : MonoBehaviour
|
|||
var (rarityData, resultData, successAction) = LocalCacheManager.Load<(RarityData, CornResult, Action)>(PopcornGameManager.CookingResultDataTag);
|
||||
result.Value = resultData;
|
||||
SetData(productData, rarityData, viewType);
|
||||
|
||||
// 続けて料理を作ることができるかどうか判定
|
||||
var hasSpace = RecipeDetailView.CheckTank(productData);
|
||||
var checkResult = RecipeDetailView.CheckAmount(productData);
|
||||
var hasMaterials = checkResult.material1 && checkResult.material2 && checkResult.material3;
|
||||
var isMakeOne = hasSpace && hasMaterials;
|
||||
|
||||
if (GameDataManager.GameData.isFirstPlay)
|
||||
{
|
||||
SetUI(resultData, rarityData.Rarity != ProductRarity.Normal, true);
|
||||
// ボタン非表示
|
||||
SetUI(resultData, viewType, isMakeOne, true);
|
||||
|
||||
// 失敗したら再チャレンジ
|
||||
if (resultData == CornResult.Failure)
|
||||
{
|
||||
TutorialManager.Instance.ShowTutorialConversation(9, () =>
|
||||
|
|
@ -54,31 +65,22 @@ public class CookingResult : MonoBehaviour
|
|||
TransitionManager.Instance.UnloadScene(GameScenes.CookingResults);
|
||||
LocalCacheManager.Load<Action>(PopcornGameManager.RestartCallbackTag, null)?.Invoke();
|
||||
});
|
||||
return;
|
||||
}
|
||||
else
|
||||
successAction?.Invoke();
|
||||
okButton.gameObject.SetActive(true);
|
||||
okButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||
{
|
||||
successAction?.Invoke();
|
||||
centerOkButton.gameObject.SetActive(true);
|
||||
centerOkButton.OnClickAsObservable().Subscribe(_ =>
|
||||
{
|
||||
// 獲得、遷移
|
||||
if (resultData == CornResult.Perfect)
|
||||
{
|
||||
AddStock(productData, rarityData.Rarity);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddStock(productData);
|
||||
}
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||
}).AddTo(this);
|
||||
}
|
||||
// 獲得、遷移
|
||||
AddStock(productData, resultData == CornResult.Perfect ? rarityData.Rarity : ProductRarity.Normal);
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||
}).AddTo(this);
|
||||
return;
|
||||
}
|
||||
|
||||
result.Subscribe(r =>
|
||||
{
|
||||
SetUI(r, rarityData.Rarity != ProductRarity.Normal);
|
||||
SetUI(r, viewType, isMakeOne);
|
||||
if (r != CornResult.Failure)
|
||||
{
|
||||
successAction?.Invoke();
|
||||
|
|
@ -89,17 +91,10 @@ public class CookingResult : MonoBehaviour
|
|||
if (viewType == ProductViewType.Default)
|
||||
{
|
||||
Market.Instance.IsPause.Value = true;
|
||||
centerOkButton.OnClickAsObservable().Subscribe(_ =>
|
||||
okButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||
{
|
||||
// 獲得、遷移
|
||||
AddStock(productData, rarityData.Rarity);
|
||||
Market.Instance.IsPause.Value = false;
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||
}).AddTo(this);
|
||||
leftOkButton.OnClickAsObservable().Subscribe(_ =>
|
||||
{
|
||||
// 獲得、遷移
|
||||
AddStock(productData);
|
||||
AddStock(productData, result.Value == CornResult.Perfect ? rarityData.Rarity : ProductRarity.Normal);
|
||||
Market.Instance.IsPause.Value = false;
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||
}).AddTo(this);
|
||||
|
|
@ -108,22 +103,13 @@ public class CookingResult : MonoBehaviour
|
|||
{
|
||||
// 大量注文時処理
|
||||
var materialNumber = LocalCacheManager.Load<int>(BulkOrder.MaterialNumberTag);
|
||||
centerOkButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||
okButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||
{
|
||||
// 獲得、遷移
|
||||
if (!GameDataManager.GameData.CompletedProductList.Exists(data => data.Number == materialNumber))
|
||||
{
|
||||
GameDataManager.GameData.CompletedProductList.Add(new BulkOrderResultData(){Number = materialNumber, Rarity = rarityData.Rarity});
|
||||
GameDataManager.SaveGameData();
|
||||
}
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||
}).AddTo(this);
|
||||
leftOkButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||
{
|
||||
// 獲得、遷移
|
||||
if (!GameDataManager.GameData.CompletedProductList.Exists(data => data.Number == materialNumber))
|
||||
{
|
||||
GameDataManager.GameData.CompletedProductList.Add(new BulkOrderResultData(){Number = materialNumber, Rarity = ProductRarity.Normal});
|
||||
var rarity = result.Value == CornResult.Perfect ? rarityData.Rarity : ProductRarity.Normal;
|
||||
GameDataManager.GameData.CompletedProductList.Add(new BulkOrderResultData(){Number = materialNumber, Rarity = rarity});
|
||||
GameDataManager.SaveGameData();
|
||||
}
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||
|
|
@ -143,6 +129,15 @@ public class CookingResult : MonoBehaviour
|
|||
// 遷移
|
||||
TransitionManager.Instance.LoadScene(GameScenes.Main);
|
||||
}).AddTo(this);
|
||||
makeOneButton.OnClickAsObservable().Take(1).Subscribe(_ =>
|
||||
{
|
||||
// 獲得、遷移
|
||||
AddStock(productData, result.Value == CornResult.Perfect ? rarityData.Rarity : ProductRarity.Normal);
|
||||
Market.Instance.IsPause.Value = false;
|
||||
SoundManager.Instance.ChangeVolumeUniqueBGM(1f);
|
||||
TransitionManager.Instance.UnloadScene(GameScenes.CookingResults);
|
||||
LocalCacheManager.Load<Action>(PopcornGameManager.RestartCallbackTag, null)?.Invoke();
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private void SetData(ProductData recipe, RarityData rarity, ProductViewType viewType)
|
||||
|
|
@ -151,49 +146,53 @@ public class CookingResult : MonoBehaviour
|
|||
popcornText.text = recipe.name;
|
||||
popcornTextPerfect.text = recipe.name;
|
||||
quantityText.text = string.Format(QuantityTextFormat, recipe.volume);
|
||||
coinView.SetPrice(recipe.GetRarityPrice(ProductRarity.Normal), recipe.GetRarityPrice(rarity.Rarity));
|
||||
var rarityFormat = viewType == ProductViewType.Default ? rarity.text : BulkOrderRarityTextFormat;
|
||||
rarityText.text = rarityFormat;
|
||||
rarityView.SetRarity(rarity.Rarity);
|
||||
popcornTarget.DestroyAllChildrens();
|
||||
Instantiate(recipe.GetLargePrefab(), popcornTarget);
|
||||
}
|
||||
|
||||
private void SetUI(CornResult result, bool hasRarity, bool isTutorial = false)
|
||||
|
||||
private void SetUI(CornResult cornResult, ProductViewType viewType, bool isMakeOne, bool isTutorial = false)
|
||||
{
|
||||
centerOkButton.gameObject.SetActive(false);
|
||||
perfectButton.gameObject.SetActive(false);
|
||||
leftOkButton.gameObject.SetActive(false);
|
||||
okButton.gameObject.SetActive(false);
|
||||
destructionButton.gameObject.SetActive(false);
|
||||
makeOneButton.gameObject.SetActive(false);
|
||||
|
||||
if (!isTutorial)
|
||||
{
|
||||
this.CallWaitForSeconds(1.25f, () =>
|
||||
{
|
||||
centerOkButton.gameObject.SetActive(result == CornResult.Perfect);
|
||||
perfectButton.gameObject.SetActive(result != CornResult.Perfect);
|
||||
leftOkButton.gameObject.SetActive(result == CornResult.Good);
|
||||
destructionButton.gameObject.SetActive(result == CornResult.Failure);
|
||||
});
|
||||
makeOneButton.gameObject.SetActive(viewType == ProductViewType.Default && isMakeOne);
|
||||
perfectButton.gameObject.SetActive(cornResult != CornResult.Perfect);
|
||||
destructionButton.gameObject.SetActive(cornResult == CornResult.Failure);
|
||||
okButton.gameObject.SetActive(cornResult != CornResult.Failure);
|
||||
});
|
||||
}
|
||||
|
||||
perfectResultObject.SetActive(result == CornResult.Perfect);
|
||||
goodResultObject.SetActive(result == CornResult.Good);
|
||||
failureResultObject.SetActive(result == CornResult.Failure);
|
||||
perfectResultObject.SetActive(cornResult == CornResult.Perfect);
|
||||
goodResultObject.SetActive(cornResult == CornResult.Good);
|
||||
failureResultObject.SetActive(cornResult == CornResult.Failure);
|
||||
|
||||
if (result == CornResult.Failure)
|
||||
if (cornResult == CornResult.Failure)
|
||||
{
|
||||
VibrationManager.Instance.PlayVibrationDoubleStrong();
|
||||
}
|
||||
smokeEffect.SetActive(result == CornResult.Failure);
|
||||
glitterEffect.SetActive(result == CornResult.Perfect);
|
||||
smokeEffect.SetActive(cornResult == CornResult.Failure);
|
||||
glitterEffect.SetActive(cornResult == CornResult.Perfect);
|
||||
|
||||
detailObject.SetActive(result != CornResult.Failure);
|
||||
explainObject.SetActive(result == CornResult.Good);
|
||||
explainWithRarityObject.SetActive(false);
|
||||
if (result == CornResult.Perfect)
|
||||
detailObject.SetActive(cornResult != CornResult.Failure);
|
||||
explainObject.SetActive(cornResult == CornResult.Good);
|
||||
explainWithRarityObject.SetActive(cornResult == CornResult.Perfect);
|
||||
|
||||
if (viewType != ProductViewType.Default)
|
||||
{
|
||||
explainWithRarityObject.SetActive(hasRarity);
|
||||
explainObject.SetActive(!hasRarity);
|
||||
coinView.gameObject.SetActive(false);
|
||||
// 高さ調整
|
||||
var rect = explainWithRarityObject.transform as RectTransform;
|
||||
rect.sizeDelta = new Vector2(rect.sizeDelta.x, BulkOrderExplainHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue