low health tower particles

This commit is contained in:
Sveske Juice 2024-04-21 02:34:45 +02:00
parent 1a04482283
commit 430da56a0f
4 changed files with 154 additions and 2 deletions

View File

@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 5565472806559733162} - component: {fileID: 5565472806559733162}
- component: {fileID: -4368249141776341009} - component: {fileID: -4368249141776341009}
- component: {fileID: 8326258332086092779} - component: {fileID: 8326258332086092779}
- component: {fileID: 1772828647246745231}
m_Layer: 8 m_Layer: 8
m_Name: BaseTower m_Name: BaseTower
m_TagString: Untagged m_TagString: Untagged
@ -37,6 +38,7 @@ Transform:
- {fileID: 3231648858884615218} - {fileID: 3231648858884615218}
- {fileID: 4220667717328304921} - {fileID: 4220667717328304921}
- {fileID: 85471039882070109} - {fileID: 85471039882070109}
- {fileID: 8658008248069201232}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7883233016828513649 --- !u!114 &7883233016828513649
@ -70,6 +72,21 @@ MonoBehaviour:
OnHealthChange: OnHealthChange:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
OnHealthChange2:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1772828647246745231}
m_TargetAssemblyTypeName: EnableCompare, Assembly-CSharp
m_MethodName: EnableIfLess
m_Mode: 0
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
--- !u!65 &5565472806559733162 --- !u!65 &5565472806559733162
BoxCollider: BoxCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -214,6 +231,20 @@ MonoBehaviour:
- {fileID: 6733197279741857448} - {fileID: 6733197279741857448}
- {fileID: 3875905170154804327} - {fileID: 3875905170154804327}
- {fileID: 7471033669110783771} - {fileID: 7471033669110783771}
--- !u!114 &1772828647246745231
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 872127579833310669}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7e05852b3744c955a930bc6a66b17e6a, type: 3}
m_Name:
m_EditorClassIdentifier:
toEnable: {fileID: 3424060888733970503}
threshold: 30
--- !u!1 &881819783351085137 --- !u!1 &881819783351085137
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1114,8 +1145,8 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6616012430861705016} m_GameObject: {fileID: 6616012430861705016}
serializedVersion: 2 serializedVersion: 2
m_LocalRotation: {x: 0.3060453, y: 0.000000023165901, z: -0.0000000074471513, w: 0.952017} m_LocalRotation: {x: 0.3060453, y: -0.000000023165901, z: 0.0000000074471513, w: 0.952017}
m_LocalPosition: {x: 0, y: 1.661, z: -3} m_LocalPosition: {x: 0, y: -32.5, z: 39}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
@ -1259,3 +1290,88 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
healthBar: {fileID: 5350365205670160062} healthBar: {fileID: 5350365205670160062}
attachHealth: {fileID: 7883233016828513649} attachHealth: {fileID: 7883233016828513649}
--- !u!1001 &2147029337253988588
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 527409087646353271}
m_Modifications:
- target: {fileID: 3625242609487067307, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_Name
value: TowerLowHPParticles
objectReference: {fileID: 0}
- target: {fileID: 3625242609487067307, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: fcc6137314310644387e407a7a1e092f, type: 3}
--- !u!1 &3424060888733970503 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 3625242609487067307, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
m_PrefabInstance: {fileID: 2147029337253988588}
m_PrefabAsset: {fileID: 0}
--- !u!4 &8658008248069201232 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7344433588278711740, guid: fcc6137314310644387e407a7a1e092f,
type: 3}
m_PrefabInstance: {fileID: 2147029337253988588}
m_PrefabAsset: {fileID: 0}

View File

@ -0,0 +1,23 @@
using UnityEngine;
public class EnableCompare : MonoBehaviour
{
[SerializeField] private GameObject toEnable;
[SerializeField] private float threshold = 20f;
public void EnableIfLess(float value)
{
if (value < threshold)
{
toEnable.SetActive(true);
}
}
public void EnableIfGreater(float value)
{
if (value > threshold)
{
toEnable.SetActive(true);
}
}
}

View File

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

View File

@ -13,6 +13,7 @@ public class HealthComponent : MonoBehaviour
public float StartHealth => startHealth; public float StartHealth => startHealth;
public UnityEvent OnHealthZero; public UnityEvent OnHealthZero;
public UnityEvent<float, float> OnHealthChange; public UnityEvent<float, float> OnHealthChange;
public UnityEvent<float> OnHealthChange2;
void Awake() void Awake()
{ {
@ -22,6 +23,7 @@ public class HealthComponent : MonoBehaviour
public void TakeDamage(float damage) public void TakeDamage(float damage)
{ {
OnHealthChange?.Invoke(currentHealth, currentHealth - damage); OnHealthChange?.Invoke(currentHealth, currentHealth - damage);
OnHealthChange2?.Invoke(currentHealth - damage);
OnHealthChangeAtPos?.Invoke(transform.position, currentHealth - damage); OnHealthChangeAtPos?.Invoke(transform.position, currentHealth - damage);
currentHealth -= damage; currentHealth -= damage;