-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMajorAbilityScript.cs
46 lines (45 loc) · 1.41 KB
/
MajorAbilityScript.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
using UnityEngine;
public class MajorAbilityScript : MonoBehaviour {
bool unlocked;
public Material unlockedMaterial;
// Color of skill when unlocked
public int cost;
public GameObject[] minorAbilities;
// Array of minor abilities that are connected to this ability
public LineRenderer lineObj;
// The lineobject that will be drawn between skills
private LineRenderer[] Lines;
// Array of prefabs that are GameObjects with a Line Renderer
private void Start()
{
Lines = new LineRenderer[minorAbilities.Length];
drawToMinorAbilites();
}
void drawToMinorAbilites()
{
for(int i = 0; i < minorAbilities.Length; i++)
{
Lines[i] = Instantiate(lineObj);
Lines[i].transform.SetParent(transform);
Lines[i].SetPosition(0, transform.position);
Lines[i].SetPosition(1, minorAbilities[i].transform.position);
Lines[i].startWidth = 0.05f;
}
}
private void OnMouseDown()
{
ValueScript val = gameObject.GetComponentInParent(typeof(ValueScript)) as ValueScript;
int amount = val.getValue();
if(amount >= cost)
{
amount -= cost;
abilityUnlocked();
}
val.setValue(amount);
}
private void abilityUnlocked()
{
unlocked = true;
GetComponent<Renderer>().material = unlockedMaterial;
}
}