blob: 479c1d34babf922bc28dbdb62a1acda101ef10d9 (
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
using UnityEngine;
using UnityEngine.Events;
public class SetTeamColor : MonoBehaviour
{
public enum ColorType
{
Main,
Background,
Particle,
WinText
}
private SpriteRenderer m_spriteRenderer;
private ParticleSystem m_particleSystem;
private LineRenderer m_lineRenderer;
public UnityEvent SetColorEvent;
private MeshRenderer meshRend;
public ColorType colorType;
private void Awake()
{
m_spriteRenderer = GetComponent<SpriteRenderer>();
meshRend = GetComponent<MeshRenderer>();
m_lineRenderer = GetComponent<LineRenderer>();
}
public void Set(PlayerSkin teamColor)
{
Color color = teamColor.color;
if (colorType == ColorType.Background)
{
color = teamColor.backgroundColor;
}
if (colorType == ColorType.Particle)
{
color = teamColor.particleEffect;
}
if (colorType == ColorType.WinText)
{
color = teamColor.winText;
}
if ((bool)m_lineRenderer)
{
m_lineRenderer.startColor = color;
m_lineRenderer.endColor = color;
}
else if ((bool)m_spriteRenderer)
{
m_spriteRenderer.color = color;
}
else if ((bool)meshRend)
{
meshRend.material.color = color;
}
else
{
m_particleSystem = GetComponent<ParticleSystem>();
if ((bool)m_particleSystem)
{
ParticleSystem.MainModule main = m_particleSystem.main;
main.startColor = color;
}
}
SetColorEvent.Invoke();
}
public static void TeamColorThis(GameObject go, PlayerSkin teamColor)
{
if (!(teamColor == null))
{
SetTeamColor[] componentsInChildren = go.GetComponentsInChildren<SetTeamColor>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].Set(teamColor);
}
}
}
}
|