summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/AlphaBlink.cs
blob: 4813ba676bfebf05c606b122877c2091a5128e73 (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
using System;
using UnityEngine;

public class AlphaBlink : MonoBehaviour
{
	public float Period = 1f;

	public float Ratio = 0.5f;

	private SpriteRenderer rend;

	private MeshRenderer mesh;

	public FloatRange AlphaRange = new FloatRange(0.2f, 0.5f);

	public Color baseColor = Color.white;

	public void SetColor(Color c)
	{
		this.Start();
		this.baseColor = c;
		this.Update();
	}

	private void Start()
	{
		this.mesh = base.GetComponent<MeshRenderer>();
		this.rend = base.GetComponent<SpriteRenderer>();
	}

	public void Update()
	{
		float num = Time.time % this.Period / this.Period;
		num = (float)((num < this.Ratio) ? 1 : 0);
		if (this.rend)
		{
			this.rend.color = new Color(this.baseColor.r, this.baseColor.g, this.baseColor.b, this.AlphaRange.Lerp(num));
		}
		if (this.mesh)
		{
			this.mesh.material.SetColor("_Color", new Color(this.baseColor.r, this.baseColor.g, this.baseColor.b, this.AlphaRange.Lerp(num)));
		}
	}
}