Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop

This commit is contained in:
koya_15 2021-10-08 19:13:19 +09:00
commit 577f3e07d3
9 changed files with 173 additions and 21 deletions

View File

@ -90,12 +90,12 @@ public class DebugOptionManager : MonoBehaviour
gameData.StorageTanks = new List<StorageTank> gameData.StorageTanks = new List<StorageTank>
{ {
// new StorageTank(){Id = 1, Capacity = 50, FlavorId = 1, Stocks = new List<ProductStockData>{new ProductStockData{Rarity = ProductRarity.Normal, Stock = 0}}}, // new StorageTank(){Id = 1, Capacity = 50, FlavorId = 1, Stocks = new List<ProductStockData>{new ProductStockData{Rarity = ProductRarity.Normal, Stock = 0}}},
new StorageTank(){Id = 2, Capacity = 50, FlavorId = 2, Stocks = new List<ProductStockData> new StorageTank(){Capacity = 50, FlavorId = 2, Stocks = new List<ProductStockData>
{ {
new ProductStockData{Rarity = ProductRarity.Normal, Stock = 1}, new ProductStockData{Rarity = ProductRarity.Normal, Stock = 1},
new ProductStockData{Rarity = ProductRarity.Yellow, Stock = 20}, new ProductStockData{Rarity = ProductRarity.Yellow, Stock = 20},
}}, }},
new StorageTank(){Id = 3, Capacity = 50, FlavorId = 1, Stocks = new List<ProductStockData> new StorageTank(){Capacity = 50, FlavorId = 1, Stocks = new List<ProductStockData>
{ {
new ProductStockData{Rarity = ProductRarity.Normal, Stock = 1}, new ProductStockData{Rarity = ProductRarity.Normal, Stock = 1},
new ProductStockData{Rarity = ProductRarity.Yellow, Stock = 9}, new ProductStockData{Rarity = ProductRarity.Yellow, Stock = 9},
@ -104,7 +104,7 @@ public class DebugOptionManager : MonoBehaviour
new ProductStockData{Rarity = ProductRarity.Gold, Stock = 10}, new ProductStockData{Rarity = ProductRarity.Gold, Stock = 10},
new ProductStockData{Rarity = ProductRarity.Rainbow, Stock = 20}, new ProductStockData{Rarity = ProductRarity.Rainbow, Stock = 20},
}}, }},
new StorageTank(){Id = 4, Capacity = 50, FlavorId = 1, Stocks = new List<ProductStockData>{new ProductStockData{Rarity = ProductRarity.Gold, Stock = 4}}}, new StorageTank(){Capacity = 50, FlavorId = 1, Stocks = new List<ProductStockData>{new ProductStockData{Rarity = ProductRarity.Gold, Stock = 4}}},
}; };
}).AddTo(this); }).AddTo(this);

View File

@ -103,6 +103,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 2377818822852436376} - component: {fileID: 2377818822852436376}
- component: {fileID: 7948284479330041018}
m_Layer: 5 m_Layer: 5
m_Name: Window m_Name: Window
m_TagString: Untagged m_TagString: Untagged
@ -132,6 +133,24 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 145} m_AnchoredPosition: {x: 0, y: 145}
m_SizeDelta: {x: 900, y: 1020} m_SizeDelta: {x: 900, y: 1020}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &7948284479330041018
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2377818822852436379}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 97711eafafff465ebe1223e7ed0ab2e7, type: 3}
m_Name:
m_EditorClassIdentifier:
backgroundAnimator: {fileID: 2377818822785157575}
closeButton: {fileID: 2377818823238410848}
heartText: {fileID: 2377818823370329765}
coinText: {fileID: 2377818823929203721}
bonusCoinText: {fileID: 2377818823802633425}
messageText: {fileID: 2377818823780007094}
--- !u!1 &2377818823009469882 --- !u!1 &2377818823009469882
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -1,18 +1,20 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using UniRx; using UniRx;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
public class BulkOrderProgressData public class BulkOrderResultData
{ {
public int orderId; public int Number;
public ProductRarity rarity; public ProductRarity Rarity;
} }
public class BulkOrder : MonoBehaviour public class BulkOrder : MonoBehaviour
{ {
public static readonly string DataTag = "BulkOrderData"; public static readonly string DataTag = "BulkOrderData";
public static readonly string CancelCallbackTag = "BulkOrderCancelCallback"; public static readonly string CancelCallbackTag = "BulkOrderCancelCallback";
public static readonly string AchievedCallbackTag = "BulkOrderAchievedCallback";
private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger"); private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger");
private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger"); private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger");
[SerializeField] private Animator backgroundAnimator; [SerializeField] private Animator backgroundAnimator;
@ -49,7 +51,7 @@ public class BulkOrder : MonoBehaviour
messageText.text = messageList.First(data => data.id == gameData.OrderTextId).requestText; messageText.text = messageList.First(data => data.id == gameData.OrderTextId).requestText;
coinText.text = bulkOrderData.rewardCoin.ToString(); coinText.text = bulkOrderData.rewardCoin.ToString();
heartText.text = bulkOrderData.rewardHeart.ToString(); heartText.text = bulkOrderData.rewardHeart.ToString();
// cache
LocalCacheManager.Save(DataTag, bulkOrderData); LocalCacheManager.Save(DataTag, bulkOrderData);
cancelButton.OnClickAsObservable().ThrottleFirst(TimeSpan.FromSeconds(1f)).Subscribe(_ => cancelButton.OnClickAsObservable().ThrottleFirst(TimeSpan.FromSeconds(1f)).Subscribe(_ =>
{ {
@ -59,16 +61,63 @@ public class BulkOrder : MonoBehaviour
gameData.CancelOrderId = gameData.OrderIdInProgress; gameData.CancelOrderId = gameData.OrderIdInProgress;
// カウントリセット // カウントリセット
gameData.OrderConditionCount = 0; gameData.OrderConditionCount = 0;
GameDataManager.SaveGameData();
// キャンセルと同時に閉じる
transform.parent.SetLocalScale(0);
backgroundAnimator.SetTrigger(CloseTrigger);
this.CallWaitForSeconds(.25f, () =>
{
TransitionManager.Instance.UnloadScene(GameScenes.BulkOrder); TransitionManager.Instance.UnloadScene(GameScenes.BulkOrder);
});
})); }));
TransitionManager.Instance.LoadSceneAdditive(GameScenes.BulkOrderCancel); TransitionManager.Instance.LoadSceneAdditive(GameScenes.BulkOrderCancel);
}).AddTo(this); }).AddTo(this);
// 納品チェック
var orderList = new List<int>
{
bulkOrderData.productId1,
bulkOrderData.productId2,
bulkOrderData.productId3,
};
// 納品する
var achieved = gameData.CompletedOrderList.Count == orderList.Count(x => x != 0);
achievedObject.SetActive(achieved);
deliveredButton.interactable = achieved;
deliveredButton.OnClickAsObservable().ThrottleFirst(TimeSpan.FromSeconds(1f)).Subscribe(_ => deliveredButton.OnClickAsObservable().ThrottleFirst(TimeSpan.FromSeconds(1f)).Subscribe(_ =>
{ {
LocalCacheManager.Save(AchievedCallbackTag, new Action(() =>
{
// 獲得
var rarityList = SpreadsheetDataManager.Instance.GetBaseDataList<RarityData>(Const.RarityDataSheet);
var bonus = CalcBonus(rarityList, gameData.CompletedOrderList, bulkOrderData.shopLevel);
gameData.Coin = CoinManager.Instance.OwnCoin;
CoinManager.Instance.AddCoinWithEffect(bulkOrderData.rewardCoin + bonus);
gameData.Heart += bulkOrderData.rewardHeart;
HeartMeter.Instance.AddHeart(bulkOrderData.rewardHeart);
// カウントリセット // カウントリセット
gameData.OrderConditionCount = 0; gameData.OrderConditionCount = 0;
gameData.CurrentLevelOrderCount++;
#if UNITY_EDITOR
Debug.Log($"current:{gameData.CurrentLevelOrderCount} max:{bulkOrderData.maxOrder}");
#endif
// オーダー上限を超えるとそのLevelでの注文終了
if (gameData.CurrentLevelOrderCount == bulkOrderData.maxOrder)
{
gameData.CurrentLevelOrderCount = 0;
gameData.AchievedOrderLevel = bulkOrderData.shopLevel;
}
GameDataManager.SaveGameData();
// キャンセルと同時に閉じる
transform.parent.SetLocalScale(0);
backgroundAnimator.SetTrigger(CloseTrigger);
this.CallWaitForSeconds(.25f, () =>
{
TransitionManager.Instance.UnloadScene(GameScenes.BulkOrder);
});
}));
TransitionManager.Instance.LoadSceneAdditive(GameScenes.BulkOrderAchievement); TransitionManager.Instance.LoadSceneAdditive(GameScenes.BulkOrderAchievement);
}).AddTo(this); }).AddTo(this);
@ -77,7 +126,15 @@ public class BulkOrder : MonoBehaviour
{ {
itemView1.SetData(data1, bulkOrderData.count1); itemView1.SetData(data1, bulkOrderData.count1);
itemView1.SetButtonActive(itemView1.CheckAmount(data1)); itemView1.SetButtonActive(itemView1.CheckAmount(data1));
if (gameData.CompletedOrderList.FirstOrDefault(data => data.Number == 1) is BulkOrderResultData resultData)
{
itemView1.SetCooked(resultData.Rarity);
}
itemView1.gameObject.SetActive(true); itemView1.gameObject.SetActive(true);
itemView1.CookingButton.ThrottleFirst(TimeSpan.FromSeconds(1f)).Subscribe(_ =>
{
gameData.CompletedOrderList.Add(new BulkOrderResultData(){Number = 1, Rarity = ProductRarity.Copper});
}).AddTo(itemView1);
} }
else else
{ {
@ -87,6 +144,10 @@ public class BulkOrder : MonoBehaviour
{ {
itemView2.SetData(data2, bulkOrderData.count2); itemView2.SetData(data2, bulkOrderData.count2);
itemView2.SetButtonActive(itemView2.CheckAmount(data2)); itemView2.SetButtonActive(itemView2.CheckAmount(data2));
if (gameData.CompletedOrderList.FirstOrDefault(data => data.Number == 2) is BulkOrderResultData resultData)
{
itemView2.SetCooked(resultData.Rarity);
}
itemView2.gameObject.SetActive(true); itemView2.gameObject.SetActive(true);
} }
else else
@ -97,6 +158,10 @@ public class BulkOrder : MonoBehaviour
{ {
itemView3.SetData(data3, bulkOrderData.count3); itemView3.SetData(data3, bulkOrderData.count3);
itemView3.SetButtonActive(itemView3.CheckAmount(data3)); itemView3.SetButtonActive(itemView3.CheckAmount(data3));
if (gameData.CompletedOrderList.FirstOrDefault(data => data.Number == 3) is BulkOrderResultData resultData)
{
itemView3.SetCooked(resultData.Rarity);
}
itemView3.gameObject.SetActive(true); itemView3.gameObject.SetActive(true);
} }
else else
@ -104,4 +169,20 @@ public class BulkOrder : MonoBehaviour
itemView3.gameObject.SetActive(false); itemView3.gameObject.SetActive(false);
} }
} }
public static int CalcBonus(List<RarityData> rarityList, List<BulkOrderResultData> resultData, int shopLevel)
{
var totalBonus = 0;
var hasRarityList = resultData.Where(data => data.Rarity != ProductRarity.Normal).ToList();
if (hasRarityList.Count == 0)
{
return 0;
}
foreach (var progressData in hasRarityList)
{
var bonusRate = rarityList.FirstOrDefault(data => data.Rarity == progressData.Rarity)?.bulkOrderBonus ?? 0;
totalBonus += bonusRate * shopLevel;
}
return Mathf.CeilToInt((float) totalBonus / hasRarityList.Count);
}
} }

View File

@ -1,6 +1,47 @@
using System;
using System.Linq;
using UniRx;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
public class BulkOrderAchievedView : MonoBehaviour public class BulkOrderAchievedView : MonoBehaviour
{ {
private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger");
private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger");
[SerializeField] private Animator backgroundAnimator;
[SerializeField] private Button closeButton;
[SerializeField] private Text heartText;
[SerializeField] private Text coinText;
[SerializeField] private Text bonusCoinText;
[SerializeField] private Text messageText;
private void Start()
{
if (LocalCacheManager.Load<BulkOrderData>(BulkOrder.DataTag, null) is BulkOrderData orderData)
{
var gameData = GameDataManager.GameData;
var messageList = SpreadsheetDataManager.Instance.GetBaseDataList<BulkOrderTextData>(Const.BulkOrderTextDataSheet);
var rarityList = SpreadsheetDataManager.Instance.GetBaseDataList<RarityData>(Const.RarityDataSheet);
var bonus = BulkOrder.CalcBonus(rarityList, gameData.CompletedOrderList, orderData.shopLevel);
heartText.text = orderData.rewardHeart.ToString();
coinText.text = orderData.rewardCoin.ToString();
bonusCoinText.text = bonus.ToString();
messageText.text = messageList.First(data => data.id == gameData.OrderTextId).thanksText;
}
closeButton.OnClickAsObservable().Subscribe(_ =>
{
if (LocalCacheManager.Load<Action>(BulkOrder.AchievedCallbackTag, null) is Action callback)
{
callback.Invoke();
}
transform.parent.SetLocalScale(0);
backgroundAnimator.SetTrigger(CloseTrigger);
this.CallWaitForSeconds(.25f, () =>
{
TransitionManager.Instance.UnloadScene(GameScenes.BulkOrderAchievement);
TransitionManager.Instance.UnloadScene(GameScenes.BulkOrder);
});
}).AddTo(this);
}
} }

