diff --git a/Assets/01_Scenes/GameScene.unity b/Assets/01_Scenes/GameScene.unity index b9bed15..761693f 100644 --- a/Assets/01_Scenes/GameScene.unity +++ b/Assets/01_Scenes/GameScene.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f5ca3709af1c5712ed2af2ce643c05b9c3e6210eaa5d9170c9892afc4b821657 -size 485001 +oid sha256:53d63a41c9f19da0b2cefbd7533df4d5289e1796712177873c797020a3f6c62c +size 485087 diff --git a/Assets/02_Scripts/Managers/Global/GameManager.cs b/Assets/02_Scripts/Managers/Global/GameManager.cs index 10f42b4..beb5f60 100644 --- a/Assets/02_Scripts/Managers/Global/GameManager.cs +++ b/Assets/02_Scripts/Managers/Global/GameManager.cs @@ -26,6 +26,8 @@ public class GameManager : MonoBehaviour public float ItemBounceFrequency = 2f; // 오르내리는 속도 [Header("Global Refer")] + public GameObject StaticObjectsField; + public GameObject DynamicObjectsField; public HighlightProfile InteractionHighlightProfile; private void Awake() diff --git a/Assets/02_Scripts/Managers/Local/InventoryManager.cs b/Assets/02_Scripts/Managers/Local/InventoryManager.cs index a0e4f03..967723d 100644 --- a/Assets/02_Scripts/Managers/Local/InventoryManager.cs +++ b/Assets/02_Scripts/Managers/Local/InventoryManager.cs @@ -353,6 +353,7 @@ public void SpawnItemToWorld(ItemInstance dropItem) // 빈 게임오브젝트를 생성하고 WorldItem 컴포넌트를 붙임 GameObject dropObj = new GameObject($"{dropItem.Data.ItemName}_Dropped"); + dropObj.transform.SetParent(GameManager.Instance.DynamicObjectsField.transform); dropObj.transform.position = dropPosition; WorldItem worldItem = dropObj.AddComponent(); @@ -371,4 +372,17 @@ public void DropItemFromSlot(int slotIndex) UpdateUI(); } + + public void ItemUse(int slotIndex) + { + GameManager.Instance.ItemEffect.ItemUse(Items[slotIndex]); + Items[slotIndex].CurrentStack -= 1; + + if (Items[slotIndex].CurrentStack <= 0) + { + Slots[slotIndex].ClearSlot(); + Items[slotIndex] = null; + } + UpdateUI(); + } } diff --git a/Assets/02_Scripts/Player/Controllers/PlayerCharacterController.cs b/Assets/02_Scripts/Player/Controllers/PlayerCharacterController.cs index f72fb53..1cf08b9 100644 --- a/Assets/02_Scripts/Player/Controllers/PlayerCharacterController.cs +++ b/Assets/02_Scripts/Player/Controllers/PlayerCharacterController.cs @@ -432,9 +432,16 @@ private void JumpAction() #region 앉기 public void PointSitAction(Transform trn) { - _cController.enabled = false; + _moveInput = Vector2.zero; + _moveTargetDir = Vector3.zero; + _currentSpd = 0f; + _actionExitRequested = false; - _stateMachine.ChangeState(PlayerState.Action); + _anim.SetFloat("speedRatio", 0f); + _anim.SetFloat("DirectX", 0f); + _anim.SetFloat("DirectY", 0f); + + _cController.enabled = false; transform.position = trn.position; transform.rotation = trn.rotation; @@ -442,6 +449,18 @@ public void PointSitAction(Transform trn) _cController.enabled = true; _anim.SetBool("IsSit",true); + + RotationMode = PlayerRotationMode.CameraDecoupled; + + float freezeTime = 3f; + + _stateMachine.ChangeState(PlayerState.Trans); + + _moveCutTimer = freezeTime; + // 앉기 진입 애니메이션 길이에 맞게 조정 + _ = Util.RunDelayed(freezeTime, () => { + _stateMachine.ChangeState(PlayerState.Action); + }, default); } #endregion @@ -451,12 +470,12 @@ public void EndAction() if (_stateMachine.CurrentState != PlayerState.Action) return; _anim.SetBool("IsSit", false); - float FreezeTime = 2f; + float freezeTime = 2f; _stateMachine.ChangeState(PlayerState.Trans); - _moveCutTimer = FreezeTime; - _ = Util.RunDelayed(FreezeTime, () => { + _moveCutTimer = freezeTime; + _ = Util.RunDelayed(freezeTime, () => { _stateMachine.ChangeState(PlayerState.Idle); RotationMode = PlayerRotationMode.CameraCoupled; InteractionOnTarget.InteractEnd(this); @@ -590,12 +609,11 @@ public void AimToggleInput(InputState inputState) public void InteractInput() { if (ActionExitCheck()) return; + if (_stateMachine.CurrentState == PlayerState.Trans) return; if (InteractionTargets.Count > 0) { InteractionOnTarget.InteractExec(this); // 실제 상호작용 실행 - - RotationMode = PlayerRotationMode.CameraDecoupled; } } diff --git a/Assets/02_Scripts/UI/Inventory/InventorySlot.cs b/Assets/02_Scripts/UI/Inventory/InventorySlot.cs index f02859b..848d836 100644 --- a/Assets/02_Scripts/UI/Inventory/InventorySlot.cs +++ b/Assets/02_Scripts/UI/Inventory/InventorySlot.cs @@ -188,14 +188,10 @@ public void OnPointerClick(PointerEventData eventData) // 우클릭 if (eventData.button == PointerEventData.InputButton.Right) { - ItemUse(); + if(currentItem != null) //아이템이 존재할시에만 사용 + { + GameManager.Instance.Inventory.ItemUse(SlotIndex); + } } } - - public void ItemUse() - { - GameManager.Instance.ItemEffect.ItemUse(currentItem); - currentItem.CurrentStack -= 1; - UpdateSlotUI(); - } } \ No newline at end of file