diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs index 18a324fd..7b4a62d5 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrder.cs @@ -150,7 +150,7 @@ public class BulkOrder : MonoBehaviour var countByVolume = bulkOrderData.count1 / data1.volume; var productData = new ProductData(data1, countByVolume); productData.volume *= countByVolume; - itemView1.SetData(productData); + itemView1.SetData(productData,1); if (gameData.CompletedProductList.FirstOrDefault(data => data.Number == 1) is BulkOrderResultData resultData) { itemView1.SetCooked(resultData.Rarity); @@ -177,7 +177,7 @@ public class BulkOrder : MonoBehaviour var countByVolume = bulkOrderData.count2 / data2.volume; var productData = new ProductData(data2, countByVolume); productData.volume *= countByVolume; - itemView2.SetData(productData); + itemView2.SetData(productData,2); if (gameData.CompletedProductList.FirstOrDefault(data => data.Number == 2) is BulkOrderResultData resultData) { itemView2.SetCooked(resultData.Rarity); @@ -204,7 +204,7 @@ public class BulkOrder : MonoBehaviour var countByVolume = bulkOrderData.count3 / data3.volume; var productData = new ProductData(data3, countByVolume); productData.volume *= countByVolume; - itemView3.SetData(productData); + itemView3.SetData(productData,3); if (gameData.CompletedProductList.FirstOrDefault(data => data.Number == 3) is BulkOrderResultData resultData) { itemView3.SetCooked(resultData.Rarity); diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrderItemView.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrderItemView.cs index 952980a3..87de1be5 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrderItemView.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/BulkOrderItemView.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using MyGame.Scripts; using UniRx; using UnityEngine; using UnityEngine.UI; @@ -25,13 +26,18 @@ public class BulkOrderItemView : MonoBehaviour public IObservable CookingButton => cookingButton.OnClickAsObservable().TakeUntilDestroy(this); + + private void Awake() { ColorUtility.TryParseHtmlString(Const.RedColorString, out redColor); } - - public void SetData(ProductData data) + ProductData m_data; + int m_number; + public void SetData(ProductData data,int number) { + m_data = data; + m_number = number; stockText.text = data.volume.ToString(); nameText.text = data.Name; cornText.text = string.Format(amountFormat, data.MaterialList[0].amount); @@ -56,7 +62,7 @@ public class BulkOrderItemView : MonoBehaviour material2Text.transform.parent.gameObject.SetActive(false); } - disabledObject.OnClickAsObservable().Take(1).Subscribe(_ => + disabledObject.OnClickAsObservable().Subscribe(_ => { onClichJump(data); @@ -70,23 +76,130 @@ public class BulkOrderItemView : MonoBehaviour var checkResult = CheckAmounts(productData); if (!checkResult.material1) { - - TransitionManager.Instance.LoadScene(GameScenes.CornField); + GetRewardDialog.ShowCollectCornDialog(() => + { + TransitionManager.Instance.LoadScene(GameScenes.CornField); + }, null); } if (!checkResult.material2) { TransitionManager.Instance.JumpId = productData.MaterialList[1].id; - TransitionManager.Instance.LoadScene(GameScenes.shopping); + } if (!checkResult.material3) { - TransitionManager.Instance.JumpId = productData.MaterialList[2].id; - TransitionManager.Instance.LoadScene(GameScenes.shopping); + TransitionManager.Instance.JumpId2 = productData.MaterialList[2].id; + + } + if (!checkResult.material2 || !checkResult.material3) + { + if (!checkResult.material1) + { + return; + } + + + if (!checkResult.material2 && !checkResult.material3) + { + Jump(TransitionManager.Instance.JumpId); + TransitionManager.Instance.JumpId = -1; + + + if (TransitionManager.Instance.JumpId2 != -1) + { + ShopItemPurchaseView.jumpPurchaseAction = Jump; + } + } + else if (!checkResult.material2) + { + Jump(TransitionManager.Instance.JumpId); + TransitionManager.Instance.JumpId = -1; + } + else if (!checkResult.material3) + { + Jump(TransitionManager.Instance.JumpId2); + TransitionManager.Instance.JumpId2 = -1; + + } } } + ShopData GetShopData(int itemid) + { + var shopDataList = SpreadsheetDataManager.Instance.GetBaseDataList(Const.ShopDataSheet); + + var filteredShopDataList = shopDataList + .Where(data => !data.IsHide) + .Where(data => data.Category != ItemCategory.Special); + + foreach (var shopData in filteredShopDataList) + { + if (shopData.itemId == itemid) + { + return shopData; + } + } + return null; + + } + + + void Jump(int itemid) + { + ShopData shopData = GetShopData(itemid); + var gameData = GameDataManager.GameData; + if (null == shopData) + { + Debug.Log("null== shopData"); + } + + else if (CoinManager.Instance.OwnCoin < shopData.price) + { + GetRewardDialog.ShowUnColdDialog(() => + { + Debug.Log("金币不足"); + }, null); + } + else if (!ShopItemPurchaseView.jumpPurchase) + { + + + + ShopItemPurchaseView.ShowDialog((shopData, Shopping.GetItemAmount(shopData)), (amount, amount1) => + { + // アイテムを増やす + Shopping.AddItem(shopData, amount); + + if (amount1 != -1) + { + CoinManager.Instance.SubCoin(amount1 * amount); + } + else + { + CoinManager.Instance.SubCoin(shopData.price * amount); + + } + + + gameData.Coin = CoinManager.Instance.OwnCoin; + + GameDataManager.SaveGameData(); + + if (gameData.CompletedProductList.FirstOrDefault(data => data.Number == m_number) is BulkOrderResultData resultData) + { + SetCooked(resultData.Rarity); + } + else + { + SetButtonActive(CheckAmount(m_data)); + } + }); + + } + } + public static (bool material1, bool material2, bool material3) CheckAmounts(ProductData productData) { (bool a, bool b, bool c) flags = (true, true, true); @@ -116,16 +229,28 @@ public class BulkOrderItemView : MonoBehaviour flag = false; cornText.color = redColor; } + else + { + cornText.color = new Color(110 / 255f, 76 / 255f, 49 / 255f); + } if ((gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[1].id)?.Amount ?? 0) < productData.MaterialList[1].amount) { flag = false; material1Text.color = redColor; } + else + { + material1Text.color = new Color(110 / 255f, 76 / 255f, 49 / 255f); + } if (productData.GetMaterialCount() == 3 && (gameData.Material.FirstOrDefault(data => data.Id == productData.MaterialList[2].id)?.Amount ?? 0) < productData.MaterialList[2].amount) { flag = false; material2Text.color = redColor; } + else + { + material2Text.color = new Color(110 / 255f, 76 / 255f, 49 / 255f); + } return flag; } diff --git a/popcorn/Assets/MyGame/Scenes/Main/WatchMovieCoin.unity b/popcorn/Assets/MyGame/Scenes/Main/WatchMovieCoin.unity index 20547920..f4feee96 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/WatchMovieCoin.unity +++ b/popcorn/Assets/MyGame/Scenes/Main/WatchMovieCoin.unity @@ -767,6 +767,142 @@ MonoBehaviour: randomPlaySEFilenames: [] randomPlayVoiceFilenames: [] vibrationType: 0 +--- !u!1 &239688310 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 239688311} + - component: {fileID: 239688315} + - component: {fileID: 239688314} + - component: {fileID: 239688313} + - component: {fileID: 239688312} + m_Layer: 5 + m_Name: Button_OK + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &239688311 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 239688310} + 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: 1474298701} + m_Father: {fileID: 361105480} + 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: 61} + m_SizeDelta: {x: 250, y: 130} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &239688312 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 239688310} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5e732834936f04d48be0ff3fa358563d, type: 3} + m_Name: + m_EditorClassIdentifier: + onClickPlaySEFilename: se_ButtonTap + randomPlaySEFilenames: [] + randomPlayVoiceFilenames: [] + vibrationType: 0 +--- !u!114 &239688313 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 239688310} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 239688314} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &239688314 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 239688310} + 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: aa7d3d5ac0992464fb8f1491617b73bd, 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!222 &239688315 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 239688310} + m_CullTransparentMesh: 0 --- !u!1 &251547152 GameObject: m_ObjectHideFlags: 0 @@ -908,6 +1044,7 @@ RectTransform: m_Children: - {fileID: 4540745} - {fileID: 208413210} + - {fileID: 239688311} - {fileID: 504822411} - {fileID: 1718841269} m_Father: {fileID: 1336838852} @@ -1066,6 +1203,19 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 371454779} m_CullTransparentMesh: 0 +--- !u!114 &407448970 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bedef2aeaac8da04faa9a07b7241d0ad, type: 3} + m_Name: + m_EditorClassIdentifier: + mTarget: {fileID: 1474298703} --- !u!1 &422199534 GameObject: m_ObjectHideFlags: 0 @@ -1264,7 +1414,7 @@ RectTransform: - {fileID: 251547153} - {fileID: 1793920306} m_Father: {fileID: 361105480} - m_RootOrder: 2 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -1929,6 +2079,7 @@ MonoBehaviour: backgroundAnimator: {fileID: 1298517019} closeButton: {fileID: 4540746} okButton: {fileID: 208413211} + okCornButton: {fileID: 239688313} messageText: {fileID: 1879265584} narrowCloseButton: {fileID: 371454782} narrowOkButton: {fileID: 1986250439} @@ -2057,6 +2208,121 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1469609942} m_CullTransparentMesh: 0 +--- !u!1 &1474298700 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1474298701} + - component: {fileID: 1474298704} + - component: {fileID: 1474298703} + - component: {fileID: 1474298702} + 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 &1474298701 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1474298700} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1.3, y: 1.3, z: 1.3} + m_Children: [] + m_Father: {fileID: 239688311} + 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: 64, y: 42} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1474298702 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1474298700} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 344445a89b4f74a0e9a0a766903df87e, type: 3} + m_Name: + m_EditorClassIdentifier: + mTerm: ui_button_icon_ok_logo_big + mTermSecondary: + PrimaryTermModifier: 0 + SecondaryTermModifier: 0 + TermPrefix: + TermSuffix: + LocalizeOnAwake: 1 + IgnoreRTL: 0 + MaxCharactersInRTL: 0 + IgnoreNumbersInRTL: 1 + CorrectAlignmentForRTL: 1 + AddSpacesToJoinedLanguages: 0 + AllowLocalizedParameters: 1 + AllowParameters: 1 + TranslatedObjects: + - {fileID: 21300000, guid: 4372cbbdff809454881ff362f84c540c, type: 3} + LocalizeEvent: + m_PersistentCalls: + m_Calls: [] + AlwaysForceLocalize: 0 + LocalizeCallBack: + Target: {fileID: 0} + MethodName: + mGUI_ShowReferences: 0 + mGUI_ShowTems: 1 + mGUI_ShowCallback: 0 + mLocalizeTarget: {fileID: 407448970} + mLocalizeTargetName: I2.Loc.LocalizeTarget_UnityUI_Image +--- !u!114 &1474298703 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1474298700} + 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: 4372cbbdff809454881ff362f84c540c, 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!222 &1474298704 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1474298700} + m_CullTransparentMesh: 0 --- !u!1 &1664081616 GameObject: m_ObjectHideFlags: 0 @@ -2331,7 +2597,7 @@ RectTransform: m_Children: - {fileID: 1879265583} m_Father: {fileID: 361105480} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} diff --git a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs index 1d62936b..5519f83d 100644 --- a/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs +++ b/popcorn/Assets/MyGame/Scenes/recipe/Scripts/RecipeDetailView.cs @@ -36,8 +36,11 @@ public class RecipeDetailView : MonoBehaviour private Color redColor; + + private void Start() { + ShopItemPurchaseView.refashStart = Start; ColorUtility.TryParseHtmlString(Const.RedColorString, out redColor); var viewType = LocalCacheManager.Load(Const.ProductViewTypeTag, ProductViewType.Default); var data = LocalCacheManager.Load(PopcornGameManager.CookingDataTag); @@ -100,7 +103,7 @@ public class RecipeDetailView : MonoBehaviour throw new ArgumentOutOfRangeException(); } - disabledNextButton.OnClickAsObservable().Take(1).Subscribe(_ => + disabledNextButton.OnClickAsObservable().Subscribe(_ => { onClichJump(data); @@ -112,22 +115,125 @@ public class RecipeDetailView : MonoBehaviour var checkResult = CheckAmount(productData); if (!checkResult.material1) { - - TransitionManager.Instance.LoadScene(GameScenes.CornField); + GetRewardDialog.ShowCollectCornDialog(() => + { + TransitionManager.Instance.LoadScene(GameScenes.CornField); + }, null); + } if (!checkResult.material2) { TransitionManager.Instance.JumpId = productData.MaterialList[1].id; - TransitionManager.Instance.LoadScene(GameScenes.shopping); + + } if (!checkResult.material3) { - TransitionManager.Instance.JumpId = productData.MaterialList[2].id; - TransitionManager.Instance.LoadScene(GameScenes.shopping); + TransitionManager.Instance.JumpId2 = productData.MaterialList[2].id; + + } + if (!checkResult.material2|| !checkResult.material3) + { + if (!checkResult.material1) + { + return; + } + + + if (!checkResult.material2 && !checkResult.material3) + { + Jump(TransitionManager.Instance.JumpId); + TransitionManager.Instance.JumpId = -1; + + + if (TransitionManager.Instance.JumpId2 != -1) + { + ShopItemPurchaseView.jumpPurchaseAction = Jump; + } + } + else if(!checkResult.material2) + { + Jump(TransitionManager.Instance.JumpId); + TransitionManager.Instance.JumpId = -1; + } + else if (!checkResult.material3) + { + Jump(TransitionManager.Instance.JumpId2); + TransitionManager.Instance.JumpId2 = -1; + + } } } + ShopData GetShopData(int itemid) + { + var shopDataList = SpreadsheetDataManager.Instance.GetBaseDataList(Const.ShopDataSheet); + + var filteredShopDataList = shopDataList + .Where(data => !data.IsHide) + .Where(data => data.Category != ItemCategory.Special); + + foreach (var shopData in filteredShopDataList) + { + if (shopData.itemId==itemid) + { + return shopData; + } + } + return null; + + } + + + void Jump(int itemid) + { + ShopData shopData = GetShopData(itemid); + var gameData = GameDataManager.GameData; + if (null== shopData) + { + Debug.Log("null== shopData"); + } + + else if (CoinManager.Instance.OwnCoin < shopData.price) + { + GetRewardDialog.ShowUnColdDialog(()=> + { + Debug.Log("金币不足"); + }, null); + } + else if (!ShopItemPurchaseView.jumpPurchase) + { + + + + ShopItemPurchaseView.ShowDialog((shopData, Shopping.GetItemAmount(shopData)), (amount, amount1) => + { + // アイテムを増やす + Shopping.AddItem(shopData, amount); + + if (amount1 != -1) + { + CoinManager.Instance.SubCoin(amount1 * amount); + } + else + { + CoinManager.Instance.SubCoin(shopData.price * amount); + + } + + + gameData.Coin = CoinManager.Instance.OwnCoin; + + GameDataManager.SaveGameData(); + }); + + } + } + + + + public static void ConsumeMaterial(ProductData productData) { var gameData = GameDataManager.GameData; @@ -201,14 +307,26 @@ public class RecipeDetailView : MonoBehaviour { cornAmountText.color = redColor; } + else + { + cornAmountText.color = new Color(110 / 255f, 76 / 255f, 49 / 255f); + } if (!checkResult.material2) { flavor1AmountText.color = redColor; } + else + { + flavor1AmountText.color = new Color(110 / 255f, 76 / 255f, 49 / 255f); + } if (!checkResult.material3) { flavor2AmountText.color = redColor; } + else + { + flavor2AmountText.color = new Color(110 / 255f, 76 / 255f, 49 / 255f); + } return checkResult.material1 && checkResult.material2 && checkResult.material3; } diff --git a/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemPurchaseView.cs b/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemPurchaseView.cs index 1a534015..eb423761 100644 --- a/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemPurchaseView.cs +++ b/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemPurchaseView.cs @@ -36,6 +36,13 @@ public class ShopItemPurchaseView : MonoBehaviour private Color defaultColor; private readonly IntReactiveProperty currentCount = new IntReactiveProperty(); int nowprice = -1; + + public static bool jumpPurchase=false; + + public static Action jumpPurchaseAction ; + + public static Action refashStart; + private void Start() { currentCount.AddTo(this); @@ -126,9 +133,25 @@ public class ShopItemPurchaseView : MonoBehaviour purchaseOnButton.gameObject.SetActive(active); purchaseOffButton.SetActive(!active); } + private void OnDestroy() + { + jumpPurchase = false; + if (null!= jumpPurchaseAction&& TransitionManager.Instance.JumpId2!=-1) + { + jumpPurchaseAction(TransitionManager.Instance.JumpId2); + jumpPurchaseAction = null; + TransitionManager.Instance.JumpId2 = -1; + } + + if (null!= refashStart) + { + refashStart(); + } + } public static void ShowDialog((ShopData shopData, int stockCount) data, Action onPurchase, Action onClose = null) { + jumpPurchase = true; LocalCacheManager.Save(ItemPurchaseTag, data); LocalCacheManager.Save(PurchaseCallbackTag, onPurchase); LocalCacheManager.Save(CloseCallbackTag, onClose); diff --git a/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemView.cs b/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemView.cs index 7207995c..324cee45 100644 --- a/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemView.cs +++ b/popcorn/Assets/MyGame/Scenes/shopping/Scripts/ShopItemView.cs @@ -138,15 +138,42 @@ public class ShopItemView : MonoBehaviour soldOutObject.SetActive(true); } SetItemActive(shopData.price <= CoinManager.Instance.OwnCoin); - var gameData = GameDataManager.GameData; - if (shopData.price <= gameData.Coin&& TransitionManager.Instance.JumpId!=-1) - { - if (null!= jumpPurchase&& TransitionManager.Instance.JumpId== shopData.itemId) - { - jumpPurchase(); - TransitionManager.Instance.JumpId = -1; - } - } + //var gameData = GameDataManager.GameData; + //if (shopData.price <= gameData.Coin&& (TransitionManager.Instance.JumpId!=-1|| TransitionManager.Instance.JumpId2 != -1)) + //{ + // if (null!= jumpPurchase) + // { + // if (TransitionManager.Instance.JumpId == shopData.itemId) + // { + // TransitionManager.Instance.JumpId = -1; + // if (ShopItemPurchaseView.jumpPurchase) + // { + // ShopItemPurchaseView.jumpPurchaseAction = jumpPurchase; + // } + // else + // { + // jumpPurchase(); + + // } + + // } + // if (TransitionManager.Instance.JumpId2 == shopData.itemId) + // { + + // TransitionManager.Instance.JumpId2 = -1; + // if (ShopItemPurchaseView.jumpPurchase) + // { + // ShopItemPurchaseView.jumpPurchaseAction = jumpPurchase; + // } + // else + // { + // jumpPurchase(); + + // } + + // } + // } + //} } private void OnDestroy() diff --git a/popcorn/Assets/MyGame/Scenes/shopping/Scripts/Shopping.cs b/popcorn/Assets/MyGame/Scenes/shopping/Scripts/Shopping.cs index 274a6636..34f04085 100644 --- a/popcorn/Assets/MyGame/Scenes/shopping/Scripts/Shopping.cs +++ b/popcorn/Assets/MyGame/Scenes/shopping/Scripts/Shopping.cs @@ -235,7 +235,7 @@ public class Shopping : MonoBehaviour } } - private static int GetItemAmount(ShopData shopData) + public static int GetItemAmount(ShopData shopData) { var gameData = GameDataManager.GameData; switch (shopData.Category) diff --git a/popcorn/Assets/MyGame/Scripts/GetRewardDialog.cs b/popcorn/Assets/MyGame/Scripts/GetRewardDialog.cs index e99a4770..9dc84778 100644 --- a/popcorn/Assets/MyGame/Scripts/GetRewardDialog.cs +++ b/popcorn/Assets/MyGame/Scripts/GetRewardDialog.cs @@ -19,7 +19,9 @@ namespace MyGame.Scripts Butter, StrawBerry, Sale, - Cold + Cold, + UnCoin, + CollectCorn } private static readonly string OkCallbackTag = "GetRewardDialogOkCallbackTag"; @@ -33,6 +35,9 @@ namespace MyGame.Scripts [SerializeField] private Animator backgroundAnimator; [SerializeField] private Button closeButton; [SerializeField] private Button okButton; + + [SerializeField] private Button okCornButton; + [SerializeField] private Text messageText; [SerializeField] private Button narrowCloseButton; [SerializeField] private Button narrowOkButton; @@ -157,12 +162,36 @@ namespace MyGame.Scripts //JoypacAnalyticsManager.DesignEvent(StaticStringsEvent.Ad, StaticStringsEvent.Impression, position); SetButtonAction(closeButton, okButton, "","","","","","");// AdManager.AD_PLACEMENT_VIP); break; + case RewardType.UnCoin: + okButton.gameObject.SetActive(false); + normalWindow.SetActive(true); + movieObject.SetActive(false); + closeButton.transform.localPosition = new Vector3(0, closeButton.transform.localPosition.y, 0); + messageText.text = I2.Loc.LocalizationManager.GetTranslation("Joypac/UnCoin"); + //position = StaticStringsEvent.Sale; + //JoypacAnalyticsManager.DesignEvent(StaticStringsEvent.Ad, StaticStringsEvent.Impression, position); + SetButtonAction(closeButton, okButton, "", "", "", "", "", "");// AdManager.AD_PLACEMENT_VIP); + break; + + case RewardType.CollectCorn: + okButton.gameObject.SetActive(false); + okCornButton.gameObject.SetActive(true); + normalWindow.SetActive(true); + movieObject.SetActive(false); + // closeButton.transform.localPosition = new Vector3(0, closeButton.transform.localPosition.y, 0); + messageText.text = I2.Loc.LocalizationManager.GetTranslation("Joypac/CollectCorn"); + + cornCollect = true; + //position = StaticStringsEvent.Sale; + //JoypacAnalyticsManager.DesignEvent(StaticStringsEvent.Ad, StaticStringsEvent.Impression, position); + SetButtonAction(closeButton, okCornButton, "", "", "", "", "", "");// AdManager.AD_PLACEMENT_VIP); + break; default: throw new ArgumentOutOfRangeException(); } } - + bool cornCollect = false; private void SetButtonAction(Button closeButton, Button okButton, string Placement, string name, string extras, string from, string AdsShowCome, string AdsShowAdType) { closeButton.OnClickAsObservable().Take(1).Subscribe(_ => @@ -178,6 +207,12 @@ namespace MyGame.Scripts }).AddTo(this); okButton.OnClickAsObservable().Take(1).Subscribe(_ => { + if (cornCollect) + { + LocalCacheManager.Load(OkCallbackTag, null)?.Invoke(); + LocalCacheManager.Remove(OkCallbackTag); + return; + } if (!String.IsNullOrEmpty(Placement)) { JoypacAnalyticsManager.Instance.AdEvent(name, extras, from, AdsShowCome, AdsShowAdType); @@ -283,5 +318,15 @@ namespace MyGame.Scripts { ShowDialog(RewardType.Cold, okCallback, closeCallback); } + + public static void ShowUnColdDialog(Action okCallback = null, Action closeCallback = null) + { + ShowDialog(RewardType.UnCoin, okCallback, closeCallback); + } + + public static void ShowCollectCornDialog(Action okCallback = null, Action closeCallback = null) + { + ShowDialog(RewardType.CollectCorn, okCallback, closeCallback); + } } } \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scripts/TransitionManager.cs b/popcorn/Assets/MyGame/Scripts/TransitionManager.cs index d535a951..4ed023cf 100644 --- a/popcorn/Assets/MyGame/Scripts/TransitionManager.cs +++ b/popcorn/Assets/MyGame/Scripts/TransitionManager.cs @@ -68,6 +68,8 @@ public sealed class TransitionManager : SingletonMonoBehaviour