Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop
This commit is contained in:
commit
68e8dc682d
|
|
@ -95,7 +95,10 @@ public class PopcornGameManager : MonoBehaviour
|
|||
this.CallWaitForSeconds(1.2f, () =>
|
||||
{
|
||||
SetResult(x);
|
||||
AddStock();
|
||||
if (x != CornResult.Failure)
|
||||
{
|
||||
AddStock();
|
||||
}
|
||||
// 画面タップで次へ
|
||||
this.UpdateAsObservable()
|
||||
.Select(_ => Input.GetMouseButton(0))
|
||||
|
|
@ -170,21 +173,19 @@ public class PopcornGameManager : MonoBehaviour
|
|||
var recipe = LocalCacheManager.Load<RecipeData>(RecipeDetailView.DetailRecipeTag);
|
||||
var gameData = GameDataManager.GameData;
|
||||
// 店頭の空きに追加
|
||||
if (21 >= gameData.ShopStock.Count + recipe.Volume)
|
||||
var remain = recipe.Volume;
|
||||
var shopSpace = Market.ShopStockCount - gameData.ShopStock.Count;
|
||||
if (shopSpace > 0)
|
||||
{
|
||||
for (int i = 0; i < recipe.Volume; i++)
|
||||
var stockCount = Mathf.Min(shopSpace, remain);
|
||||
for (int i = 0; i < stockCount; i++)
|
||||
{
|
||||
gameData.ShopStock.Add(recipe.RecipeId);
|
||||
}
|
||||
GameDataManager.SaveGameData();
|
||||
return;
|
||||
remain -= stockCount;
|
||||
}
|
||||
// 空のタンクに追加
|
||||
var emptyTankIndex = gameData.StorageTanks.FindIndex(x => x.Stock == 0);
|
||||
if (emptyTankIndex != -1)
|
||||
if (remain == 0)
|
||||
{
|
||||
gameData.StorageTanks[emptyTankIndex].FlavorId = recipe.RecipeId;
|
||||
gameData.StorageTanks[emptyTankIndex].Stock = recipe.Volume;
|
||||
GameDataManager.SaveGameData();
|
||||
return;
|
||||
}
|
||||
|
|
@ -194,13 +195,28 @@ public class PopcornGameManager : MonoBehaviour
|
|||
{
|
||||
// 同じフレーバーのタンクの空きに追加
|
||||
var tank = gameData.StorageTanks[index];
|
||||
if (tank.Capacity >= tank.Stock + recipe.Volume)
|
||||
var tankSpace = tank.Capacity - tank.Stock;
|
||||
if (tankSpace > 0)
|
||||
{
|
||||
tank.Stock += recipe.Volume;
|
||||
var stockCount = Mathf.Min(tankSpace, remain);
|
||||
tank.Stock += stockCount;
|
||||
gameData.StorageTanks[index] = tank;
|
||||
GameDataManager.SaveGameData();
|
||||
return;
|
||||
remain -= stockCount;
|
||||
}
|
||||
}
|
||||
if (remain == 0)
|
||||
{
|
||||
GameDataManager.SaveGameData();
|
||||
return;
|
||||
}
|
||||
// 空のタンクに追加
|
||||
var emptyTankIndex = gameData.StorageTanks.FindIndex(x => x.Stock == 0);
|
||||
if (emptyTankIndex != -1)
|
||||
{
|
||||
gameData.StorageTanks[emptyTankIndex].FlavorId = recipe.RecipeId;
|
||||
gameData.StorageTanks[emptyTankIndex].Stock = remain;
|
||||
GameDataManager.SaveGameData();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class KitchenManager : MonoBehaviour
|
|||
};
|
||||
|
||||
// 所持素材
|
||||
if (gameData.Material == null)
|
||||
if (gameData.Material == null || gameData.Material.Count == 0)
|
||||
{
|
||||
gameData.Material = new List<(int id, int amount)>
|
||||
{
|
||||
|
|
@ -75,13 +75,6 @@ public class KitchenManager : MonoBehaviour
|
|||
}
|
||||
GameDataManager.SaveGameData();
|
||||
|
||||
var shopStockString = "";
|
||||
foreach (var data in RecipeData.GetAllRecipe())
|
||||
{
|
||||
var shopStockCount = gameData.ShopStock.FindAll(x => x == data.RecipeId).Count;
|
||||
var tank = gameData.StorageTanks.FindAll(x => x.FlavorId == data.RecipeId).Sum(x => x.Stock);
|
||||
shopStockString += $"{data.Name} shop:{shopStockCount} stock:{tank}\n";
|
||||
}
|
||||
Debug.Log(shopStockString);
|
||||
Market.StockFlavorLog();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -12,10 +13,83 @@ public class Market : MonoBehaviour
|
|||
{
|
||||
var gameData = GameDataManager.GameData;
|
||||
CoinManager.Instance.ChangeCoin(gameData.coin);
|
||||
Observable.Interval(TimeSpan.FromSeconds(2f)).Subscribe(_ =>
|
||||
// 在庫数表示
|
||||
var totalCapacity = gameData.StorageTanks.Sum(x => x.Capacity);
|
||||
var totalStock = gameData.StorageTanks.Sum(x => x.Stock);
|
||||
|
||||
// 全レシピ
|
||||
var allRecipe = RecipeData.GetAllRecipe();
|
||||
|
||||
Debug.Log($"Tank:{totalStock}/{totalCapacity}");
|
||||
StockFlavorLog();
|
||||
|
||||
// お客さんの出現タイミング(10秒間に1回)
|
||||
Observable.Timer(TimeSpan.FromSeconds(2f), TimeSpan.FromSeconds(10f))
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
// 品切れ
|
||||
if (GameDataManager.GameData.ShopStock.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 店頭の先頭から売る
|
||||
var id = GameDataManager.GameData.ShopStock[0];
|
||||
GameDataManager.GameData.ShopStock.RemoveAt(0);
|
||||
var bonusRate = 0;
|
||||
var flavor = allRecipe.First(x => x.RecipeId == id);
|
||||
CoinManager.Instance.AddCoinWithEffect(flavor.Price * (1 + bonusRate / 100), () => { });
|
||||
// 売上反映
|
||||
GameDataManager.GameData.coin = CoinManager.Instance.OwnCoin;
|
||||
GameDataManager.SaveGameData();
|
||||
// 自動補充 refill
|
||||
RefillProduct();
|
||||
StockFlavorLog();
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
private void RefillProduct()
|
||||
{
|
||||
// 店頭に補充
|
||||
// 手前のタンクから出し多分stockをへらす
|
||||
// へらした分を店頭リストに追加する
|
||||
// 店頭とタンクのフレーバーの扱いが違うのに注意
|
||||
// 店頭にはフレーバーごとに並び順があるのでリストに1つづつ入れる必要がある
|
||||
var gameData = GameDataManager.GameData;
|
||||
var shopSpace = ShopStockCount - gameData.ShopStock.Count;
|
||||
var index = 0;
|
||||
var tankCount = gameData.StorageTanks.Count;
|
||||
while (shopSpace > 0)
|
||||
{
|
||||
CoinManager.Instance.AddCoinWithEffect(300, () => { });
|
||||
}).AddTo(this);
|
||||
if (index > tankCount - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
var tank = gameData.StorageTanks[index];
|
||||
var stockCount = Mathf.Min(shopSpace, tank.Stock);
|
||||
gameData.ShopStock.AddRange(Enumerable.Repeat(tank.FlavorId, stockCount));
|
||||
shopSpace -= stockCount;
|
||||
tank.Stock -= stockCount;
|
||||
gameData.StorageTanks[index] = tank;
|
||||
index++;
|
||||
}
|
||||
GameDataManager.SaveGameData();
|
||||
}
|
||||
|
||||
public static void StockFlavorLog()
|
||||
{
|
||||
var gameData = GameDataManager.GameData;
|
||||
var shopStockString = "";
|
||||
foreach (var data in RecipeData.GetAllRecipe())
|
||||
{
|
||||
var shopStockCount = gameData.ShopStock.FindAll(x => x == data.RecipeId).Count;
|
||||
var tank = gameData.StorageTanks.FindAll(x => x.FlavorId == data.RecipeId).Sum(x => x.Stock);
|
||||
if (shopStockCount + tank == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
shopStockString += $"{data.Name} shop:{shopStockCount} stock:{tank}\n";
|
||||
}
|
||||
Debug.Log(shopStockString);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
|
|
|||
|
|
@ -1900,6 +1900,72 @@ Transform:
|
|||
m_Father: {fileID: 203299121}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &865915984
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 865915987}
|
||||
- component: {fileID: 865915986}
|
||||
- component: {fileID: 865915985}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &865915985
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 865915984}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_HorizontalAxis: Horizontal
|
||||
m_VerticalAxis: Vertical
|
||||
m_SubmitButton: Submit
|
||||
m_CancelButton: Cancel
|
||||
m_InputActionsPerSecond: 10
|
||||
m_RepeatDelay: 0.5
|
||||
m_ForceModuleActive: 0
|
||||
--- !u!114 &865915986
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 865915984}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_FirstSelected: {fileID: 0}
|
||||
m_sendNavigationEvents: 1
|
||||
m_DragThreshold: 10
|
||||
--- !u!4 &865915987
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 865915984}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &887630637
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -2224,7 +2290,7 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 6
|
||||
m_RootOrder: 7
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1025201116
|
||||
MonoBehaviour:
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ public class RecipeDetailView : MonoBehaviour
|
|||
gameData.Material[flavorIndex1] = stockMaterial1;
|
||||
if (data.Flavors.Count == 2)
|
||||
{
|
||||
var flavorIndex2 = gameData.Material.FindIndex(x => x.id == data.Flavors[0].id);
|
||||
var flavorIndex2 = gameData.Material.FindIndex(x => x.id == data.Flavors[1].id);
|
||||
var stockMaterial2 = gameData.Material[flavorIndex2];
|
||||
stockMaterial2.amount -= data.Flavors[0].amount;
|
||||
stockMaterial2.amount -= data.Flavors[1].amount;
|
||||
gameData.Material[flavorIndex2] = stockMaterial2;
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ public class RecipeDetailView : MonoBehaviour
|
|||
var flavor2Amount = 0;
|
||||
if (data.Flavors.Count == 2)
|
||||
{
|
||||
var flavorIndex2 = gameData.Material.FindIndex(x => x.id == data.Flavors[0].id);
|
||||
var flavorIndex2 = gameData.Material.FindIndex(x => x.id == data.Flavors[1].id);
|
||||
if (flavorIndex2 != -1)
|
||||
{
|
||||
flavor2Amount = gameData.Material[flavorIndex2].amount;
|
||||
|
|
|
|||
|
|
@ -44,11 +44,10 @@ public class CoinManager : SingletonMonoBehaviour<CoinManager>
|
|||
{
|
||||
ownCoin += count;
|
||||
// 生成枚数決定
|
||||
var spawnCount = Mathf.Min(count, 7);
|
||||
// 生成ポジション決め、生成
|
||||
InstantiateEffeect(coinPrefab, spawnCount, Vector3.zero, coinIconTransform.position, () =>
|
||||
InstantiateEffeect(coinPrefab, count, Vector3.zero, coinIconTransform.position, () =>
|
||||
{
|
||||
coinCountText.CountUpAnimation(coinTextFormat, ownCoin, duration + spawnCount * 0.1f);
|
||||
coinCountText.CountUpAnimation(coinTextFormat, ownCoin, duration + count * 0.1f);
|
||||
callback.Invoke();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue