From b34dfa2ddbb05b136a982fdada20adc4b3533307 Mon Sep 17 00:00:00 2001 From: NTG_Lenovo Date: Thu, 10 Oct 2024 18:32:18 +0900 Subject: [PATCH] =?UTF-8?q?0.3.1.2=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/01.Scenes/01.Tycoon.unity | 15 +- Assets/02.Scripts/Character/Npc/Customer.cs | 12 +- .../Character/Player/PlayerHealthPoint.cs | 6 +- Assets/02.Scripts/EventManager.cs | 150 +++++++++++++++--- Assets/02.Scripts/Item/Item.cs | 4 +- Assets/02.Scripts/Map/MapPortal.cs | 2 +- .../Prop/Tycoon/InteractionFuniture.cs | 4 +- Assets/02.Scripts/Prop/Tycoon/PowerSwitch.cs | 2 +- Assets/02.Scripts/Prop/Tycoon/ServingTable.cs | 4 +- Assets/02.Scripts/Prop/Tycoon/TrashCan.cs | 3 +- Assets/02.Scripts/Tycoon/LiquidController.cs | 4 +- .../Tycoon/TycoonStageController.cs | 4 +- Assets/02.Scripts/Tycoon/TycoonStatus.cs | 6 +- .../02.Scripts/Ui/Combat/CombatUiManager.cs | 4 +- Assets/02.Scripts/Ui/InteractionUi.cs | 6 +- .../02.Scripts/Ui/Tycoon/TycoonUiManager.cs | 4 +- 16 files changed, 160 insertions(+), 70 deletions(-) diff --git a/Assets/01.Scenes/01.Tycoon.unity b/Assets/01.Scenes/01.Tycoon.unity index 7d09669e9..6da8dd5a1 100644 --- a/Assets/01.Scenes/01.Tycoon.unity +++ b/Assets/01.Scenes/01.Tycoon.unity @@ -15121,7 +15121,6 @@ GameObject: - component: {fileID: 1400792461} - component: {fileID: 1400792460} - component: {fileID: 1400792459} - - component: {fileID: 1400792462} - component: {fileID: 1400792463} m_Layer: 8 m_Name: LiquidInteractionRegion @@ -15129,7 +15128,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &1400792458 Transform: m_ObjectHideFlags: 0 @@ -15219,18 +15218,6 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1400792457} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!114 &1400792462 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1400792457} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: f0f3dc568d0721b48ad5f24339d24951, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!114 &1400792463 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/02.Scripts/Character/Npc/Customer.cs b/Assets/02.Scripts/Character/Npc/Customer.cs index e80b62cb5..5c5762ddc 100644 --- a/Assets/02.Scripts/Character/Npc/Customer.cs +++ b/Assets/02.Scripts/Character/Npc/Customer.cs @@ -280,10 +280,10 @@ namespace BlueWater.Npcs.Customers var servedCocktailData = ItemManager.Instance.CocktailDataSo.GetDataByIdx(currentPickupItem.Idx); ServedItem(servedCocktailData); BalloonUi.ReceiveItem(servedCocktailData); - EventManager.OnCocktailServedToCustomer?.Invoke(servedCocktailData); + EventManager.InvokeCocktailServedToCustomer(servedCocktailData); IsOrderedSucceed = currentPickupItem.Idx == OrderedCocktailData.Idx; IsReceivedItem = true; - EventManager.OnOrderResult?.Invoke(this, IsOrderedSucceed); + EventManager.InvokeOrderResult(this, IsOrderedSucceed); break; default: throw new ArgumentOutOfRangeException(); @@ -309,13 +309,13 @@ namespace BlueWater.Npcs.Customers public virtual void ShowInteractionUi() { SpineController.EnableCustomMaterial(); - EventManager.OnShowInteractionUi?.Invoke(InteractionMessage); + EventManager.InvokeShowInteractionUi(InteractionMessage); } public virtual void HideInteractionUi() { SpineController.DisableCustomMaterial(); - EventManager.OnHideInteractionUi?.Invoke(); + EventManager.InvokeHideInteractionUi(); } public void RegisterPlayerInteraction() @@ -352,7 +352,7 @@ namespace BlueWater.Npcs.Customers var isWaitTimeOver = BalloonUi.IsWaitTimeOver(); if (isWaitTimeOver) { - EventManager.OnOrderResult?.Invoke(this, false); + EventManager.InvokeOrderResult(this, false); } return isWaitTimeOver; @@ -417,7 +417,7 @@ namespace BlueWater.Npcs.Customers _customerInteractionType = CustomerInteractionType.OrderCocktail; RegisterPlayerInteraction(); - EventManager.OnOrderedCocktail?.Invoke(this); + EventManager.InvokeOrderedCocktail(this); } public void MoveSpawnPosition() diff --git a/Assets/02.Scripts/Character/Player/PlayerHealthPoint.cs b/Assets/02.Scripts/Character/Player/PlayerHealthPoint.cs index be329db73..ecedd27a0 100644 --- a/Assets/02.Scripts/Character/Player/PlayerHealthPoint.cs +++ b/Assets/02.Scripts/Character/Player/PlayerHealthPoint.cs @@ -65,14 +65,14 @@ namespace BlueWater.Players var previousMaxHealthPoint = MaxHealthPoint; var newChangedHealthPoint = Mathf.Clamp(changedHealthPoint, 0, 10); MaxHealthPoint = newChangedHealthPoint; - EventManager.OnMaxHealthChanged?.Invoke(previousMaxHealthPoint, newChangedHealthPoint); + EventManager.InvokeMaxHealthChanged(previousMaxHealthPoint, newChangedHealthPoint); } public void SetCurrentHealthPoint(int changedHealthPoint) { var newChangedHealthPoint = Mathf.Clamp(changedHealthPoint, 0, MaxHealthPoint); CurrentHealthPoint = newChangedHealthPoint; - EventManager.OnHealthChanged?.Invoke(newChangedHealthPoint); + EventManager.InvokeHealthChanged(newChangedHealthPoint); if (CurrentHealthPoint <= 2) { @@ -124,7 +124,7 @@ namespace BlueWater.Players public void Die() { - EventManager.OnDead?.Invoke(); + EventManager.InvokeDead(); } private IEnumerator FlashWhiteCoroutine() diff --git a/Assets/02.Scripts/EventManager.cs b/Assets/02.Scripts/EventManager.cs index 14b430f62..1a22860af 100644 --- a/Assets/02.Scripts/EventManager.cs +++ b/Assets/02.Scripts/EventManager.cs @@ -11,52 +11,156 @@ namespace BlueWater #region Global events // Ui - public static Action FadeInOut; + public static Action OnFadeInOut; + public static void InvokeFadeInOut(float fadeInTime, float fadeOutTime, Color? fadeColor = null, float delayAfterFadeIn = 0f) + { + OnFadeInOut?.Invoke(fadeInTime, fadeOutTime, fadeColor, delayAfterFadeIn); + } // Player + // 플레이어 최대체력 변경 이벤트 public static Action OnMaxHealthChanged; + public static void InvokeMaxHealthChanged(int previousMaxHealthPoint, int changedMaxHealthPoint) + { + OnMaxHealthChanged?.Invoke(previousMaxHealthPoint, changedMaxHealthPoint); + } + + // 플레이어 현재체력 변경 이벤트 public static Action OnHealthChanged; + public static void InvokeHealthChanged(int changedHealthPoint) + { + OnHealthChanged?.Invoke(changedHealthPoint); + } + + // 플레이어 죽을 때 이벤트 public static Action OnDead; + public static void InvokeDead() + { + OnDead?.Invoke(); + } // 상호작용 + // 상호작용 Ui 활성화 public static Action OnShowInteractionUi; + public static void InvokeShowInteractionUi(string interactionMessage) + { + OnShowInteractionUi?.Invoke(interactionMessage); + } + + // 상호작용 Ui 비활성화 public static Action OnHideInteractionUi; + public static void InvokeHideInteractionUi() + { + OnHideInteractionUi?.Invoke(); + } + + // 플레이어 상호작용중 이벤트 + public static Action OnInteracting; #endregion // Tycoon events #region Tycoon events + // 타이쿤 시작 이벤트 + public static Action OnTycoonGameStarted; + public static void InvokeTycoonGameStarted() + { + OnTycoonGameStarted?.Invoke(); + } + + // 타이쿤 종료 이벤트 (OnDead 이벤트로 대체중) + public static Action OnTycoonGameOvered; + public static void InvokeTycoonGameOvered() + { + OnTycoonGameOvered?.Invoke(); + } + // 플레이어 + // 레벨업 이벤트 public static Action OnLevelUp; - public static Action OnChangeGold; + public static void InvokeLevelUp(LevelData levelData) + { + OnLevelUp?.Invoke(levelData); + } + + // 경험치 변경 이벤트 public static Action OnChangeExp; + public static void InvokeChangeExp(ExpData expData) + { + OnChangeExp?.Invoke(expData); + } + + // 골드 변경 이벤트 + public static Action OnChangeGold; + public static void InvokeChangeGold(int newGold) + { + OnChangeGold?.Invoke(newGold); + } + + // 플레이어 칵테일 제조 시작 이벤트 + public static Action OnCocktailStarted; + public static void InvokeCocktailStarted() + { + OnCocktailStarted?.Invoke(); + } + + // 플레이어 칵테일 제조 완성 이벤트 + public static Action OnCocktailCompleted; + public static void InvokeCocktailCompleted(CocktailData completedCocktail) + { + OnCocktailCompleted?.Invoke(completedCocktail); + } + + // 플레이어가 들고있는 칵테일 버리기 이벤트 + public static Action OnCocktailDiscarded; + public static void InvokeCocktailDiscarded() + { + OnCocktailDiscarded?.Invoke(); + } + + // 플레이어가 들고있는 칵테일을 서빙테이블에 올려두는 이벤트 + public static Action OnPlaceOnServingTable; + public static void InvokePlaceOnServingTable() + { + OnPlaceOnServingTable?.Invoke(); + } + + // 플레이어가 서빙테이블에 있는 칵테일을 가져오는 이벤트 + public static Action OnTakeFromServingTable; + public static void InvokeTakeFromServingTable() + { + OnTakeFromServingTable?.Invoke(); + } // Npc + // 손님 생성 이벤트 public static Action OnCreateCustomer; - public static Action OnOrderedCocktail; - public static Action OnOrderResult; - - // 음료 - // public static Action OnDrinkRecipeAcquired; - // public static Action OnDrinkRecipeSelected; + public static void InvokeCreateCustomer() + { + OnCreateCustomer?.Invoke(); + } - public static Action OnTycoonGameStarted; - public static Action OnTycoonGameOvered; - - public static Action OnCocktailStarted; - public static Action OnCocktailCompleted; - public static Action OnCocktailDiscarded; - - public static Action OnPlaceOnServingTable; - public static Action OnTakeFromServingTable; - + // 손님이 칵테일 주문 이벤트 + public static Action OnOrderedCocktail; + public static void InvokeOrderedCocktail(Customer orderedCustomer) + { + OnOrderedCocktail?.Invoke(orderedCustomer); + } + + // 손님이 칵테일을 받을때 이벤트 public static Action OnCocktailServedToCustomer; - - public static Action OnInteracting; - - // 요리 - //public static Action OnFoodRecipeAcquired; + public static void InvokeCocktailServedToCustomer(CocktailData servedCocktailData) + { + OnCocktailServedToCustomer?.Invoke(servedCocktailData); + } + + // 손님이 칵테일을 받을때 결과 이벤트 + public static Action OnOrderResult; + public static void InvokeOrderResult(Customer orderedCustomer, bool orderedSucceed) + { + OnOrderResult?.Invoke(orderedCustomer, orderedSucceed); + } #endregion } diff --git a/Assets/02.Scripts/Item/Item.cs b/Assets/02.Scripts/Item/Item.cs index 1ce5e5571..c6c4f7340 100644 --- a/Assets/02.Scripts/Item/Item.cs +++ b/Assets/02.Scripts/Item/Item.cs @@ -211,12 +211,12 @@ namespace BlueWater.Items public void ShowInteractionUi() { InteractionMessage = $"{ItemData.Name} 줍기"; - EventManager.OnShowInteractionUi?.Invoke(InteractionMessage); + EventManager.InvokeShowInteractionUi(InteractionMessage); } public void HideInteractionUi() { - EventManager.OnHideInteractionUi?.Invoke(); + EventManager.InvokeHideInteractionUi(); } private void DestroySelf() => Destroy(gameObject); diff --git a/Assets/02.Scripts/Map/MapPortal.cs b/Assets/02.Scripts/Map/MapPortal.cs index 662719996..a17188047 100644 --- a/Assets/02.Scripts/Map/MapPortal.cs +++ b/Assets/02.Scripts/Map/MapPortal.cs @@ -45,7 +45,7 @@ namespace BlueWater.Maps private IEnumerator PortalCoroutine(Collider other) { PlayerInputKeyManager.Instance.DisableCurrentPlayerInput(); - EventManager.FadeInOut?.Invoke(_fadeInOutTime.x, _fadeInOutTime.y, _fadeColor, _delayAfterFadeIn); + EventManager.InvokeFadeInOut(_fadeInOutTime.x, _fadeInOutTime.y, _fadeColor, _delayAfterFadeIn); //CombatUiManager.Instance.FadeInOut(_fadeInOutTime.x, _fadeInOutTime.y, _fadeColor, _delayAfterFadeIn); yield return new WaitForSeconds(_fadeInOutTime.x); diff --git a/Assets/02.Scripts/Prop/Tycoon/InteractionFuniture.cs b/Assets/02.Scripts/Prop/Tycoon/InteractionFuniture.cs index 664238aad..181e2e581 100644 --- a/Assets/02.Scripts/Prop/Tycoon/InteractionFuniture.cs +++ b/Assets/02.Scripts/Prop/Tycoon/InteractionFuniture.cs @@ -99,7 +99,7 @@ namespace BlueWater.Tycoons public virtual void ShowInteractionUi() { VisualLook.material = OutlineMaterial; - EventManager.OnShowInteractionUi?.Invoke(InteractionMessage); + EventManager.InvokeShowInteractionUi(InteractionMessage); } public virtual void HideInteractionUi() @@ -108,7 +108,7 @@ namespace BlueWater.Tycoons { VisualLook.material = OriginalMaterial; } - EventManager.OnHideInteractionUi?.Invoke(); + EventManager.InvokeHideInteractionUi(); } protected void RegisterPlayerInteraction() diff --git a/Assets/02.Scripts/Prop/Tycoon/PowerSwitch.cs b/Assets/02.Scripts/Prop/Tycoon/PowerSwitch.cs index d0b1c75c2..0a14baa17 100644 --- a/Assets/02.Scripts/Prop/Tycoon/PowerSwitch.cs +++ b/Assets/02.Scripts/Prop/Tycoon/PowerSwitch.cs @@ -11,7 +11,7 @@ namespace BlueWater.Tycoons public override void Interaction() { - EventManager.OnTycoonGameStarted?.Invoke(); + EventManager.InvokeTycoonGameStarted(); } public override bool CanInteraction() diff --git a/Assets/02.Scripts/Prop/Tycoon/ServingTable.cs b/Assets/02.Scripts/Prop/Tycoon/ServingTable.cs index 18426c983..862dd7314 100644 --- a/Assets/02.Scripts/Prop/Tycoon/ServingTable.cs +++ b/Assets/02.Scripts/Prop/Tycoon/ServingTable.cs @@ -24,7 +24,7 @@ namespace BlueWater.Tycoons // 테이블의 칵테일을 가져가는 경우 if (_currentPickupItem != null) { - EventManager.OnTakeFromServingTable?.Invoke(); + EventManager.InvokeTakeFromServingTable(); CurrentTycoonPlayer.TycoonPickupHandler.PickupItem(_currentPickupItem); CurrentTycoonPlayer.InteractionCanvas.BalloonUi.SetItemImage(_currentPickupItem); _cocktailGlassImage.enabled = false; @@ -34,7 +34,7 @@ namespace BlueWater.Tycoons // 테이블에 칵테일을 놓는 경우 else { - EventManager.OnPlaceOnServingTable?.Invoke(); + EventManager.InvokePlaceOnServingTable(); _currentPickupItem = CurrentTycoonPlayer.TycoonPickupHandler.GetCurrentPickupItem(); CurrentTycoonPlayer.TycoonPickupHandler.GiveItem(_currentPickupItem); CurrentTycoonPlayer.InteractionCanvas.BalloonUi.DiscardItem(); diff --git a/Assets/02.Scripts/Prop/Tycoon/TrashCan.cs b/Assets/02.Scripts/Prop/Tycoon/TrashCan.cs index 12ecfe780..9548e17cd 100644 --- a/Assets/02.Scripts/Prop/Tycoon/TrashCan.cs +++ b/Assets/02.Scripts/Prop/Tycoon/TrashCan.cs @@ -4,8 +4,7 @@ namespace BlueWater.Tycoons { public override void Interaction() { - EventManager.OnCocktailDiscarded?.Invoke(); - //CurrentTycoonPlayer.DiscardItem(); + EventManager.InvokeCocktailDiscarded(); } public override bool CanInteraction() diff --git a/Assets/02.Scripts/Tycoon/LiquidController.cs b/Assets/02.Scripts/Tycoon/LiquidController.cs index 1d6558473..a80f4865f 100644 --- a/Assets/02.Scripts/Tycoon/LiquidController.cs +++ b/Assets/02.Scripts/Tycoon/LiquidController.cs @@ -356,7 +356,7 @@ namespace BlueWater _isCompleted = false; _currentMixedColor = barrel.GetLiquidData().Color; _instanceMaterial.SetColor(LiquidColorHash, _currentMixedColor * _colorIntensity); - EventManager.OnCocktailStarted?.Invoke(); + EventManager.InvokeCocktailStarted(); } _startTime = Time.time; @@ -489,7 +489,7 @@ namespace BlueWater yield return new WaitForSeconds(1f); HidePanel(); - EventManager.OnCocktailCompleted?.Invoke(matchingCocktail); + EventManager.InvokeCocktailCompleted(matchingCocktail); } /// diff --git a/Assets/02.Scripts/Tycoon/TycoonStageController.cs b/Assets/02.Scripts/Tycoon/TycoonStageController.cs index 583009a8e..5c7eb8fbc 100644 --- a/Assets/02.Scripts/Tycoon/TycoonStageController.cs +++ b/Assets/02.Scripts/Tycoon/TycoonStageController.cs @@ -39,7 +39,7 @@ namespace BlueWater.Tycoons _dailyCustomerVisitInfos.Clear(); Utils.StartUniqueCoroutine(this, ref _startStageCoroutineInstance, StartStageCoroutine()); - EventManager.OnTycoonGameStarted?.Invoke(); + EventManager.InvokeTycoonGameStarted(); } private IEnumerator StartStageCoroutine() @@ -49,7 +49,7 @@ namespace BlueWater.Tycoons while (true) { var currentLevelData = _tycoonManager.GetCurrentLevelData(); - EventManager.OnCreateCustomer?.Invoke(); + EventManager.InvokeCreateCustomer(); yield return new WaitForSeconds(currentLevelData.CustomerRespawn); } diff --git a/Assets/02.Scripts/Tycoon/TycoonStatus.cs b/Assets/02.Scripts/Tycoon/TycoonStatus.cs index 60adf1b8e..9a887e265 100644 --- a/Assets/02.Scripts/Tycoon/TycoonStatus.cs +++ b/Assets/02.Scripts/Tycoon/TycoonStatus.cs @@ -89,7 +89,7 @@ namespace BlueWater.Tycoons var previousExp = _currentExp; var addedExp = value - previousExp; _currentExp = value; - EventManager.OnChangeExp?.Invoke(new ExpData(_currentLevel, previousExp, addedExp)); + EventManager.InvokeChangeExp(new ExpData(_currentLevel, previousExp, addedExp)); } } @@ -110,7 +110,7 @@ namespace BlueWater.Tycoons set { _currentGold = value; - EventManager.OnChangeGold?.Invoke(_currentGold); + EventManager.InvokeChangeGold(_currentGold); } } @@ -318,7 +318,7 @@ namespace BlueWater.Tycoons break; } - EventManager.OnLevelUp?.Invoke(currentLevelData); + EventManager.InvokeLevelUp(currentLevelData); } } } \ No newline at end of file diff --git a/Assets/02.Scripts/Ui/Combat/CombatUiManager.cs b/Assets/02.Scripts/Ui/Combat/CombatUiManager.cs index 5e1037fcd..ca392c0ad 100644 --- a/Assets/02.Scripts/Ui/Combat/CombatUiManager.cs +++ b/Assets/02.Scripts/Ui/Combat/CombatUiManager.cs @@ -62,7 +62,7 @@ namespace BlueWater.Uis { PopupUi.OnPopupUiOpenEvent += RegisterPopup; PopupUi.OnPopupUiCloseEvent += UnregisterPopup; - EventManager.FadeInOut += FadeInOut; + EventManager.OnFadeInOut += FadeInOut; Invoke(nameof(StartTutorial), 0.1f); } @@ -78,7 +78,7 @@ namespace BlueWater.Uis PopupUi.OnPopupUiOpenEvent -= RegisterPopup; PopupUi.OnPopupUiCloseEvent -= UnregisterPopup; - EventManager.FadeInOut -= FadeInOut; + EventManager.OnFadeInOut -= FadeInOut; } [Button("셋팅 초기화")] diff --git a/Assets/02.Scripts/Ui/InteractionUi.cs b/Assets/02.Scripts/Ui/InteractionUi.cs index 7c0e7d461..94912fc20 100644 --- a/Assets/02.Scripts/Ui/InteractionUi.cs +++ b/Assets/02.Scripts/Ui/InteractionUi.cs @@ -23,14 +23,14 @@ namespace BlueWater.Uis { EventManager.OnShowInteractionUi += ShowUi; EventManager.OnHideInteractionUi += HideUi; - EventManager.OnInteracting += A; + EventManager.OnInteracting += SetFillAmount; } private void OnDestroy() { EventManager.OnShowInteractionUi -= ShowUi; EventManager.OnHideInteractionUi -= HideUi; - EventManager.OnInteracting -= A; + EventManager.OnInteracting -= SetFillAmount; } public void ShowUi(string message) @@ -44,7 +44,7 @@ namespace BlueWater.Uis _panel.SetActive(false); } - private void A(float fillAmount) + private void SetFillAmount(float fillAmount) { _fillImage.fillAmount = fillAmount; } diff --git a/Assets/02.Scripts/Ui/Tycoon/TycoonUiManager.cs b/Assets/02.Scripts/Ui/Tycoon/TycoonUiManager.cs index 040dcafb1..dba03e149 100644 --- a/Assets/02.Scripts/Ui/Tycoon/TycoonUiManager.cs +++ b/Assets/02.Scripts/Ui/Tycoon/TycoonUiManager.cs @@ -53,7 +53,7 @@ namespace BlueWater.Uis PopupUi.OnPopupUiCloseEvent += UnregisterPopup; EventManager.OnTycoonGameStarted += TycoonOpenEvent; EventManager.OnTycoonGameOvered += TycoonClosedEvent; - EventManager.FadeInOut += FadeInOut; + EventManager.OnFadeInOut += FadeInOut; } private void OnDestroy() @@ -64,7 +64,7 @@ namespace BlueWater.Uis PopupUi.OnPopupUiCloseEvent -= UnregisterPopup; EventManager.OnTycoonGameStarted -= TycoonOpenEvent; EventManager.OnTycoonGameOvered -= TycoonClosedEvent; - EventManager.FadeInOut -= FadeInOut; + EventManager.OnFadeInOut -= FadeInOut; } #endregion