summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/KillButtonManager.cs
blob: 6c43b4fd321ea86720380740e3ddbe90269a4c81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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);
	}
}