diff --git a/Assets/New Animator Controller.controller b/Assets/New Animator Controller.controller index bda13f5..593a6df 100644 --- a/Assets/New Animator Controller.controller +++ b/Assets/New Animator Controller.controller @@ -108,8 +108,7 @@ AnimatorState: m_Name: Locomotion m_Speed: 1 m_CycleOffset: 0 - m_Transitions: - - {fileID: 5781145710961441674} + m_Transitions: [] m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -252,31 +251,6 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 ---- !u!1101 &5781145710961441674 -AnimatorStateTransition: - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: - m_Conditions: - - m_ConditionMode: 1 - m_ConditionEvent: Attack - m_EventTreshold: 0 - m_DstStateMachine: {fileID: 0} - m_DstState: {fileID: 1042583441410514574} - m_Solo: 0 - m_Mute: 0 - m_IsExit: 0 - serializedVersion: 3 - m_TransitionDuration: 0.25 - m_TransitionOffset: 0 - m_ExitTime: 0.82954544 - m_HasExitTime: 1 - m_HasFixedDuration: 1 - m_InterruptionSource: 0 - m_OrderedInterruption: 1 - m_CanTransitionToSelf: 1 --- !u!1101 &7110953658697184367 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -319,7 +293,7 @@ AnimatorStateMachine: m_Position: {x: 340, y: 80, z: 0} - serializedVersion: 1 m_State: {fileID: 1042583441410514574} - m_Position: {x: 650, y: -120, z: 0} + m_Position: {x: 330, y: -30, z: 0} - serializedVersion: 1 m_State: {fileID: 7354546966716114735} m_Position: {x: 340, y: -200, z: 0} @@ -327,6 +301,7 @@ AnimatorStateMachine: m_AnyStateTransitions: - {fileID: 7110953658697184367} - {fileID: 404349288434198591} + - {fileID: 7713475934094704921} m_EntryTransitions: [] m_StateMachineTransitions: {} m_StateMachineBehaviours: [] @@ -362,3 +337,28 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: +--- !u!1101 &7713475934094704921 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Attack + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 1042583441410514574} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.75 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 diff --git a/Assets/Prefabs/HotbarSlot.prefab b/Assets/Prefabs/HotbarSlot.prefab new file mode 100644 index 0000000..fa5e12e --- /dev/null +++ b/Assets/Prefabs/HotbarSlot.prefab @@ -0,0 +1,428 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &267047305060795697 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7307898750992612318} + - component: {fileID: 6164662416235394563} + - component: {fileID: 5317606285065586905} + m_Layer: 5 + m_Name: HotbarSlot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7307898750992612318 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 267047305060795697} + 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_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 4898813806943746593} + - {fileID: 2802311425631855222} + - {fileID: 7510340633778428719} + - {fileID: 1353474716909668110} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &6164662416235394563 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 267047305060795697} + m_CullTransparentMesh: 1 +--- !u!114 &5317606285065586905 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 267047305060795697} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4c873d40887ad9a439c14bf4f7fc31de, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::InventorySlotUI + iconImage: {fileID: 7873647287834677809} + amountText: {fileID: 7566654020528282449} + selectionHighlight: {fileID: 9126347784680599350} +--- !u!1 &3696256704103182857 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2802311425631855222} + - component: {fileID: 2054834852609699146} + - component: {fileID: 7873647287834677809} + m_Layer: 5 + m_Name: Icon + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2802311425631855222 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3696256704103182857} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7307898750992612318} + 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: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2054834852609699146 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3696256704103182857} + m_CullTransparentMesh: 1 +--- !u!114 &7873647287834677809 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3696256704103182857} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + 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 &6001211355652619312 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7510340633778428719} + - component: {fileID: 5042768747676868742} + - component: {fileID: 7566654020528282449} + m_Layer: 5 + m_Name: AmoutText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7510340633778428719 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6001211355652619312} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7307898750992612318} + 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: 0, y: 0} + m_SizeDelta: {x: 50, y: 100} + m_Pivot: {x: 0, y: 0.5} +--- !u!222 &5042768747676868742 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6001211355652619312} + m_CullTransparentMesh: 1 +--- !u!114 &7566654020528282449 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6001211355652619312} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshProUGUI + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: 1 + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 36 + m_fontSizeBase: 36 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 4 + m_VerticalAlignment: 1024 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_characterHorizontalScale: 1 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_TextWrappingMode: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 0 + m_ActiveFontFeatures: 6e72656b + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_EmojiFallbackSupport: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!1 &8379433747932548676 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4898813806943746593} + - component: {fileID: 8506671009770206749} + - component: {fileID: 3243083682293997790} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4898813806943746593 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8379433747932548676} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7307898750992612318} + 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: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8506671009770206749 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8379433747932548676} + m_CullTransparentMesh: 1 +--- !u!114 &3243083682293997790 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8379433747932548676} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0.078431375} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + 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 &9126347784680599350 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1353474716909668110} + - component: {fileID: 4997794014858873455} + - component: {fileID: 158315208944153192} + m_Layer: 5 + m_Name: Selection + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1353474716909668110 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9126347784680599350} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7307898750992612318} + 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: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &4997794014858873455 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9126347784680599350} + m_CullTransparentMesh: 1 +--- !u!114 &158315208944153192 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9126347784680599350} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + 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 diff --git a/Assets/Prefabs/HotbarSlot.prefab.meta b/Assets/Prefabs/HotbarSlot.prefab.meta new file mode 100644 index 0000000..0300d96 --- /dev/null +++ b/Assets/Prefabs/HotbarSlot.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d3f86d99741589a44882869bec91c6d2 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index a17fbec..5f93f30 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -346,7 +346,6 @@ MonoBehaviour: serializedVersion: 2 m_Bits: 256 buildSpeedMultiplier: 2 - pickupRadius: 1.5 itemLayer: serializedVersion: 2 m_Bits: 16384 @@ -460,6 +459,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Assembly-CSharp::PlayerInventory ShowTopMostFoldoutHeaderGroup: 1 + slotCount: 8 + maxWeight: 50 + database: {fileID: 11400000, guid: c8b92b51748d21d4e9be2892a4c7c2d2, type: 2} --- !u!114 &8444973872686006962 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/ItemDatabase.asset b/Assets/Resources/ItemDatabase.asset new file mode 100644 index 0000000..9691297 --- /dev/null +++ b/Assets/Resources/ItemDatabase.asset @@ -0,0 +1,16 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +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: e1161d1386968b54483e219677fcc729, type: 3} + m_Name: ItemDatabase + m_EditorClassIdentifier: Assembly-CSharp::ItemDatabase + allItems: + - {fileID: 11400000, guid: 953ceca9a25978549a56f0a4ff5d6a2c, type: 2} diff --git a/Assets/Resources/UGSettingObject.asset.meta b/Assets/Resources/ItemDatabase.asset.meta similarity index 79% rename from Assets/Resources/UGSettingObject.asset.meta rename to Assets/Resources/ItemDatabase.asset.meta index 5c09255..cdb01b7 100644 --- a/Assets/Resources/UGSettingObject.asset.meta +++ b/Assets/Resources/ItemDatabase.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: acf0cb8f9f15fc44ab0dbc01d456e73f +guid: c8b92b51748d21d4e9be2892a4c7c2d2 NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Assets/Item_Resource.asset b/Assets/Resources/Item_Resource.asset similarity index 100% rename from Assets/Item_Resource.asset rename to Assets/Resources/Item_Resource.asset diff --git a/Assets/Item_Resource.asset.meta b/Assets/Resources/Item_Resource.asset.meta similarity index 100% rename from Assets/Item_Resource.asset.meta rename to Assets/Resources/Item_Resource.asset.meta diff --git a/Assets/Resources/UGSettingObject.asset b/Assets/Resources/UGSettingObject.asset deleted file mode 100644 index 66d0f85..0000000 --- a/Assets/Resources/UGSettingObject.asset +++ /dev/null @@ -1,22 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &11400000 -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: 65742e7a9b971e242888935dd58a15a7, type: 3} - m_Name: UGSettingObject - m_EditorClassIdentifier: CAH.UnityGoogleSheets::UGS.UGSettingObject - ScriptURL: - ScriptPassword: default - GoogleFolderID: - GenerateCodePath: Assets/UGS.Generated/Scripts/ - DataPath: Assets/UGS.Generated/Resources/ - RuntimeDataPath: UGS/UGS.Data/ - CDN_URL: - base64: 0 diff --git a/Assets/Scenes/DefenceScene.unity b/Assets/Scenes/DefenceScene.unity index 2597ef1..bc98e72 100644 --- a/Assets/Scenes/DefenceScene.unity +++ b/Assets/Scenes/DefenceScene.unity @@ -293,6 +293,78 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 59717880} m_CullTransparentMesh: 1 +--- !u!1 &102637058 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 102637059} + - component: {fileID: 102637061} + - component: {fileID: 102637060} + m_Layer: 5 + m_Name: HotbarPanel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &102637059 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 102637058} + 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_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 2334337062712963962} + m_Father: {fileID: 1409253547} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &102637060 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 102637058} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.HorizontalLayoutGroup + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 0 + m_Spacing: 0 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 1 + m_ChildControlWidth: 0 + m_ChildControlHeight: 0 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 + m_ReverseArrangement: 0 +--- !u!222 &102637061 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 102637058} + m_CullTransparentMesh: 1 --- !u!1 &227051990 GameObject: m_ObjectHideFlags: 0 @@ -454,7 +526,7 @@ RectTransform: m_GameObject: {fileID: 280147082} 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_LocalScale: {x: 0.5, y: 0.5, z: 1} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1558135261} @@ -465,9 +537,9 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 0} m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: -300, y: 80} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 600, y: 160} - m_Pivot: {x: 0.5, y: 0.5} + m_Pivot: {x: 1, y: 0} --- !u!114 &280147084 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1312,7 +1384,6 @@ Transform: - {fileID: 1866217603} - {fileID: 412220987} - {fileID: 1842105546} - - {fileID: 931645607} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &707831773 @@ -1653,52 +1724,6 @@ PrefabInstance: insertIndex: -1 addedObject: {fileID: 445606027} m_SourcePrefab: {fileID: 100100000, guid: 443aa97110814434cb36b26656f1884c, type: 3} ---- !u!1 &931645606 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 931645607} - - component: {fileID: 931645608} - m_Layer: 0 - m_Name: ItemDatabase - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &931645607 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 931645606} - serializedVersion: 2 - 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_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 670724422} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &931645608 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 931645606} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e1161d1386968b54483e219677fcc729, type: 3} - m_Name: - m_EditorClassIdentifier: Assembly-CSharp::ItemDatabase - allItems: - - {fileID: 11400000, guid: 953ceca9a25978549a56f0a4ff5d6a2c, type: 2} --- !u!1 &1044242050 GameObject: m_ObjectHideFlags: 0 @@ -2404,10 +2429,10 @@ Light: m_InnerSpotAngle: 21.80208 m_CookieSize2D: {x: 0.5, y: 0.5} m_Shadows: - m_Type: 1 + m_Type: 2 m_Resolution: -1 m_CustomResolution: -1 - m_Strength: 1 + m_Strength: 0.2 m_Bias: 0.05 m_NormalBias: 0.4 m_NearPlane: 0.2 @@ -2442,7 +2467,7 @@ Light: m_AreaSize: {x: 1, y: 1} m_BounceIntensity: 1 m_ColorTemperature: 10775 - m_UseColorTemperature: 1 + m_UseColorTemperature: 0 m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} m_UseBoundingSphereOverride: 0 m_UseViewFrustumForShadowCasterCull: 1 @@ -2480,7 +2505,7 @@ GameObject: - component: {fileID: 1409253545} - component: {fileID: 1409253544} m_Layer: 5 - m_Name: TurretSelectionCanvas + m_Name: Canvas m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -2563,6 +2588,7 @@ RectTransform: m_Children: - {fileID: 280147083} - {fileID: 1202322936} + - {fileID: 102637059} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -3570,6 +3596,108 @@ Transform: m_CorrespondingSourceObject: {fileID: 2338240775821095493, guid: 1955bdf7dd2940f44aa117fbcf6eb626, type: 3} m_PrefabInstance: {fileID: 497942047} m_PrefabAsset: {fileID: 0} +--- !u!1001 &2334337062712963961 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 102637059} + m_Modifications: + - target: {fileID: 267047305060795697, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_Name + value: HotbarSlot + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_SizeDelta.x + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_SizeDelta.y + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: d3f86d99741589a44882869bec91c6d2, type: 3} +--- !u!224 &2334337062712963962 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 7307898750992612318, guid: d3f86d99741589a44882869bec91c6d2, type: 3} + m_PrefabInstance: {fileID: 2334337062712963961} + m_PrefabAsset: {fileID: 0} --- !u!1001 &3690888448170635710 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/GameBase/DroppedItem.cs b/Assets/Scripts/GameBase/DroppedItem.cs index 3828b3d..fb6addd 100644 --- a/Assets/Scripts/GameBase/DroppedItem.cs +++ b/Assets/Scripts/GameBase/DroppedItem.cs @@ -97,9 +97,7 @@ public class DroppedItem : NetworkBehaviour, IInteractable if (playerObj.TryGetComponent(out var inventory)) { _isProcessed = true; - ItemData data = ItemDatabase.Instance.GetItemByID(_itemDataID.Value); - - inventory.AddItem(data); // 인벤토리에 추가 + inventory.AddItemRpc(_itemDataID.Value, 1); // 인벤토리에 추가 // 3. 획득 성공 시 네트워크 상에서 제거합니다. GetComponent().Despawn(); diff --git a/Assets/Scripts/GameBase/ItemData.cs b/Assets/Scripts/GameBase/ItemData.cs index 55cdb24..3282c74 100644 --- a/Assets/Scripts/GameBase/ItemData.cs +++ b/Assets/Scripts/GameBase/ItemData.cs @@ -5,7 +5,9 @@ public class ItemData : ScriptableObject { public int itemID; public string itemName; - public Sprite icon; + public Sprite icon; + public float weight; // 아이템 개당 무게 + public int maxStack = 99; // 최대 중첩 개수 [Header("Visual Source")] public GameObject originalBlockPrefab; // 이제 이것만 있으면 됩니다! diff --git a/Assets/Scripts/GameBase/ItemDatabase.cs b/Assets/Scripts/GameBase/ItemDatabase.cs index cfdcb97..3a4c005 100644 --- a/Assets/Scripts/GameBase/ItemDatabase.cs +++ b/Assets/Scripts/GameBase/ItemDatabase.cs @@ -1,12 +1,46 @@ using UnityEngine; using System.Collections.Generic; -public class ItemDatabase : MonoBehaviour +[CreateAssetMenu(menuName = "Inventory/Item Database")] +public class ItemDatabase : ScriptableObject { - public static ItemDatabase Instance; + private static ItemDatabase _instance; + + // 전역 어디서든 접근 가능한 Instance 프로퍼티 + public static ItemDatabase Instance + { + get + { + if (_instance == null) + { + // Resources 폴더 안에 있는 "ItemDatabase"라는 이름의 파일을 찾습니다. + _instance = Resources.Load("ItemDatabase"); + + if (_instance == null) + { + Debug.LogError("ItemDatabase 에셋을 찾을 수 없습니다! Resources 폴더 안에 이름이 'ItemDatabase'인 에셋이 있는지 확인하세요."); + } + } + return _instance; + } + } + public List allItems; + private Dictionary _itemCache; - void Awake() => Instance = this; + public ItemData GetItemByID(int id) + { + if (_itemCache == null) InitCache(); + return _itemCache.GetValueOrDefault(id); + } - public ItemData GetItemByID(int id) => allItems.Find(x => x.itemID == id); + private void InitCache() + { + _itemCache = new Dictionary(); + foreach (var item in allItems) + { + if (item != null) + _itemCache[item.itemID] = item; + } + } } \ No newline at end of file diff --git a/Assets/Scripts/Player/InventorySlotUI.cs b/Assets/Scripts/Player/InventorySlotUI.cs new file mode 100644 index 0000000..a0a94c5 --- /dev/null +++ b/Assets/Scripts/Player/InventorySlotUI.cs @@ -0,0 +1,41 @@ +using UnityEngine; +using UnityEngine.UI; +using TMPro; + +public class InventorySlotUI : MonoBehaviour +{ + [Header("UI Elements")] + [SerializeField] private Image iconImage; + [SerializeField] private TextMeshProUGUI amountText; + [SerializeField] private GameObject selectionHighlight; + + // 슬롯의 내용을 갱신하는 함수 + public void UpdateView(int itemID, int amount) + { + // 빈 슬롯 처리 (ID가 -1이거나 개수가 0인 경우) + if (itemID == -1 || amount <= 0) + { + iconImage.enabled = false; + amountText.text = ""; + } + else + { + // 싱글톤 데이터베이스에서 아이템 정보 가져오기 + var itemData = ItemDatabase.Instance.GetItemByID(itemID); + + if (itemData != null) + { + iconImage.sprite = itemData.icon; + iconImage.enabled = true; + amountText.text = amount.ToString(); + } + } + } + + // 선택 하이라이트 표시/숨김 (나중에 1~5번 키 입력 시 사용) + public void SetSelection(bool isSelected) + { + if (selectionHighlight != null) + selectionHighlight.SetActive(isSelected); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Player/InventorySlotUI.cs.meta b/Assets/Scripts/Player/InventorySlotUI.cs.meta new file mode 100644 index 0000000..b560054 --- /dev/null +++ b/Assets/Scripts/Player/InventorySlotUI.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 4c873d40887ad9a439c14bf4f7fc31de \ No newline at end of file diff --git a/Assets/Scripts/Player/ItemPickup.cs b/Assets/Scripts/Player/ItemPickup.cs deleted file mode 100644 index 5c95b87..0000000 --- a/Assets/Scripts/Player/ItemPickup.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Unity.Netcode; -using UnityEngine; - -public class ItemPickup : NetworkBehaviour -{ - public ItemData itemData; - - public void SetItem(ItemData data) => itemData = data; - - private void OnTriggerEnter(Collider medical) - { - if (!IsServer) return; - - // 플레이어인지 확인 - if (medical.CompareTag("Player")) - { - if (medical.TryGetComponent(out var inventory)) - { - inventory.AddItem(itemData); - GetComponent().Despawn(); // 먹었으므로 제거 - } - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Player/ItemPickup.cs.meta b/Assets/Scripts/Player/ItemPickup.cs.meta deleted file mode 100644 index 30643de..0000000 --- a/Assets/Scripts/Player/ItemPickup.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 1e494b2626c9e354eba277618a850ee8 \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerInventory.cs b/Assets/Scripts/Player/PlayerInventory.cs index 510910e..b4bfcb9 100644 --- a/Assets/Scripts/Player/PlayerInventory.cs +++ b/Assets/Scripts/Player/PlayerInventory.cs @@ -1,23 +1,89 @@ using Unity.Netcode; using UnityEngine; -using System.Collections.Generic; +using System; public class PlayerInventory : NetworkBehaviour { - // 아이템 이름과 개수를 저장 - private Dictionary items = new Dictionary(); + [Header("Inventory Settings")] + [Range(1, 10)] // 인스펙터에서 슬라이더로 조절 가능 + public int slotCount = 5; + public float maxWeight = 50f; - public void AddItem(ItemData data) + public struct InventorySlot : INetworkSerializable, IEquatable { - if (!IsServer) return; + public int ItemID; // string에서 int로 변경 + public int Amount; - if (items.ContainsKey(data.itemName)) - items[data.itemName]++; - else - items.Add(data.itemName, 1); + public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter + { + serializer.SerializeValue(ref ItemID); + serializer.SerializeValue(ref Amount); + } - Debug.Log($"[Inventory] {data.itemName} 획득! (현재: {items[data.itemName]}개)"); + public bool Equals(InventorySlot other) => ItemID == other.ItemID && Amount == other.Amount; + } - // 여기서 클라이언트 UI를 갱신하는 ClientRpc를 호출할 수 있습니다. + [Header("References")] + [SerializeField] private ItemDatabase database; + + public NetworkList Slots; + // 무게 정보는 서버에서만 쓰고 나머지는 읽기만 가능 (네트워크 보안) + private NetworkVariable _currentWeight = new NetworkVariable(0f, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Server); + + public float CurrentWeight => _currentWeight.Value; + + void Awake() + { + Slots = new NetworkList(); + } + + public override void OnNetworkSpawn() + { + // 서버에서만 슬롯 초기화 + if (IsServer && Slots.Count == 0) + { + // 설정된 slotCount만큼 데이터 슬롯 생성 + for (int i = 0; i < slotCount; i++) + Slots.Add(new InventorySlot { ItemID = -1, Amount = 0 }); + } + + // 로컬 플레이어라면 UI 연결 + if (IsOwner) + { + QuickslotUI ui = FindFirstObjectByType(); + if (ui != null) ui.BindInventory(this); + } + } + + // PlayerInventory.cs 내의 AddItemRpc 예시 + [Rpc(SendTo.Server, InvokePermission = RpcInvokePermission.Everyone)] + public void AddItemRpc(int itemID, int amount) + { + // 이제 필드 변수 없이 바로 접근 가능! + ItemData data = ItemDatabase.Instance.GetItemByID(itemID); + if (data == null) return; + + float addedWeight = data.weight * amount; + bool added = false; + + for (int i = 0; i < Slots.Count; i++) + { + // 기존에 같은 아이템이 있거나(-1은 빈 슬롯을 의미) 빈 슬롯인 경우 + if (Slots[i].ItemID == itemID || Slots[i].ItemID == -1) + { + Slots[i] = new InventorySlot + { + ItemID = itemID, + Amount = Slots[i].Amount + amount + }; + added = true; + break; + } + } + + if (added) + { + _currentWeight.Value += addedWeight; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerNetworkController.cs b/Assets/Scripts/Player/PlayerNetworkController.cs index cb098e5..080d19f 100644 --- a/Assets/Scripts/Player/PlayerNetworkController.cs +++ b/Assets/Scripts/Player/PlayerNetworkController.cs @@ -20,7 +20,6 @@ public class PlayerNetworkController : NetworkBehaviour [SerializeField] private LayerMask interactableLayer; [SerializeField] private LayerMask constructionLayer; [SerializeField] private float buildSpeedMultiplier = 2f; - [SerializeField] private float pickupRadius = 1.5f; // 줍기 인식 범위 [SerializeField] private LayerMask itemLayer; // DroppedItem 레이어 설정 [Header("Mining Settings")] diff --git a/Assets/Scripts/Player/QuickSlotUI.cs b/Assets/Scripts/Player/QuickSlotUI.cs new file mode 100644 index 0000000..44011c5 --- /dev/null +++ b/Assets/Scripts/Player/QuickSlotUI.cs @@ -0,0 +1,76 @@ +using UnityEngine; +using UnityEngine.UI; +using TMPro; +using Unity.Netcode; +using System.Collections.Generic; + +public class QuickslotUI : MonoBehaviour +{ + [Header("Dynamic Setup")] + [SerializeField] private GameObject slotPrefab; // 생성할 슬롯 프리팹 + [SerializeField] private Transform slotContainer; // 슬롯들이 들어갈 부모 (HotbarPanel) + + [Header("Weight UI")] + [SerializeField] private Slider weightSlider; + [SerializeField] private TextMeshProUGUI weightText; + + private List _uiSlots = new List(); + private PlayerInventory _linkedInventory; + + public void BindInventory(PlayerInventory inventory) + { + _linkedInventory = inventory; + + // 1. 기존에 있던 슬롯 UI들 모두 삭제 (초기화) + foreach (Transform child in slotContainer) Destroy(child.gameObject); + _uiSlots.Clear(); + + // 2. 인벤토리 데이터 크기(slotCount)만큼 UI 프리팹 생성 + for (int i = 0; i < _linkedInventory.slotCount; i++) + { + GameObject newSlot = Instantiate(slotPrefab, slotContainer); + InventorySlotUI slotUI = newSlot.GetComponent(); + _uiSlots.Add(slotUI); + } + + // 3. 이벤트 등록 및 초기 갱신 + _linkedInventory.Slots.OnListChanged += (e) => RefreshAll(); + RefreshAll(); + } + + private void RefreshAll() + { + if (_linkedInventory == null) return; + + for (int i = 0; i < _uiSlots.Count; i++) + { + var data = _linkedInventory.Slots[i]; + _uiSlots[i].UpdateView(data.ItemID, data.Amount); + } + UpdateWeightDisplay(); + } + + // 데이터 변경 이벤트 핸들러 + private void OnInventoryDataChanged(NetworkListEvent changeEvent) + { + RefreshAll(); + } + + private void UpdateWeightDisplay() + { + if (_linkedInventory == null) return; + + float current = _linkedInventory.CurrentWeight; + float max = _linkedInventory.maxWeight; + + if (weightSlider != null) weightSlider.value = current / max; + if (weightText != null) weightText.text = $"{current:F1} / {max:F1} kg"; + } + + private void OnDestroy() + { + // 이벤트 구독 해제 (메모리 누수 방지) + if (_linkedInventory != null) + _linkedInventory.Slots.OnListChanged -= OnInventoryDataChanged; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Player/QuickSlotUI.cs.meta b/Assets/Scripts/Player/QuickSlotUI.cs.meta new file mode 100644 index 0000000..845fddc --- /dev/null +++ b/Assets/Scripts/Player/QuickSlotUI.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f077dc997e302de44ac64b941af02805 \ No newline at end of file