From 89476907b832799661834266a9d7b65066ce2955 Mon Sep 17 00:00:00 2001 From: kimura Date: Fri, 20 May 2022 11:40:20 +0900 Subject: [PATCH] =?UTF-8?q?=E7=BE=BD=E6=89=80=E6=8C=81=E6=95=B0=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Main/Scripts/MissionManager.cs | 5 +++ .../MyGame/Scenes/marketing/Customize.unity | 30 ++++++++++++++ .../Prefabs/StockRainbowWings.prefab | 15 +++++++ .../Scenes/marketing/Scripts/MarketManager.cs | 1 + .../Scenes/marketing/Scripts/ShopCustomize.cs | 17 +++++--- .../Scripts/ShopCustomizeCoinManager.cs | 40 +++++++++++++++++++ .../Scripts/ShopCustomizeCoinManager.cs.meta | 3 ++ 7 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 popcorn/Assets/MyGame/Scripts/ShopCustomizeCoinManager.cs create mode 100644 popcorn/Assets/MyGame/Scripts/ShopCustomizeCoinManager.cs.meta diff --git a/popcorn/Assets/MyGame/Scenes/Main/Scripts/MissionManager.cs b/popcorn/Assets/MyGame/Scenes/Main/Scripts/MissionManager.cs index 034ee491..e086d98d 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Scripts/MissionManager.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Scripts/MissionManager.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using I2.Loc; +using MyGame.Scripts; using UniRx; using UnityEngine; using UnityEngine.UI; @@ -511,6 +512,10 @@ public class MissionManager : MonoBehaviour CoinManager.Instance.AddCoin(missionData.reward); GameDataManager.GameData.Coin = CoinManager.Instance.OwnCoin; break; + case MissionRewardType.ShopCustomizeCoin when ShopCustomizeCoinManager.ExistsInstance: + ShopCustomizeCoinManager.Instance.AddCoin(missionData.reward); + GameDataManager.GameData.ShopCustomizeCoin = ShopCustomizeCoinManager.Instance.OwnCoin; + break; case MissionRewardType.ShopCustomizeCoin: GameDataManager.GameData.ShopCustomizeCoin += missionData.reward; break; diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Customize.unity b/popcorn/Assets/MyGame/Scenes/marketing/Customize.unity index 4754ff4f..2443470a 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Customize.unity +++ b/popcorn/Assets/MyGame/Scenes/marketing/Customize.unity @@ -517,6 +517,36 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 6ae614796715fc949a96921656b66a62, type: 3} +--- !u!1 &238780954 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 3099811789230852685} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 238780955} + m_Layer: 0 + m_Name: Cart_c (Missing Prefab) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &238780955 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 3099811789230852685} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 238780954} + 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: 1826383572} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &247710335 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/StockRainbowWings.prefab b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/StockRainbowWings.prefab index bbf0b7f0..4483cd56 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/StockRainbowWings.prefab +++ b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/StockRainbowWings.prefab @@ -91,6 +91,7 @@ GameObject: - component: {fileID: 1275687393892332067} - component: {fileID: 1275687393892332066} - component: {fileID: 1275687393892332065} + - component: {fileID: 6236916451255634275} m_Layer: 5 m_Name: StockRainbowWings m_TagString: Untagged @@ -195,6 +196,20 @@ MonoBehaviour: m_ChildControlHeight: 0 m_ChildScaleWidth: 0 m_ChildScaleHeight: 0 +--- !u!114 &6236916451255634275 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1275687393892332079} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 12819c5a8c234fa2bdf10a248f20e09c, type: 3} + m_Name: + m_EditorClassIdentifier: + coinCountText: {fileID: 1275687393837241563} + coinUpDuration: 0.5 --- !u!1 &1275687394498706116 GameObject: m_ObjectHideFlags: 0 diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs index 275d8824..b9b89771 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs @@ -44,6 +44,7 @@ public class MarketManager : MonoBehaviour // カスタマイズ読み込み marketView.SetAllItem(); stockView = marketView.GetTarget(ShopCustomizeCategory.Category4).GetComponentInChildren(); + ShopCustomizeCoinManager.Instance.ChangeCoin(gameData.ShopCustomizeCoin); if (!gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay)) { diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomize.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomize.cs index 75ffe43b..756e8342 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomize.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomize.cs @@ -12,11 +12,12 @@ namespace MyGame.Scenes.marketing.Scripts [SerializeField] private MarketView marketView; [SerializeField] private ShopCustomizeView customizeView; [SerializeField] private ShopCustomizeSelector customizeSelector; - private readonly Subject levelNotify = new Subject(); + private readonly Subject purchasedNotify = new Subject(); private void Start() { - levelNotify.AddTo(this); + purchasedNotify.AddTo(this); + SoundManager.Instance.PlayBGM("bgm_marketing"); var gameData = GameDataManager.GameData; var customizeDataList = SpreadsheetDataManager.Instance.GetBaseDataList(Const.ShopCustomizeDataSheet); #if UNITY_EDITOR @@ -33,6 +34,8 @@ myItems {string.Join(",", gameData.ShopCustomizeMyItems.Select(x => x.ToString() ShopCustomizeTutorialDialog.ShowDialog(); } customizeView.SetLevel(gameData.ShopCustomizeLevel); + ShopCustomizeCoinManager.Instance.ChangeCoin(gameData.ShopCustomizeCoin); + customizeView.OnCloseObservable.Subscribe(_ => { GameDataManager.SaveGameData(); // 設定を保存 @@ -74,8 +77,8 @@ myItems {string.Join(",", gameData.ShopCustomizeMyItems.Select(x => x.ToString() else { item.SetState(ShopCustomizeItemState.Lock); - levelNotify.Distinct() - .Where(x => x >= customizeData.level) + purchasedNotify.Distinct() + .Where(_ => gameData.ShopCustomizeLevel >= customizeData.level) .Take(1) .Subscribe(x => { @@ -126,15 +129,17 @@ myItems {string.Join(",", gameData.ShopCustomizeMyItems.Select(x => x.ToString() private void PurchaseItem(ShopCustomizeData customizeData) { var gameData = GameDataManager.GameData; - gameData.ShopCustomizeCoin -= customizeData.price; + ShopCustomizeCoinManager.Instance.SubCoin(customizeData.price); + gameData.ShopCustomizeCoin = ShopCustomizeCoinManager.Instance.OwnCoin; gameData.ShopCustomizePoint += customizeData.point; gameData.ShopCustomizeMyItems = gameData.ShopCustomizeMyItems.Append(customizeData.id).ToArray(); var customizeLevelList = SpreadsheetDataManager.Instance.GetBaseDataList(Const.ShopCustomizeLevelDataSheet); var level = customizeLevelList.LastOrDefault(data => data.point <= gameData.ShopCustomizePoint)?.level ?? 1; - levelNotify.OnNext(level); gameData.ShopCustomizeLevel = level; GameDataManager.SaveGameData(); + customizeView.SetLevel(gameData.ShopCustomizeLevel); + purchasedNotify.OnNext(Unit.Default); } /* diff --git a/popcorn/Assets/MyGame/Scripts/ShopCustomizeCoinManager.cs b/popcorn/Assets/MyGame/Scripts/ShopCustomizeCoinManager.cs new file mode 100644 index 00000000..2e17117f --- /dev/null +++ b/popcorn/Assets/MyGame/Scripts/ShopCustomizeCoinManager.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +namespace MyGame.Scripts +{ + public class ShopCustomizeCoinManager : SingletonMonoBehaviour + { + [SerializeField] private TextWithCountUpInt coinCountText; + [SerializeField] private float coinUpDuration = 0.5f; + + private int ownCoin; + public int OwnCoin => ownCoin; + private string coinTextFormat = "{0}"; + void Awake(){ + if(CheckInstance()) return ; + } + + public void ChangeCoin(int count) + { + ownCoin = count; + coinCountText.ChangeValue(coinTextFormat, ownCoin); + } + + public void AddCoin(int count) + { + ownCoin += count; + SoundManager.Instance.PlaySE("se_coin_get"); + coinCountText.CountUpAnimation(coinTextFormat, ownCoin, coinUpDuration); + } + + public void SubCoin(int coin){ + ownCoin -= coin; + if(coinCountText.gameObject.activeInHierarchy){ + coinCountText.CountUpAnimation(coinTextFormat, ownCoin, coinUpDuration); + }else{ + coinCountText.ChangeValue(coinTextFormat, ownCoin); + } + } + + } +} \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scripts/ShopCustomizeCoinManager.cs.meta b/popcorn/Assets/MyGame/Scripts/ShopCustomizeCoinManager.cs.meta new file mode 100644 index 00000000..890c5199 --- /dev/null +++ b/popcorn/Assets/MyGame/Scripts/ShopCustomizeCoinManager.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 12819c5a8c234fa2bdf10a248f20e09c +timeCreated: 1653009837 \ No newline at end of file