forked from GCSShatteredSpace/Week-2-Code-Reading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
weaponTile.cs
63 lines (51 loc) · 1.3 KB
/
weaponTile.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
using UnityEngine;
using System.Collections;
public class weaponTile : MonoBehaviour {
public Renderer rend;
public int itemIndex;
private bool chosen;
public Color mouseOver;
public Color chosenColor;
public Color normalColor;
public Color wunengColor; //wuneng=impotent in chinese :P
public bool valid;
public bool mouseOn;
public string weaponName;
public string description;
public weaponProperties stats;
public GameObject controller;
private menu mCtrl;
public GameObject statsCtrl;
public statsController dataBase;
void Start() {
rend = GetComponent<Renderer>();
controller = GameObject.Find ("GameController(Clone)");
mCtrl=this.gameObject.GetComponentInParent<menu>();
statsCtrl = GameObject.Find("gameData");
dataBase = statsCtrl.GetComponent<statsController> ();
rend.material.color = normalColor;
}
void OnMouseEnter() {
mouseOn = true;
}
void OnMouseDown() {
if (valid&&(mCtrl.current!=itemIndex)) {
mCtrl.current=itemIndex;
mCtrl.changeSelection();
}
}
void OnMouseExit() {
mouseOn = false;
}
void Update(){
if (!valid) {
rend.material.color = wunengColor;
}else if(mCtrl.current==itemIndex){
rend.material.color = chosenColor;
}else if(mouseOn){
rend.material.color = mouseOver;
}else{
rend.material.color = normalColor;
}
}
}