-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTileScript.cs
More file actions
178 lines (144 loc) · 3.92 KB
/
TileScript.cs
File metadata and controls
178 lines (144 loc) · 3.92 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TileScript : MonoBehaviour {
bool faceup = false;
int xLoc = 0;
int yLoc = 0;
public Sprite back;
Sprite frontFace;
int cardID = 0;
string cardID_s = "000";
string cardName = "";
string attackText = "";
string bountyText = "";
string atrText = "";
/*
Atribute shortcuts:
000: Null
001: Beast
002: Slime
003: Humanoid
*/
string cardAtr_s = "000";
string attackCode;
string bountyCode;
DeckController ctrObject;
SpriteRenderer sprRenderer;
bool isVisible = true;
// Use this for initialization
void Start () {
//frontFace = Resources.Load("Sprites/TileImages/icon002", typeof(Sprite)) as Sprite;
sprRenderer = this.GetComponent<SpriteRenderer>();
ctrObject = GameObject.Find("Deck").GetComponent<DeckController>();
}
// Update is called once per frame
void Update () {
if (!isVisible) {
sprRenderer.enabled = false;
} else if (faceup){
sprRenderer.enabled = true;
sprRenderer.sprite = frontFace;
} else {
sprRenderer.enabled = true;
sprRenderer.sprite = back;
}
}
public void setLocation(int x, int y) {
xLoc = x;
yLoc = y;
}
public void flip() {
faceup = !faceup;
}
public void loadTiletoSlot(string newID, string atr, string newAttackCode, string newBountyCode,string newName,
string newAttackText,string newBountyText, Sprite newSprite) {
cardID = int.Parse(newID);
cardID_s = newID;
cardAtr_s = atr;
attackCode = newAttackCode;
bountyCode = newBountyCode;
frontFace = newSprite;
isVisible = true;
cardName = newName;
attackText = newAttackText;
bountyText = newBountyText;
switch (int.Parse(atr))
{
case 0:
atrText = "";
break;
case 1:
atrText = "Beast";
break;
case 2:
atrText = "Slime";
break;
case 3:
atrText = "Humanoid";
break;
case 4:
atrText = "Trap";
break;
case 5:
atrText = "Weapon";
break;
default:
atrText = "Error";
break;
}
}
private void OnMouseDown()
{
if (!faceup){
ctrObject.onOtherClick(cardID, xLoc, yLoc);
}
}
private void OnMouseOver()
{
if (faceup) {
ctrObject.onOtherMouseOver(cardName, attackText, bountyText, atrText);
}
}
//getters
public string getAttackCode() {
return attackCode;
}
public string getBountyCode() {
return bountyCode;
}
public string getAtr() {
return cardAtr_s;
}
public int getcardID() {
return cardID;
}
public string getCardID_S() {
return cardID_s;
}
public int getXLoc() {
return xLoc;
}
public int getYLoc() {
return yLoc;
}
public Sprite GetFrontFace() {
return frontFace;
}
public string getCardName() {
return cardName;
}
public string getAttackText() {
return attackText;
}
public string getBountyText() {
return bountyText;
}
//Hiding and revealing for animations.
public void hide() {
isVisible = false;
}
public void reveal() {
isVisible = true;
}
}