Merge branch 'develop' of bitbucket.org:usaya/popcorn into develop
This commit is contained in:
commit
219913a3f6
|
|
@ -1,5 +1,154 @@
|
||||||
%YAML 1.1
|
%YAML 1.1
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &2895484395707725730
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1272573749203266507}
|
||||||
|
- component: {fileID: 4707019036817275407}
|
||||||
|
- component: {fileID: 5887917383623105892}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Image_text
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &1272573749203266507
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2895484395707725730}
|
||||||
|
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: 7070062469376303877}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchoredPosition: {x: 2.9, y: 4}
|
||||||
|
m_SizeDelta: {x: 66, y: 40}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!222 &4707019036817275407
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2895484395707725730}
|
||||||
|
m_CullTransparentMesh: 0
|
||||||
|
--- !u!114 &5887917383623105892
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2895484395707725730}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 0
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 21300000, guid: 1ed7a6eade5a3af4c962706dec098104, type: 3}
|
||||||
|
m_Type: 0
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!1 &7845949066005219734
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 7070062469376303877}
|
||||||
|
- component: {fileID: 1561612110923996906}
|
||||||
|
- component: {fileID: 7043889385648676325}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Button_Purchase_Off
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 0
|
||||||
|
--- !u!224 &7070062469376303877
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7845949066005219734}
|
||||||
|
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:
|
||||||
|
- {fileID: 1272573749203266507}
|
||||||
|
m_Father: {fileID: 9133304336500199661}
|
||||||
|
m_RootOrder: 2
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0.5, y: 0}
|
||||||
|
m_AnchorMax: {x: 0.5, y: 0}
|
||||||
|
m_AnchoredPosition: {x: 140, y: 125.10004}
|
||||||
|
m_SizeDelta: {x: 240, y: 98}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!222 &1561612110923996906
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7845949066005219734}
|
||||||
|
m_CullTransparentMesh: 0
|
||||||
|
--- !u!114 &7043889385648676325
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7845949066005219734}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 21300000, guid: 8539f0168ede4654dbdbe738754bdb2f, type: 3}
|
||||||
|
m_Type: 1
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
--- !u!1 &9133304335139982201
|
--- !u!1 &9133304335139982201
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -134,7 +283,8 @@ MonoBehaviour:
|
||||||
subCountButton: {fileID: 5919954079663981596}
|
subCountButton: {fileID: 5919954079663981596}
|
||||||
addCountButton: {fileID: 5919954079471528431}
|
addCountButton: {fileID: 5919954079471528431}
|
||||||
closeButton: {fileID: 9133304335940276437}
|
closeButton: {fileID: 9133304335940276437}
|
||||||
purchaseButton: {fileID: 9133304335268316946}
|
purchaseOnButton: {fileID: 9133304335268316946}
|
||||||
|
purchaseOffButton: {fileID: 7845949066005219734}
|
||||||
--- !u!1 &9133304335268316944
|
--- !u!1 &9133304335268316944
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -148,7 +298,7 @@ GameObject:
|
||||||
- component: {fileID: 9133304335268316949}
|
- component: {fileID: 9133304335268316949}
|
||||||
- component: {fileID: 9133304335268316946}
|
- component: {fileID: 9133304335268316946}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Button_Purchase
|
m_Name: Button_Purchase_On
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
|
|
@ -569,7 +719,7 @@ RectTransform:
|
||||||
- {fileID: 9133304336181127573}
|
- {fileID: 9133304336181127573}
|
||||||
- {fileID: 9133304337054428178}
|
- {fileID: 9133304337054428178}
|
||||||
m_Father: {fileID: 9133304336500199661}
|
m_Father: {fileID: 9133304336500199661}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 5
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
|
|
@ -1597,6 +1747,7 @@ RectTransform:
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 9133304335940276434}
|
- {fileID: 9133304335940276434}
|
||||||
- {fileID: 9133304335268316947}
|
- {fileID: 9133304335268316947}
|
||||||
|
- {fileID: 7070062469376303877}
|
||||||
- {fileID: 9133304337032816943}
|
- {fileID: 9133304337032816943}
|
||||||
- {fileID: 9133304336675516546}
|
- {fileID: 9133304336675516546}
|
||||||
- {fileID: 9133304335380453066}
|
- {fileID: 9133304335380453066}
|
||||||
|
|
@ -1899,7 +2050,7 @@ RectTransform:
|
||||||
- {fileID: 9133304335893567655}
|
- {fileID: 9133304335893567655}
|
||||||
- {fileID: 9133304335334808081}
|
- {fileID: 9133304335334808081}
|
||||||
m_Father: {fileID: 9133304336500199661}
|
m_Father: {fileID: 9133304336500199661}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 4
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 1}
|
m_AnchorMin: {x: 0.5, y: 1}
|
||||||
m_AnchorMax: {x: 0.5, y: 1}
|
m_AnchorMax: {x: 0.5, y: 1}
|
||||||
|
|
@ -2166,7 +2317,7 @@ RectTransform:
|
||||||
- {fileID: 9133304336883555446}
|
- {fileID: 9133304336883555446}
|
||||||
- {fileID: 9133304336944246770}
|
- {fileID: 9133304336944246770}
|
||||||
m_Father: {fileID: 9133304336500199661}
|
m_Father: {fileID: 9133304336500199661}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 3
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 1}
|
m_AnchorMin: {x: 0.5, y: 1}
|
||||||
m_AnchorMax: {x: 0.5, y: 1}
|
m_AnchorMax: {x: 0.5, y: 1}
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,17 @@ public class ShopItemPurchaseView : MonoBehaviour
|
||||||
[SerializeField] private Button subCountButton;
|
[SerializeField] private Button subCountButton;
|
||||||
[SerializeField] private Button addCountButton;
|
[SerializeField] private Button addCountButton;
|
||||||
[SerializeField] private Button closeButton;
|
[SerializeField] private Button closeButton;
|
||||||
[SerializeField] private Button purchaseButton;
|
[SerializeField] private Button purchaseOnButton;
|
||||||
|
[SerializeField] private GameObject purchaseOffButton;
|
||||||
public IObservable<Unit> PurchaseButtonObservable => purchaseButton.OnClickAsObservable().TakeUntilDestroy(this);
|
|
||||||
|
|
||||||
|
private Color defaultColor;
|
||||||
private readonly IntReactiveProperty currentCount = new IntReactiveProperty();
|
private readonly IntReactiveProperty currentCount = new IntReactiveProperty();
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
currentCount.AddTo(this);
|
currentCount.AddTo(this);
|
||||||
|
defaultColor = totalPrice.color;
|
||||||
var data = LocalCacheManager.Load<(ShopData shopData, int stockCount)>(ItemPurchaseTag);
|
var data = LocalCacheManager.Load<(ShopData shopData, int stockCount, Action<int> callback)>(ItemPurchaseTag);
|
||||||
|
LocalCacheManager.Remove(ItemPurchaseTag);
|
||||||
SetData(data.shopData, data.stockCount);
|
SetData(data.shopData, data.stockCount);
|
||||||
closeButton.OnClickAsObservable().Subscribe(_ =>
|
closeButton.OnClickAsObservable().Subscribe(_ =>
|
||||||
{
|
{
|
||||||
|
|
@ -41,8 +42,9 @@ public class ShopItemPurchaseView : MonoBehaviour
|
||||||
TransitionManager.Instance.UnloadScene(GameScenes.Purchase);
|
TransitionManager.Instance.UnloadScene(GameScenes.Purchase);
|
||||||
});
|
});
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
purchaseButton.OnClickAsObservable().Subscribe(_ =>
|
purchaseOnButton.OnClickAsObservable().Subscribe(_ =>
|
||||||
{
|
{
|
||||||
|
data.callback.Invoke(currentCount.Value);
|
||||||
transform.SetLocalScale(0);
|
transform.SetLocalScale(0);
|
||||||
backgroundAnimator.SetTrigger(CloseTrigger);
|
backgroundAnimator.SetTrigger(CloseTrigger);
|
||||||
this.CallWaitForSeconds(.25f, () =>
|
this.CallWaitForSeconds(.25f, () =>
|
||||||
|
|
@ -54,16 +56,25 @@ public class ShopItemPurchaseView : MonoBehaviour
|
||||||
currentCount.Value = MinPurchaseCount;
|
currentCount.Value = MinPurchaseCount;
|
||||||
currentCount.Subscribe(x =>
|
currentCount.Subscribe(x =>
|
||||||
{
|
{
|
||||||
|
var total = data.shopData.price * x;
|
||||||
|
SetButtonActive(total <= CoinManager.Instance.OwnCoin);
|
||||||
|
totalPrice.color = total <= CoinManager.Instance.OwnCoin ? defaultColor : Color.red;
|
||||||
|
totalPrice.text = $"{total}";
|
||||||
purchaseCount.text = $"{x}";
|
purchaseCount.text = $"{x}";
|
||||||
totalPrice.text = $"{data.shopData.price * x}";
|
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
addCountButton.OnClickAsObservable().Select(_ => 1)
|
if (data.shopData.ConsumeType == ShopItemType.Consumable)
|
||||||
.Merge(subCountButton.OnClickAsObservable().Select(_ => -1))
|
{
|
||||||
.Subscribe(x =>
|
addCountButton.OnClickAsObservable().Select(_ => 1)
|
||||||
{
|
.Merge(subCountButton.OnClickAsObservable().Select(_ => -1))
|
||||||
currentCount.Value = Mathf.Clamp(currentCount.Value + x, MinPurchaseCount, MaxPurchaseCount);
|
.Subscribe(x =>
|
||||||
|
{
|
||||||
}).AddTo(this);
|
currentCount.Value = Mathf.Clamp(currentCount.Value + x, MinPurchaseCount, MaxPurchaseCount);
|
||||||
|
}).AddTo(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentCount.Value = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetData(ShopData shopData, int count)
|
private void SetData(ShopData shopData, int count)
|
||||||
|
|
@ -72,4 +83,10 @@ public class ShopItemPurchaseView : MonoBehaviour
|
||||||
price.text = $"{shopData.price}";
|
price.text = $"{shopData.price}";
|
||||||
stockCount.text = $"所持数 :{count}";
|
stockCount.text = $"所持数 :{count}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetButtonActive(bool active)
|
||||||
|
{
|
||||||
|
purchaseOnButton.gameObject.SetActive(active);
|
||||||
|
purchaseOffButton.SetActive(!active);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,19 +27,26 @@ public class Shopping : MonoBehaviour
|
||||||
{
|
{
|
||||||
itemView.SetItemActive(shopData.price <= ownCoin);
|
itemView.SetItemActive(shopData.price <= ownCoin);
|
||||||
}).AddTo(this);
|
}).AddTo(this);
|
||||||
|
var purchaseSubject = new Subject<int>();
|
||||||
|
purchaseSubject.AddTo(itemView);
|
||||||
|
purchaseSubject.Subscribe(amount =>
|
||||||
|
{
|
||||||
|
// アイテムを増やす
|
||||||
|
AddItem(shopData, amount);
|
||||||
|
itemView.SetStockCount(GetItemAmount(shopData));
|
||||||
|
CoinManager.Instance.SubCoin(shopData.price * amount);
|
||||||
|
gameData.coin = CoinManager.Instance.OwnCoin;
|
||||||
|
changeCoinSubject.OnNext(gameData.coin);
|
||||||
|
GameDataManager.SaveGameData();
|
||||||
|
}).AddTo(itemView);
|
||||||
// アイテム購入クリック購読
|
// アイテム購入クリック購読
|
||||||
itemView.PurchaseButtonObservable
|
itemView.PurchaseButtonObservable
|
||||||
.Where(_ => shopData.price <= CoinManager.Instance.OwnCoin)
|
.Where(_ => shopData.price <= CoinManager.Instance.OwnCoin)
|
||||||
.Subscribe(_ =>
|
.Subscribe(_ =>
|
||||||
{
|
{
|
||||||
// アイテムを増やす
|
LocalCacheManager.Save(ShopItemPurchaseView.ItemPurchaseTag, (shopData, GetItemAmount(shopData), new Action<int>(x => purchaseSubject.OnNext(x))));
|
||||||
AddItem(shopData);
|
TransitionManager.Instance.LoadSceneAdditive(GameScenes.Purchase);
|
||||||
itemView.SetStockCount(GetItemAmount(shopData));
|
}).AddTo(itemView);
|
||||||
CoinManager.Instance.SubCoin(shopData.price);
|
|
||||||
gameData.coin = CoinManager.Instance.OwnCoin;
|
|
||||||
changeCoinSubject.OnNext(gameData.coin);
|
|
||||||
GameDataManager.SaveGameData();
|
|
||||||
}).AddTo(itemView);
|
|
||||||
}
|
}
|
||||||
changeCoinSubject.OnNext(CoinManager.Instance.OwnCoin);
|
changeCoinSubject.OnNext(CoinManager.Instance.OwnCoin);
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +67,7 @@ public class Shopping : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddItem(ShopData shopData)
|
private void AddItem(ShopData shopData, int amount)
|
||||||
{
|
{
|
||||||
var gameData = GameDataManager.GameData;
|
var gameData = GameDataManager.GameData;
|
||||||
switch (shopData.Category)
|
switch (shopData.Category)
|
||||||
|
|
@ -69,16 +76,14 @@ public class Shopping : MonoBehaviour
|
||||||
var index = gameData.Material.FindIndex(x => x.Id == shopData.itemId);
|
var index = gameData.Material.FindIndex(x => x.Id == shopData.itemId);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
|
index = gameData.Material.Count;
|
||||||
gameData.Material.Add(new MaterialData
|
gameData.Material.Add(new MaterialData
|
||||||
{
|
{
|
||||||
Id = shopData.itemId,
|
Id = shopData.itemId,
|
||||||
Amount = 1
|
Amount = 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
gameData.Material[index].Amount += amount;
|
||||||
{
|
|
||||||
gameData.Material[index].Amount++;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ItemCategory.Recipe:
|
case ItemCategory.Recipe:
|
||||||
if (!gameData.MyRecipes.Contains(shopData.itemId))
|
if (!gameData.MyRecipes.Contains(shopData.itemId))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue