-
Notifications
You must be signed in to change notification settings - Fork 0
/
King.cs
44 lines (38 loc) · 924 Bytes
/
King.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
using UnityEngine;
using System.Collections;
public class King : ChessPiece {
// Update is called once per frame
void Update () {
}
/**
* Set piece to move to specified square
* TODO: make it an arc instead of teleport
*/
override public void moveToDest(Square s) {
tile.Occupant = null;
s.Occupant = this;
this.tile = s;
((Transform)this.GetComponent (typeof(Transform))).localPosition = s.Position;
}
/**
* Start a recursive search for all possible moves
*/
override public void populateLists() {
for (int i = (int)Square.dir.up; i<=(int)Square.dir.ul; i++) {
Square s = tile.adjacent[i];
if(s != null) {
ChessPiece p = s.Occupant;
if(p!=null) attack.Add(s);
else move.Add(s);
}
}
}
/**
* Gracefully remove piece from board
* TODO: fade out, possible scorekeeping
*/
override public void removePiece() {
tile.Occupant = null;
Destroy (this);
}
}