View File

@ -9,7 +9,7 @@ using UnityEngine.UI;
public class KitchenManager : MonoBehaviour public class KitchenManager : MonoBehaviour
{ {
public static readonly string CancelCallbackTag = "BulkOrderCancelCallback"; public static readonly string CancelCallbackTag = "KitchenCancelCallback";
[SerializeField] private Button cookingButton; [SerializeField] private Button cookingButton;
[SerializeField] private Button adButton; [SerializeField] private Button adButton;
[SerializeField] private KitchenView kitchenView; [SerializeField] private KitchenView kitchenView;
@ -62,6 +62,7 @@ public class KitchenManager : MonoBehaviour
orderIndicatorView.TappedPhone.ThrottleFirst(TimeSpan.FromSeconds(1f)).Take(1).Subscribe(_ => orderIndicatorView.TappedPhone.ThrottleFirst(TimeSpan.FromSeconds(1f)).Take(1).Subscribe(_ =>
{ {
// タップで更新 // タップで更新
gameData.CompletedOrderList.Clear();
gameData.OrderIdInProgress = result.nextOrderId; gameData.OrderIdInProgress = result.nextOrderId;
if (nextMessageList.Exists(data => data.id == gameData.OrderTextId)) if (nextMessageList.Exists(data => data.id == gameData.OrderTextId))
{ {

View File

@ -81,7 +81,7 @@ public class ProductManagement : MonoBehaviour
Action<int> purchaseAction = amount => Action<int> purchaseAction = amount =>
{ {
// タンク追加 // タンク追加
gameData.StorageTanks.Add(new StorageTank() {Id = tankView.TankNumber, Capacity = 50}); gameData.StorageTanks.Add(new StorageTank() {Capacity = 50});
tankView.SetData(gameData.StorageTanks[tankView.TankNumber - 1]); tankView.SetData(gameData.StorageTanks[tankView.TankNumber - 1]);
tankView.SetState(TankState.Unlock); tankView.SetState(TankState.Unlock);
CoinManager.Instance.SubCoin(shopData.price); CoinManager.Instance.SubCoin(shopData.price);

View File

@ -5,7 +5,6 @@ using UnityEngine;
public class StorageTank public class StorageTank
{ {
// タンクID, タンク内のフレーバーID, フレーバーの個数 // タンクID, タンク内のフレーバーID, フレーバーの個数
public int Id;
public int Capacity; public int Capacity;
public int FlavorId; public int FlavorId;
public int Stock public int Stock

View File

@ -40,7 +40,7 @@ public class CoinManager : SingletonMonoBehaviour<CoinManager>
coinCountText.CountUpAnimation(coinTextFormat, ownCoin, duration); coinCountText.CountUpAnimation(coinTextFormat, ownCoin, duration);
} }
public void AddCoinWithEffect(int count, Action callback) public void AddCoinWithEffect(int count, Action callback = null)
{ {
ownCoin += count; ownCoin += count;
// 生成枚数決定 // 生成枚数決定
@ -48,7 +48,7 @@ public class CoinManager : SingletonMonoBehaviour<CoinManager>
InstantiateEffeect(coinPrefab, count, Vector3.zero, coinIconTransform.position, () => InstantiateEffeect(coinPrefab, count, Vector3.zero, coinIconTransform.position, () =>
{ {
coinCountText.CountUpAnimation(coinTextFormat, ownCoin, duration); coinCountText.CountUpAnimation(coinTextFormat, ownCoin, duration);
callback.Invoke(); callback?.Invoke();
}); });
} }

View File

@ -102,9 +102,9 @@ public sealed class GameData {
// [DataMember(Name = "Data27")] // [DataMember(Name = "Data27")]
// BulkOrder
[DataMember(Name = "Data28")] [DataMember(Name = "Data28")]
public int OrderIdInProgress; public int OrderIdInProgress;
[DataMember(Name = "Data29")] [DataMember(Name = "Data29")]
public int OrderTextId; public int OrderTextId;
[DataMember(Name = "Data30")] [DataMember(Name = "Data30")]
@ -113,9 +113,10 @@ public sealed class GameData {
public int CancelOrderId; public int CancelOrderId;
[DataMember(Name = "Data32")] [DataMember(Name = "Data32")]
public int AchievedOrderLevel; public int AchievedOrderLevel;
// 進捗
[DataMember(Name = "Data33")] [DataMember(Name = "Data33")]
public List<BulkOrderProgressData> OrderProgressList; public List<BulkOrderResultData> CompletedOrderList;
[DataMember(Name = "Data34")]
public int CurrentLevelOrderCount;
// mission // mission
[DataMember(Name = "Data1001")] [DataMember(Name = "Data1001")]
@ -207,6 +208,15 @@ public sealed class GameData {
{ {
MyRecipes = new[] {Const.DefaultRecipeId}; MyRecipes = new[] {Const.DefaultRecipeId};
} }
if (StorageTanks.Count < 1)
{
StorageTanks.Add(new StorageTank
{
Capacity = 50,
FlavorId = -1,
}
);
}
if (Pans.Length < 1) if (Pans.Length < 1)
{ {
Pans = new[] {Const.DefaultPanId}; Pans = new[] {Const.DefaultPanId};
@ -221,10 +231,11 @@ public sealed class GameData {
MyRecipes = MyRecipes ?? new int[0]; MyRecipes = MyRecipes ?? new int[0];
Material = Material ?? new List<MaterialData>(); Material = Material ?? new List<MaterialData>();
ShopStock = ShopStock ?? new List<ProductStockData>(); ShopStock = ShopStock ?? new List<ProductStockData>();
StorageTanks = StorageTanks ?? new List<StorageTank>();
Pans = Pans ?? new int[0]; Pans = Pans ?? new int[0];
TotalSalesList = TotalSalesList ?? new List<ProductStockData>(); TotalSalesList = TotalSalesList ?? new List<ProductStockData>();
AchievedMission = achievedMission?.ToList() ?? new List<int>(); AchievedMission = achievedMission?.ToList() ?? new List<int>();
OrderProgressList = OrderProgressList ?? new List<BulkOrderProgressData>(); CompletedOrderList = CompletedOrderList ?? new List<BulkOrderResultData>();
} }
private Dictionary<int, int> ArrayToDictionary(KeyValueOfintint[] array){ private Dictionary<int, int> ArrayToDictionary(KeyValueOfintint[] array){
var dictionary = new Dictionary<int, int>(); var dictionary = new Dictionary<int, int>();