2026-03-30 아이템 사용 진행중

This commit is contained in:
2026-03-30 18:01:09 +09:00
parent d833da5bfa
commit f8773fa168
33 changed files with 613 additions and 8 deletions

Binary file not shown.

View File

@@ -6,11 +6,19 @@ public enum ItemType
CONSUMABLE = 1
}
public enum ItemEffectType
{
NONE = 0,
INTERVAL_DAMAGE = 1
}
[CreateAssetMenu(fileName = "New Item", menuName = "Item")]
public class Item : ScriptableObject
{
public string ItemId;
public ItemType ItemType;
public ItemEffectType ItemEffectType;
public GameObject ItemEffectVisual;
public int SortId;
public string ItemName;
public Sprite Icon; //인벤토리용 2D 아이콘
@@ -30,4 +38,9 @@ public class Item : ScriptableObject
[Header("Collider Settings")]
public Vector3 ColliderCenter = Vector3.zero;
public Vector3 ColliderSize = Vector3.one;
//ItemEffectType.INTERVAL_DAMAGE 일 경우
public float IntervalDamage;
public float IntervalDamageTime;
}

View File

@@ -16,6 +16,9 @@ public class GameManager : MonoBehaviour
public InGameUIManager InGameUI { get; private set; }
public InventoryManager Inventory { get; private set; }
//기타
public ItemEffectManager ItemEffect { get; private set; }
[Header("Item Dynamic Settings")]
public float ItemRotationSpeed = 50f; // 회전 속도
public float ItemBounceAmplitude = 0.1f; // 오르내리는 높이
@@ -44,9 +47,11 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
this.IntroUI = FindFirstObjectByType<IntroUIManager>();
this.InGameUI = FindFirstObjectByType<InGameUIManager>();
this.Inventory = FindFirstObjectByType<InventoryManager>();
this.ItemEffect = FindFirstObjectByType<ItemEffectManager>();
if (this.Level != null) this.Level.OnSceneLoaded(scene, mode);
if (this.Camera != null) this.Camera.OnSceneLoaded(scene, mode);
if (this.ItemEffect != null) this.ItemEffect.OnSceneLoaded(scene, mode);
InputManager.Instance.PlayerInputEnable(true);
GlobalUIManager.Instance.SetSceneLoadingActive(false);

View File

@@ -0,0 +1,43 @@
using System.Collections;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ItemEffectManager : MonoBehaviour
{
public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
}
public void ItemUse(ItemInstance item)
{
if(item.Data.ItemEffectType == ItemEffectType.INTERVAL_DAMAGE)
{
IntervalDamageHealthEffect(GameManager.Instance.Level.CurrentCharacter.GetComponent<Health>(), item.Data.IntervalDamage, item.Data.IntervalDamageTime, item.Data.ItemEffectVisual);
}
}
public void IntervalDamageHealthEffect(Health health,float damage,float time,GameObject itemEffectVisual)
{
IntervalDamage(health, damage,time, itemEffectVisual);
}
//일정 시간 동안 틱대미지 일으키는 함수
public async void IntervalDamage(Health health, float damage,float time, GameObject itemEffectVisual)
{
GameObject fx_Visual = Instantiate(itemEffectVisual, health.transform); // health의 자식으로 이펙트 생성
fx_Visual.transform.localPosition = new Vector3(0, 1.5f, 0);
float tickDamage = damage / time;
while(time <=0)
{
health.ChangeHP(Mathf.FloorToInt(tickDamage)); //소수점 전부 버림
if (health.CurrentHP <= 0) break;
time--;
await Task.Yield();
}
Destroy(fx_Visual);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 784f293946888364996d3928fe23ffd4

View File

@@ -2,17 +2,16 @@
public class PlayerHealth : Health
{
private PlayerStat _pstat;
public int currentHp;
[SerializeField] private PlayerStat _pstat;
void Start()
{
_pstat = GetComponent<PlayerStat>();
//currentHp = _pstat.MaxHp; // 스태틱 데이터를 가져와 초기화
currentHp = _pstat.MaxHp; // 스태틱 데이터를 가져와 초기화
}
public void TakeDamage(int damage)
{
ChangeHP(currentHp - Mathf.Clamp(damage,0,currentHp));
}
}

View File

@@ -183,4 +183,10 @@ public void UpdateSlotUI()
}
//SlotBg.sprite = _rarityImage.sprite;
}
public void ItemUse()
{
GameManager.Instance.ItemEffect.ItemUse(currentItem);
currentItem.CurrentStack -= 1;
}
}

View File

