-
Notifications
You must be signed in to change notification settings - Fork 96
/
SCAN_ResourceOverlay.cs
77 lines (63 loc) · 1.61 KB
/
SCAN_ResourceOverlay.cs
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
#region license
/*
* [Scientific Committee on Advanced Navigation]
* S.C.A.N. Satellite
*
* SCAN_ResourceOverlay - Script for controlling each resource toggle for the planetary overlay window
*
* Copyright (c)2014 David Grandy <david.grandy@gmail.com>;
* Copyright (c)2014 technogeeky <technogeeky@gmail.com>;
* Copyright (c)2014 (Your Name Here) <your email here>; see LICENSE.txt for licensing details.
*/
#endregion
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace SCANsat.Unity.Unity
{
public class SCAN_ResourceOverlay : MonoBehaviour
{
[SerializeField]
private TextHandler m_ResourceName = null;
private SCAN_Overlay parent;
private string resource;
private bool active;
public string Resource
{
get { return resource; }
}
public void SetResource(string name, SCAN_Overlay p, bool isOn)
{
if (p == null)
return;
parent = p;
resource = name;
if (m_ResourceName != null)
m_ResourceName.OnTextUpdate.Invoke(name);
if (isOn && p.OverlayInterface.DrawResource)
{
m_ResourceName.OnColorUpdate.Invoke(p.ActiveColor);
m_ResourceName.SetNormalColor(p.ActiveColor);
}
}
public void DrawResource()
{
if (parent == null)
return;
active = !active;
parent.SetResource(resource, active);
if (m_ResourceName != null)
m_ResourceName.SetNormalColor(parent.ActiveColor);
}
public void Inactivate()
{
active = false;
if (m_ResourceName != null)
{
m_ResourceName.OnColorUpdate.Invoke(parent.NormalColor);
m_ResourceName.SetNormalColor(parent.NormalColor);
}
}
}
}