From 537ca96e30a3e0a3a1d1f8b99cf75be3b6f31a04 Mon Sep 17 00:00:00 2001 From: rudderbucky Date: Sun, 21 Jun 2020 14:17:37 -0700 Subject: [PATCH] Lerp color fix --- Assets/Scripts/Abilities/Stealth.cs | 2 +- Assets/Scripts/Game Object Definitions/ShellPart.cs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Abilities/Stealth.cs b/Assets/Scripts/Abilities/Stealth.cs index fa5220dd9..edef9045d 100644 --- a/Assets/Scripts/Abilities/Stealth.cs +++ b/Assets/Scripts/Abilities/Stealth.cs @@ -64,7 +64,7 @@ protected override void Execute() isActive = true; // set to active isOnCD = true; // set to on cooldown ToggleIndicator(true); - + SpriteRenderer[] renderers = craft.GetComponentsInChildren(true); for (int i = 0; i < renderers.Length; i++) { diff --git a/Assets/Scripts/Game Object Definitions/ShellPart.cs b/Assets/Scripts/Game Object Definitions/ShellPart.cs index 6ec562142..d4987ec5b 100644 --- a/Assets/Scripts/Game Object Definitions/ShellPart.cs +++ b/Assets/Scripts/Game Object Definitions/ShellPart.cs @@ -275,7 +275,8 @@ private IEnumerator InitColorLerp(float lerpVal) lerpVal += 0.05F; lerpVal = Mathf.Min(lerpVal, 1); var lerpedColor = Color.Lerp(Color.gray, info.shiny ? ShinyFactionColors.colors[faction] : FactionColors.colors[faction], lerpVal); - + lerpedColor.a = (craft.invisible ? (craft.faction == 0 ? 0.2f: 0f) : 1f); + spriteRenderer.color = lerpedColor; if(shooter) shooter.GetComponent().color = lerpedColor; @@ -298,8 +299,10 @@ public void TakeDamage(float damage) { if(partHealth != 0 && colorLerped) { - spriteRenderer.color = Color.Lerp(Color.gray, info.shiny ? ShinyFactionColors.colors[faction] : + var color = Color.Lerp(Color.gray, info.shiny ? ShinyFactionColors.colors[faction] : FactionColors.colors[faction], currentHealth / partHealth); + color.a = (craft.invisible ? (craft.faction == 0 ? 0.2f: 0f) : 1f); + spriteRenderer.color = color; if(shooter) shooter.GetComponent().color = spriteRenderer.color; } }