-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHexPiece.cs
48 lines (38 loc) · 939 Bytes
/
HexPiece.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HexPiece : MonoBehaviour
{
int q;
int r;
public enum PieceType
{
Scenery,
Occupant
}
PieceType type;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Set(int q, int r, PieceType type) {
SetPosition(q, r);
this.type = type;
}
public void SetPosition(int q, int r) {
this.q = q;
this.r = r;
transform.Translate(HexBoard.GetXYZ(q, r) - transform.localPosition, Space.Self);
}
public void Move(int dq, int dr)
{
q += dq;
r += dr;
//Todo: This should initiate or queue move animation rather than Translate.
transform.Translate(HexBoard.GetXYZ(dq, dr), Space.Self);
}
}