Merge branch 'main' of https://gitea.deprived.dev/Sveskejuice/fgm24
This commit is contained in:
commit
aff0d01fc6
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 98edd43838a689944bf8b51dc59cb761
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,148 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-2249664144050529756
|
||||
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: 7
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Rope
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _AlphaTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MaskTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
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:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnableExternalAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.005
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.202
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.554717, g: 0.2277991, b: 0.032445684, a: 1}
|
||||
- _Color: {r: 0.554717, g: 0.22779906, b: 0.032445684, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _Flip: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 62e10f2f26f232f49affb7663a8064fb
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -135,6 +135,7 @@ GameObject:
|
|||
- component: {fileID: 347555805}
|
||||
- component: {fileID: 347555804}
|
||||
- component: {fileID: 347555803}
|
||||
- component: {fileID: 347555807}
|
||||
m_Layer: 0
|
||||
m_Name: EnemyTest (3)
|
||||
m_TagString: Untagged
|
||||
|
@ -271,6 +272,39 @@ Transform:
|
|||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &347555807
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 347555802}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
maxHealth: 100
|
||||
OnHealthZero:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 347555807}
|
||||
m_TargetAssemblyTypeName: HealthComponent, Assembly-CSharp
|
||||
m_MethodName: SimpleKill
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
OnHealthChange:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
minThreshold: 1
|
||||
squezeDamageScalor: 1
|
||||
--- !u!1 &418427021
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -283,6 +317,7 @@ GameObject:
|
|||
- component: {fileID: 418427024}
|
||||
- component: {fileID: 418427023}
|
||||
- component: {fileID: 418427022}
|
||||
- component: {fileID: 418427026}
|
||||
m_Layer: 0
|
||||
m_Name: EnemyTest (4)
|
||||
m_TagString: Untagged
|
||||
|
@ -419,6 +454,39 @@ Transform:
|
|||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &418427026
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 418427021}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
maxHealth: 100
|
||||
OnHealthZero:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 418427026}
|
||||
m_TargetAssemblyTypeName: HealthComponent, Assembly-CSharp
|
||||
m_MethodName: SimpleKill
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
OnHealthChange:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
minThreshold: 1
|
||||
squezeDamageScalor: 1
|
||||
--- !u!1 &437176298
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -431,6 +499,7 @@ GameObject:
|
|||
- component: {fileID: 437176300}
|
||||
- component: {fileID: 437176299}
|
||||
- component: {fileID: 437176302}
|
||||
- component: {fileID: 437176303}
|
||||
m_Layer: 0
|
||||
m_Name: EnemyTest (2)
|
||||
m_TagString: Untagged
|
||||
|
@ -567,6 +636,39 @@ Rigidbody2D:
|
|||
m_SleepingMode: 1
|
||||
m_CollisionDetection: 1
|
||||
m_Constraints: 0
|
||||
--- !u!114 &437176303
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 437176298}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
maxHealth: 100
|
||||
OnHealthZero:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 437176303}
|
||||
m_TargetAssemblyTypeName: HealthComponent, Assembly-CSharp
|
||||
m_MethodName: SimpleKill
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
OnHealthChange:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
minThreshold: 1
|
||||
squezeDamageScalor: 1
|
||||
--- !u!1 &442848047
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -578,6 +680,7 @@ GameObject:
|
|||
- component: {fileID: 442848048}
|
||||
- component: {fileID: 442848050}
|
||||
- component: {fileID: 442848049}
|
||||
- component: {fileID: 442848051}
|
||||
m_Layer: 5
|
||||
m_Name: Health
|
||||
m_TagString: Untagged
|
||||
|
@ -701,6 +804,21 @@ CanvasRenderer:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 442848047}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &442848051
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 442848047}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6ea817cc94396c24199c7d5b0f34e889, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
padding: 'Health: '
|
||||
healthText: {fileID: 442848049}
|
||||
healthComponent: {fileID: 1451580751}
|
||||
--- !u!1 &484915623
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -919,8 +1037,26 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
maxHealth: 100
|
||||
currentHealth: 0
|
||||
healthText: {fileID: 442848049}
|
||||
OnHealthZero:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1451580751}
|
||||
m_TargetAssemblyTypeName: HealthComponent, Assembly-CSharp
|
||||
m_MethodName: SimpleKill
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
OnHealthChange:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
minThreshold: 1
|
||||
squezeDamageScalor: 0
|
||||
--- !u!114 &1451580752
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1344,6 +1480,7 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 1973576216}
|
||||
- component: {fileID: 1973576217}
|
||||
- component: {fileID: 1973576218}
|
||||
m_Layer: 0
|
||||
m_Name: Rope
|
||||
m_TagString: Untagged
|
||||
|
@ -1393,7 +1530,112 @@ MonoBehaviour:
|
|||
serializedVersion: 2
|
||||
m_Bits: 1
|
||||
pullForce: 65
|
||||
lineRenderer: {fileID: 1973576218}
|
||||
testPos: {x: 0, y: 0}
|
||||
--- !u!120 &1973576218
|
||||
LineRenderer:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1973576215}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 0
|
||||
m_LightProbeUsage: 0
|
||||
m_ReflectionProbeUsage: 0
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 62e10f2f26f232f49affb7663a8064fb, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Positions:
|
||||
- {x: 0, y: 0, z: 0}
|
||||
- {x: 0, y: 0, z: 1}
|
||||
m_Parameters:
|
||||
serializedVersion: 3
|
||||
widthMultiplier: 1
|
||||
widthCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0.2280693
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
colorGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 1, g: 1, b: 1, a: 1}
|
||||
key1: {r: 1, g: 1, b: 1, a: 1}
|
||||
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 65535
|
||||
ctime2: 0
|
||||
ctime3: 0
|
||||
ctime4: 0
|
||||
ctime5: 0
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_ColorSpace: -1
|
||||
m_NumColorKeys: 2
|
||||
m_NumAlphaKeys: 2
|
||||
numCornerVertices: 0
|
||||
numCapVertices: 0
|
||||
alignment: 0
|
||||
textureMode: 0
|
||||
textureScale: {x: 1, y: 1}
|
||||
shadowBias: 0.5
|
||||
generateLightingData: 0
|
||||
m_MaskInteraction: 0
|
||||
m_UseWorldSpace: 1
|
||||
m_Loop: 0
|
||||
m_ApplyActiveColorSpace: 1
|
||||
--- !u!1 &1993214202
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using TMPro;
|
||||
|
||||
public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver
|
||||
{
|
||||
[SerializeField] int maxHealth = 100;
|
||||
public int currentHealth { get; private set; }
|
||||
|
||||
public UnityEvent OnHealthZero;
|
||||
public UnityEvent<int, int> OnHealthChange;
|
||||
|
||||
[Header("Squeze Damage")]
|
||||
[SerializeField]
|
||||
float minThreshold = 1f;
|
||||
|
||||
[SerializeField]
|
||||
float squezeDamageScalor = 1f;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
currentHealth = maxHealth;
|
||||
}
|
||||
|
||||
public void TakeDamage(int damage)
|
||||
{
|
||||
currentHealth -= damage;
|
||||
OnHealthChange?.Invoke(currentHealth + damage, currentHealth);
|
||||
|
||||
if (currentHealth <= 0)
|
||||
OnHealthZero?.Invoke();
|
||||
}
|
||||
|
||||
public void TakeSquezeDamage(float squezeDamage)
|
||||
{
|
||||
Debug.Log($"Taking {squezeDamage}");
|
||||
if (squezeDamage < minThreshold) return;
|
||||
|
||||
TakeDamage((int) Mathf.Round(squezeDamage * squezeDamageScalor));
|
||||
}
|
||||
|
||||
public void SimpleKill()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class PlayerHP : MonoBehaviour
|
||||
{
|
||||
public int maxHealth = 100;
|
||||
public int currentHealth;
|
||||
public TextMeshProUGUI healthText;
|
||||
void Start()
|
||||
{
|
||||
currentHealth = maxHealth;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (currentHealth <= 0)
|
||||
{
|
||||
// TODO: Game Over
|
||||
}
|
||||
if (healthText != null && currentHealth > 0)
|
||||
{
|
||||
healthText.text = "Health: " + currentHealth;
|
||||
}
|
||||
else if (healthText != null && currentHealth <= 0)
|
||||
healthText.text = "Health: 0";
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
TakeDamage(5);
|
||||
}
|
||||
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
currentHealth -= (int)damage;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
public interface ISquezeDamageReceiver
|
||||
{
|
||||
public void TakeSquezeDamage(float squezeDamage);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d31d8fbcb6322ba4ba6891dba7d49bd0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -47,14 +47,17 @@ public class RopeSimulator : MonoBehaviour
|
|||
[SerializeField, Range(0f, 100f)]
|
||||
float pullForce = 20f;
|
||||
|
||||
[Header("Rendering")]
|
||||
[SerializeField] LineRenderer lineRenderer;
|
||||
|
||||
int[] order;
|
||||
|
||||
public Vector2 testPos;
|
||||
|
||||
Vector2 prevStartPos;
|
||||
|
||||
Rope rope;
|
||||
|
||||
Dictionary<Collider2D, float> colliderToSquezeForce = new();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//rope = new RopeBuilder()
|
||||
|
@ -100,6 +103,8 @@ public class RopeSimulator : MonoBehaviour
|
|||
|
||||
private void Update()
|
||||
{
|
||||
colliderToSquezeForce.Clear();
|
||||
|
||||
rope.points.First().position = start.position;
|
||||
rope.points.Last().position = end.position;
|
||||
|
||||
|
@ -128,7 +133,19 @@ public class RopeSimulator : MonoBehaviour
|
|||
start.gameObject.GetComponent<Rigidbody2D>().AddForce(pullDirection * overshoot * pullForce);
|
||||
}
|
||||
|
||||
prevStartPos = start.position;
|
||||
// Handle squeze kills
|
||||
foreach (var collider in colliderToSquezeForce)
|
||||
{
|
||||
ISquezeDamageReceiver squezeDamageReceiver = collider.Key.GetComponent<ISquezeDamageReceiver>();
|
||||
if (squezeDamageReceiver == null) continue;
|
||||
|
||||
squezeDamageReceiver.TakeSquezeDamage(collider.Value);
|
||||
}
|
||||
|
||||
// Update line renderer
|
||||
var positions = rope.points.Select(p => new Vector3(p.position.x, p.position.y, 0f)).ToArray();
|
||||
lineRenderer.positionCount = positions.Length;
|
||||
lineRenderer.SetPositions(positions);
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
|
@ -216,10 +233,17 @@ public class RopeSimulator : MonoBehaviour
|
|||
Collider2D hitCollider = Physics2D.OverlapCircle(p.position, ropeRadius, staticColliderMask);
|
||||
if (hitCollider == null) return;
|
||||
|
||||
// Register the squeze force this rope particle is squezing the collider
|
||||
Vector2 resolvedPos = hitCollider.ClosestPoint(p.position);
|
||||
Vector2 penetrationDir = (resolvedPos - p.position).normalized;
|
||||
Vector2 finalPos = resolvedPos - penetrationDir * ropeRadius;
|
||||
|
||||
Vector2 penetration = resolvedPos - p.position;
|
||||
Vector2 finalPos = resolvedPos - penetration.normalized * ropeRadius;
|
||||
|
||||
float squezeForce;
|
||||
if (!colliderToSquezeForce.TryGetValue(hitCollider, out squezeForce))
|
||||
colliderToSquezeForce.Add(hitCollider, squezeForce + penetration.magnitude);
|
||||
else
|
||||
colliderToSquezeForce[hitCollider] = squezeForce + penetration.magnitude;
|
||||
|
||||
p.position = finalPos;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8b645cb8aa203484aaefb2b6f86e696c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,31 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class HealthDisplay : MonoBehaviour
|
||||
{
|
||||
[SerializeField] string padding = "Health: ";
|
||||
[SerializeField] TextMeshProUGUI healthText;
|
||||
[SerializeField] HealthComponent healthComponent;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
healthText.text = padding + healthComponent.currentHealth;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
healthComponent.OnHealthChange.AddListener(UpdateHealth);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
healthComponent.OnHealthChange.RemoveListener(UpdateHealth);
|
||||
}
|
||||
|
||||
public void UpdateHealth(int prevHealth, int newHealth)
|
||||
{
|
||||
healthText.text = padding + healthComponent.currentHealth;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6ea817cc94396c24199c7d5b0f34e889
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue