damage text white orange red

This commit is contained in:
Sveske Juice 2024-02-03 17:11:43 -08:00
parent c565a38cc9
commit fdd5a5d3a3
5 changed files with 39 additions and 12 deletions

View File

@ -109,8 +109,8 @@ MonoBehaviour:
m_fontMaterials: [] m_fontMaterials: []
m_fontColor32: m_fontColor32:
serializedVersion: 2 serializedVersion: 2
rgba: 4279085303 rgba: 4294967295
m_fontColor: {r: 0.9685534, g: 0.6569338, b: 0.051777944, a: 1} m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0 m_enableVertexGradient: 0
m_colorMode: 3 m_colorMode: 3
m_fontColorGradient: m_fontColorGradient:
@ -258,3 +258,8 @@ MonoBehaviour:
m_PostInfinity: 2 m_PostInfinity: 2
m_RotationOrder: 4 m_RotationOrder: 4
damageText: {fileID: 2851877176569532699} damageText: {fileID: 2851877176569532699}
normalColor: {r: 0.90943396, g: 0.90943396, b: 0.90943396, a: 1}
critColor: {r: 1, g: 0.63425434, b: 0.2245282, a: 1}
superCritColor: {r: 1, g: 0.103773475, b: 0.103773475, a: 1}
critThreshold: 25
superCritThreshold: 65

View File

@ -1702,6 +1702,11 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 880679715} m_GameObject: {fileID: 880679715}
m_CullTransparentMesh: 1 m_CullTransparentMesh: 1
--- !u!4 &1053616514 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3}
m_PrefabInstance: {fileID: 1968948229}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1194834060 stripped --- !u!4 &1194834060 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} m_CorrespondingSourceObject: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
@ -1751,7 +1756,8 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
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:
- {fileID: 1053616514}
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!1001 &1232208432 --- !u!1001 &1232208432
@ -3693,19 +3699,19 @@ PrefabInstance:
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
serializedVersion: 3 serializedVersion: 3
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 1206522693}
m_Modifications: m_Modifications:
- target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3} - target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: -10.853601 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3} - target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: -18.801167 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3} - target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: -0.052307792 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3} - target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3}
propertyPath: m_LocalRotation.w propertyPath: m_LocalRotation.w
@ -4041,5 +4047,4 @@ SceneRoots:
- {fileID: 1920006249} - {fileID: 1920006249}
- {fileID: 640312360} - {fileID: 640312360}
- {fileID: 5796191506433166633} - {fileID: 5796191506433166633}
- {fileID: 1968948229}
- {fileID: 1206522693} - {fileID: 1206522693}

View File

@ -78,6 +78,6 @@ Material:
- _UVSec: 0 - _UVSec: 0
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:
- _Color: {r: 0.8301887, g: 0.15299344, b: 0.13705944, a: 0.4627451} - _Color: {r: 0.8301887, g: 0.15299338, b: 0.13705936, a: 0.7372549}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []

View File

@ -62,8 +62,12 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver
accumulatedDamageInTick += damage; accumulatedDamageInTick += damage;
if (currentHealth <= 0) { if (currentHealth <= 0) {
// Make sure to flush accumulated when dying
if (accumulatedDamageInTick > 1f)
OnHealthChangeAtPos?.Invoke(transform.position.Add(y: 2f), accumulatedDamageInTick);
OnHealthZero?.Invoke(); OnHealthZero?.Invoke();
BloodComputeShader.Instance.createBlood(transform.position, (int)(maxHealth *maxHealth * BloodComputeShader.Instance.scoreMult), maxHealth / 25.0f); BloodComputeShader.Instance.createBlood(transform.position, (int)(maxHealth *maxHealth * BloodComputeShader.Instance.scoreMult), maxHealth / 8.0f);
} }
} }

View File

@ -6,11 +6,24 @@ using TMPro;
public class DamageText : MonoBehaviour public class DamageText : MonoBehaviour
{ {
[SerializeField] AnimationCurve damageToSize; [SerializeField] AnimationCurve damageToSize;
[SerializeField] TMPro.TextMeshPro damageText; [SerializeField] TextMeshPro damageText;
[SerializeField]
private Color normalColor, critColor, superCritColor;
[SerializeField]
private float critThreshold, superCritThreshold;
public void Init(float damage) public void Init(float damage)
{ {
transform.localScale = Vector2.one * damageToSize.Evaluate(damage); transform.localScale = Vector3.one * damageToSize.Evaluate(damage);
damageText.color = normalColor;
if (damage > critThreshold)
damageText.color = critColor;
if (damage > superCritThreshold)
damageText.color = superCritColor;
damageText.text = damage.ToString(); damageText.text = damage.ToString();
} }
} }