Enemies have blood. ANd also health bars ig

This commit is contained in:
Sveske Juice 2024-02-03 13:18:28 -08:00
parent 0381f9cc90
commit 61c1c81dd5
12 changed files with 324 additions and 15 deletions

View File

@ -62,19 +62,19 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 9123080415032741332}
m_Position: {x: 30, y: 40, z: 0}
m_Position: {x: -150, y: 60, z: 0}
- serializedVersion: 1
m_State: {fileID: 548892628922324246}
m_Position: {x: 570, y: 80, z: 0}
m_Position: {x: 470, y: 80, z: 0}
- serializedVersion: 1
m_State: {fileID: 5718945116413065706}
m_Position: {x: 570, y: 240, z: 0}
m_Position: {x: 360, y: 220, z: 0}
- serializedVersion: 1
m_State: {fileID: -8349034508235637004}
m_Position: {x: 570, y: 0, z: 0}
m_Position: {x: 400, y: 10, z: 0}
- serializedVersion: 1
m_State: {fileID: 3308394434488297487}
m_Position: {x: 570, y: 160, z: 0}
m_Position: {x: 420, y: 140, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions:
- {fileID: -6173615721886091892}
@ -85,8 +85,8 @@ AnimatorStateMachine:
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 300, y: 70, z: 0}
m_EntryPosition: {x: 20, y: 160, z: 0}
m_AnyStatePosition: {x: 170, y: 80, z: 0}
m_EntryPosition: {x: -160, y: 180, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 9123080415032741332}
@ -154,31 +154,31 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Run
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Mop
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: RunMop
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Swing
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer

8
Assets/Prefabs/UI.meta Normal file
View File

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

View File

@ -0,0 +1,130 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1788304117561062157
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 221465835851718647}
- component: {fileID: 664351549858138631}
- component: {fileID: 7075700545869768638}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &221465835851718647
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1788304117561062157}
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: 7656168731602766272}
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!222 &664351549858138631
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1788304117561062157}
m_CullTransparentMesh: 1
--- !u!114 &7075700545869768638
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1788304117561062157}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
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: 21300000, guid: 8c59015655dd78441962423900e5e31f, type: 3}
m_Type: 3
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 0
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &5537527563549888860
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7656168731602766272}
- component: {fileID: 3891416435710064780}
m_Layer: 5
m_Name: HealthBar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7656168731602766272
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5537527563549888860}
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: 221465835851718647}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 300, y: 100}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &3891416435710064780
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5537527563549888860}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5265f2859819fd84a9a27a3301dd3cb7, type: 3}
m_Name:
m_EditorClassIdentifier:
attachedHealth: {fileID: 0}
healthBarImg: {fileID: 7075700545869768638}
healthLeftColor: {r: 1, g: 1, b: 1, a: 0}
unusedHealth: {r: 1, g: 1, b: 1, a: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0ea0f1215ba49f5448e8e8d60a899fe8
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -121,6 +121,7 @@ GameObject:
- component: {fileID: 8373694659570615877}
- component: {fileID: -1793628155013383594}
- component: {fileID: 3477818934881411113}
- component: {fileID: 58401337460216238}
m_Layer: 0
m_Name: Enemy1V1
m_TagString: Untagged
@ -261,3 +262,39 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3}
m_Name:
m_EditorClassIdentifier:
invert: 0
--- !u!70 &58401337460216238
CapsuleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6905705041633878913}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_Size: {x: 1, y: 2}
m_Direction: 0

View File

@ -120,6 +120,7 @@ GameObject:
- component: {fileID: 1240337968825240287}
- component: {fileID: -7368324163293952402}
- component: {fileID: 1203571175389907979}
- component: {fileID: 4546369442828517320}
m_Layer: 0
m_Name: Enemy1V2
m_TagString: Untagged
@ -239,3 +240,39 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3}
m_Name:
m_EditorClassIdentifier:
invert: 0
--- !u!70 &4546369442828517320
CapsuleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6905705041633878913}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_Size: {x: 1, y: 2}
m_Direction: 0

View File

@ -120,6 +120,7 @@ GameObject:
- component: {fileID: -3565830332974631248}
- component: {fileID: -99408799291400877}
- component: {fileID: 7065122129502476799}
- component: {fileID: 1757117162005437690}
m_Layer: 0
m_Name: Enemy1V3
m_TagString: Untagged
@ -239,3 +240,39 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3}
m_Name:
m_EditorClassIdentifier:
invert: 0
--- !u!70 &1757117162005437690
CapsuleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6905705041633878913}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_Size: {x: 1, y: 2}
m_Direction: 0

View File

@ -14,6 +14,7 @@ public struct Droplet
public class BloodComputeShader : MonoBehaviour
{
public static BloodComputeShader Instance { get; private set; }
public int numParticles = 1000;
public ComputeShader bloodCompute;
@ -53,7 +54,15 @@ public class BloodComputeShader : MonoBehaviour
[SerializeField]
uint bufferLookPointer = 0;
// Start is called before the first frame update
private void Awake()
{
if (Instance != null)
{
Destroy(gameObject);
return;
}
Instance = this;
}
void Start()
{
var mops = FindObjectsByType<Mop>(FindObjectsSortMode.None);

View File

@ -87,7 +87,7 @@ void InitDust (uint3 id : SV_DispatchThreadID)
particles[i].velocity = nvel;
particles[i].position = particleInitPos;
particles[i].position.z = 1;
particles[i].position.z = 0.01;
particles[i].enabled = 1;
particles[i].airborne = 1;
positions[i] = float4(particles[i].position, 1 * size);

View File

@ -0,0 +1,31 @@
using UnityEngine;
using UnityEngine.UI;
public class HealthBar : MonoBehaviour
{
[SerializeField]
private HealthComponent attachedHealth;
[SerializeField]
private Image healthBarImg;
[SerializeField]
private Color healthLeftColor, unusedHealth;
private void OnEnable()
{
attachedHealth.OnHealthChange.AddListener(UpdateHealthBar);
}
private void OnDisable()
{
attachedHealth.OnHealthChange.RemoveListener(UpdateHealthBar);
}
private void UpdateHealthBar(int prevHealth, int newHealth)
{
float percent = ((float) newHealth) / ((float)attachedHealth.getMaxHealth());
Debug.Log(percent);
healthBarImg.fillAmount = percent;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5265f2859819fd84a9a27a3301dd3cb7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -38,8 +38,10 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver
currentHealth -= damage;
OnHealthChange?.Invoke(currentHealth + damage, currentHealth);
if (currentHealth <= 0)
if (currentHealth <= 0) {
OnHealthZero?.Invoke();
BloodComputeShader.Instance.createBlood(transform.position, maxHealth*10, maxHealth / 25.0f);
}
}
public void TakeSquezeDamage(float squezeDamage)