diff options
Diffstat (limited to 'Client/Assembly-CSharp/KillButtonManager.cs')
-rw-r--r-- | Client/Assembly-CSharp/KillButtonManager.cs | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/KillButtonManager.cs b/Client/Assembly-CSharp/KillButtonManager.cs new file mode 100644 index 0000000..6c43b4f --- /dev/null +++ b/Client/Assembly-CSharp/KillButtonManager.cs @@ -0,0 +1,69 @@ +using System; +using UnityEngine; + +public class KillButtonManager : MonoBehaviour +{ + public PlayerControl CurrentTarget; + + public SpriteRenderer renderer; + + public TextRenderer TimerText; + + public bool isCoolingDown = true; + + public bool isActive; + + private Vector2 uv; + + public void Start() + { + this.renderer.SetCooldownNormalizedUvs(); + this.SetTarget(null); + } + + public void PerformKill() + { + if (base.isActiveAndEnabled && this.CurrentTarget && !this.isCoolingDown && !PlayerControl.LocalPlayer.Data.IsDead && PlayerControl.LocalPlayer.CanMove) + { + PlayerControl.LocalPlayer.RpcMurderPlayer(this.CurrentTarget); + this.SetTarget(null); + } + } + + public void SetTarget(PlayerControl target) + { + if (this.CurrentTarget && this.CurrentTarget != target) + { + this.CurrentTarget.GetComponent<SpriteRenderer>().material.SetFloat("_Outline", 0f); + } + this.CurrentTarget = target; + if (this.CurrentTarget) + { + SpriteRenderer component = this.CurrentTarget.GetComponent<SpriteRenderer>(); + component.material.SetFloat("_Outline", (float)(this.isActive ? 1 : 0)); + component.material.SetColor("_OutlineColor", Color.red); + this.renderer.color = Palette.EnabledColor; + this.renderer.material.SetFloat("_Desat", 0f); + return; + } + this.renderer.color = Palette.DisabledColor; + this.renderer.material.SetFloat("_Desat", 1f); + } + + public void SetCoolDown(float timer, float maxTimer) + { + float num = Mathf.Clamp(timer / maxTimer, 0f, 1f); + if (this.renderer) + { + this.renderer.material.SetFloat("_Percent", num); + } + this.isCoolingDown = (num > 0f); + if (this.isCoolingDown) + { + this.TimerText.Text = Mathf.CeilToInt(timer).ToString(); + this.TimerText.gameObject.SetActive(true); + return; + } + this.TimerText.gameObject.SetActive(false); + } +} |