Repository navigation
Expand file tree
/
Copy pathControl.java
More file actions
executable file
·136 lines (120 loc) · 4.73 KB
/
Copy pathControl.java
File metadata and controls
executable file
·136 lines (120 loc) · 4.73 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
package GameRule;
import javafx.scene.image.ImageView;
import javafx.scene.shape.Rectangle;
import java.io.FileNotFoundException;
/**
* Created by admin on 2016/12/30.
*/
public class Control {
public Control() {
}
//一般向上移动
public void turnUp(int[][] theTeam, int[][] numberOfAnimal, ImageView[][] animalImage, int i, int j, boolean player) {
theTeam[i - 1][j] = theTeam[i][j];
theTeam[i][j] = 0;
numberOfAnimal[i - 1][j] = numberOfAnimal[i][j];
numberOfAnimal[i][j] = 0;
animalImage[i - 1][j].setImage(animalImage[i][j].getImage());
animalImage[i][j].setImage(null);
}
//一般向下移动
public void turnDown(int[][] theTeam, int[][] numberOfAnimal, ImageView[][] animalImage, int i, int j, boolean player) {
theTeam[i + 1][j] = theTeam[i][j];
theTeam[i][j] = 0;
numberOfAnimal[i + 1][j] = numberOfAnimal[i][j];
numberOfAnimal[i][j] = 0;
animalImage[i + 1][j].setImage(animalImage[i][j].getImage());
animalImage[i][j].setImage(null);
}
//一般向左移动
public void turnLeft(int[][] theTeam, int[][] numberOfAnimal, ImageView[][] animalImage, int i, int j, boolean player) {
theTeam[i][j - 1] = theTeam[i][j];
theTeam[i][j] = 0;
numberOfAnimal[i][j - 1] = numberOfAnimal[i][j];
numberOfAnimal[i][j] = 0;
animalImage[i][j - 1].setImage(animalImage[i][j].getImage());
animalImage[i][j].setImage(null);
}
//一般向右移动
public void turnRight(int[][] theTeam, int[][] numberOfAnimal, ImageView[][] animalImage, int i, int j, boolean player) {
theTeam[i][j + 1] = theTeam[i][j];
theTeam[i][j] = 0;
numberOfAnimal[i][j + 1] = numberOfAnimal[i][j];
numberOfAnimal[i][j] = 0;
animalImage[i][j + 1].setImage(animalImage[i][j].getImage());
animalImage[i][j].setImage(null);
}
//狮虎向上跳河
public void jumpUp(int[][] theTeam, int[][] numberOfAnimal, ImageView[][] animalImage, int i, int j, boolean player) {
theTeam[i - 3][j] = theTeam[i][j];
theTeam[i][j] = 0;
numberOfAnimal[i - 3][j] = numberOfAnimal[i][j];
numberOfAnimal[i][j] = 0;
animalImage[i - 3][j].setImage(animalImage[i][j].getImage());
animalImage[i][j].setImage(null);
}
//狮虎向下跳河
public void jumpDowwn(int[][] theTeam, int[][] numberOfAnimal, ImageView[][] animalImage, int i, int j, boolean player) {
theTeam[i + 3][j] = theTeam[i][j];
theTeam[i][j] = 0;
numberOfAnimal[i + 3][j] = numberOfAnimal[i][j];
numberOfAnimal[i][j] = 0;
animalImage[i + 3][j].setImage(animalImage[i][j].getImage());
animalImage[i][j].setImage(null);
}
//狮虎向左跳河
public void jumpLeft(int[][] theTeam, int[][] numberOfAnimal, ImageView[][] animalImage, int i, int j, boolean player) {
theTeam[i][j - 4] = theTeam[i][j];
theTeam[i][j] = 0;
numberOfAnimal[i][j - 4] = numberOfAnimal[i][j];
numberOfAnimal[i][j] = 0;
animalImage[i][j - 4].setImage(animalImage[i][j].getImage());
animalImage[i][j].setImage(null);
}
// 狮虎向右跳河
public void jumpRight(int[][] theTeam, int[][] numberOfAnimal, ImageView[][] animalImage, int i, int j, boolean player) {
theTeam[i][j + 4] = theTeam[i][j];
theTeam[i][j] = 0;
numberOfAnimal[i][j + 4] = numberOfAnimal[i][j];
numberOfAnimal[i][j] = 0;
animalImage[i][j + 4].setImage(animalImage[i][j].getImage());
animalImage[i][j].setImage(null);
}
//改变界面上rectangles可否点击
public void setDisable(int[][] theTeam, boolean player, Rectangle[][] rectangles) {
if(player){
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 9; j++) {
if(theTeam[i][j] == -1)
rectangles[i][j].setDisable(true);
else
rectangles[i][j].setDisable(false);
}
}
}else {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 9; j++) {
if(theTeam[i][j] == 1)
rectangles[i][j].setDisable(true);
else
rectangles[i][j].setDisable(false);
}
}
}
}
//判断当前界面是否已点击一个动物
public boolean isClick(Rectangle[][] rectangle) {
int count = 0;
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 9; j++) {
if (rectangle[i][j].getOpacity() < 0.3) {
count++;
}
}
}
if (count == 63)
return false;
else
return true;
}
}