From fdd5a5d3a376b98fdaf925c0eeb264dbeca77731 Mon Sep 17 00:00:00 2001 From: Sveske Juice Date: Sat, 3 Feb 2024 17:11:43 -0800 Subject: [PATCH] damage text white orange red --- Assets/Prefabs/UI/DamageText.prefab | 9 +++++++-- Assets/Scenes/GameScene.unity | 17 +++++++++++------ Assets/Scripts/Dust.mat | 2 +- Assets/Scripts/Player/HealthComponent.cs | 6 +++++- Assets/Scripts/UI/DamageText.cs | 17 +++++++++++++++-- 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Assets/Prefabs/UI/DamageText.prefab b/Assets/Prefabs/UI/DamageText.prefab index 2a75414..864c623 100644 --- a/Assets/Prefabs/UI/DamageText.prefab +++ b/Assets/Prefabs/UI/DamageText.prefab @@ -109,8 +109,8 @@ MonoBehaviour: m_fontMaterials: [] m_fontColor32: serializedVersion: 2 - rgba: 4279085303 - m_fontColor: {r: 0.9685534, g: 0.6569338, b: 0.051777944, a: 1} + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} m_enableVertexGradient: 0 m_colorMode: 3 m_fontColorGradient: @@ -258,3 +258,8 @@ MonoBehaviour: m_PostInfinity: 2 m_RotationOrder: 4 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 diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index f9500f4..f2b8b1e 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -1702,6 +1702,11 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 880679715} 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 Transform: m_CorrespondingSourceObject: {fileID: 320690117028550720, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} @@ -1751,7 +1756,8 @@ Transform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: [] + m_Children: + - {fileID: 1053616514} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1232208432 @@ -3693,19 +3699,19 @@ PrefabInstance: serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 0} + m_TransformParent: {fileID: 1206522693} m_Modifications: - target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3} propertyPath: m_LocalPosition.x - value: -10.853601 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3} propertyPath: m_LocalPosition.y - value: -18.801167 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3} propertyPath: m_LocalPosition.z - value: -0.052307792 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3288169701052299107, guid: 25c9a2db8fc5b7c4f8feebba5c73e7a3, type: 3} propertyPath: m_LocalRotation.w @@ -4041,5 +4047,4 @@ SceneRoots: - {fileID: 1920006249} - {fileID: 640312360} - {fileID: 5796191506433166633} - - {fileID: 1968948229} - {fileID: 1206522693} diff --git a/Assets/Scripts/Dust.mat b/Assets/Scripts/Dust.mat index 11127cf..f91878d 100644 --- a/Assets/Scripts/Dust.mat +++ b/Assets/Scripts/Dust.mat @@ -78,6 +78,6 @@ Material: - _UVSec: 0 - _ZWrite: 1 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} m_BuildTextureStacks: [] diff --git a/Assets/Scripts/Player/HealthComponent.cs b/Assets/Scripts/Player/HealthComponent.cs index 8d9babc..550d44b 100644 --- a/Assets/Scripts/Player/HealthComponent.cs +++ b/Assets/Scripts/Player/HealthComponent.cs @@ -62,8 +62,12 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver accumulatedDamageInTick += damage; if (currentHealth <= 0) { + // Make sure to flush accumulated when dying + if (accumulatedDamageInTick > 1f) + OnHealthChangeAtPos?.Invoke(transform.position.Add(y: 2f), accumulatedDamageInTick); + 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); } } diff --git a/Assets/Scripts/UI/DamageText.cs b/Assets/Scripts/UI/DamageText.cs index 034843f..9a8ad0b 100644 --- a/Assets/Scripts/UI/DamageText.cs +++ b/Assets/Scripts/UI/DamageText.cs @@ -6,11 +6,24 @@ using TMPro; public class DamageText : MonoBehaviour { [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) { - 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(); } }