@@ -2,5 +2,11 @@
public class Health : MonoBehaviour
{
protected int currentHp;
public int CurrentHP { get { return currentHp; } }
public void ChangeHP(int newHp)
{
currentHp = newHp;
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 12cb1cd502e4ce040a0019a8b07df585
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,130 @@
fileFormatVersion: 2
guid: 8e5cd36b33255f04ca2d84e2700b0968
ModelImporter:
serializedVersion: 24200
internalIDToNameTable: []
externalObjects:
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Cork_Brown_Custom
second: {fileID: 2100000, guid: a6ebbd296f5307343ab740c01729e4e1, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Glass_Normal_Custom
second: {fileID: 2100000, guid: 35230064915296a4c95376a7a1bbfed8, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Liquid_Red_Custom
second: {fileID: 2100000, guid: 78f8742722f4d5049bbf2d595009af95, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Metal_Steel_Custom
second: {fileID: 2100000, guid: 7287a7324b5c3eb40a70151e4909060c, type: 2}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
generateMeshLods: 0
meshLodGenerationFlags: 0
maximumMeshLod: -1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4cdc640eaa107e9479ecf7c20af75e4b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,130 @@
fileFormatVersion: 2
guid: e04a9c7cba44979488000b9763d524c7
ModelImporter:
serializedVersion: 24200
internalIDToNameTable: []
externalObjects:
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Cork_Brown_Custom
second: {fileID: 2100000, guid: a6ebbd296f5307343ab740c01729e4e1, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Glass_Normal_Custom
second: {fileID: 2100000, guid: 35230064915296a4c95376a7a1bbfed8, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Liquid_Red_Custom
second: {fileID: 2100000, guid: 78f8742722f4d5049bbf2d595009af95, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Metal_Steel_Custom
second: {fileID: 2100000, guid: 7287a7324b5c3eb40a70151e4909060c, type: 2}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
generateMeshLods: 0
meshLodGenerationFlags: 0
maximumMeshLod: -1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 12406acb8e7c1804591ff85d17b34ab0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,130 @@
fileFormatVersion: 2
guid: 81f7a23414b425f40a1d5597cb653c7f
ModelImporter:
serializedVersion: 24200
internalIDToNameTable: []
externalObjects:
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Cork_Brown_Custom
second: {fileID: 2100000, guid: a6ebbd296f5307343ab740c01729e4e1, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Glass_Normal_Custom
second: {fileID: 2100000, guid: 35230064915296a4c95376a7a1bbfed8, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Liquid_Red_Custom
second: {fileID: 2100000, guid: 426beac577db40d4498e1d95d6cfb540, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: Metal_Steel_Custom
second: {fileID: 2100000, guid: 7287a7324b5c3eb40a70151e4909060c, type: 2}
materials:
materialImportMode: 2
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
generateMeshLods: 0
meshLodGenerationFlags: 0
maximumMeshLod: -1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 13a12e6044f5fdd4f98f840de6ac367e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ab3e607c6988e2e4390fc7cc9cc4385d
guid: ce87e417378c7ec41b7eae6d812d3308
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8bf88f804bb21ad41aa447da70b39409
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,84 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-2873080775141026017
MonoBehaviour:
m_ObjectHideFlags: 11
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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 10
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Liquid_LightGreen_Custom
m_Shader: {fileID: -6465566751694194690, guid: d0de2408f4d93cb45a499bbfcbc9dcb8, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2999
stringTagMap: {}
disabledShaderPasses:
- MOTIONVECTORS
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _GradientTexture:
m_Texture: {fileID: 2800000, guid: 829f4efcb8f42d446b87cf13f469ece2, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _GrayscaleTex:
m_Texture: {fileID: 2800000, guid: b4cb285455d9a614baf38f250a89dece, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Main_Texture:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Amplitude: 0.1244
- _FoamWidth: 0
- _Foam_Smoothness: 0.01
- _Frequency: 19.5
- _GradientCount: 110
- _GradientIndex: 69
- _QueueControl: 0
- _QueueOffset: -1
- _Rim_Power: 2.44
- _WobbleX: -0
- _WobbleZ: -0
m_Colors:
- _BottomColor: {r: 0.63596004, g: 2.9960783, b: 0.872428, a: 1}
- _FillAmount: {r: 0, g: -0.46269467, b: 0.000000007450581, a: 0}
- _FoamColor: {r: 0.6494246, g: 0.8980392, b: 0.6392157, a: 1}
- _Rim_Color: {r: 0.37254906, g: 1, b: 0.42787504, a: 1}
- _TopColor: {r: 0.20784311, g: 0.85882354, b: 0.2391922, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 426beac577db40d4498e1d95d6cfb540
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 0a2d05f3e497afb439d3032e04afeeb7
guid: fac7c32f28d818a4c91840dc73bd9358
folderAsset: yes
DefaultImporter:
externalObjects: {}