-
Notifications
You must be signed in to change notification settings - Fork 0
/
TerrainInfo.pde
153 lines (124 loc) · 2.95 KB
/
TerrainInfo.pde
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
final int SEASON_WINTER = 1;
final int SEASON_SPRING = 2;
final int SEASON_SUMMER = 3;
final int SEASON_FALL = 4;
class TerrainInfo {
int size;
int getSize() {
return size;
}
int[][] heightMap;
int[][] getHeightMap() {
return heightMap;
}
void setHeightMap(int[][] heightMap) {
this.heightMap = heightMap;
}
Climate climate;
Climate getClimate() {
return climate;
}
void setClimate(Climate c) {
climate = c;
}
int waterLevel;
int getWaterLevel() {
return waterLevel;
}
void setWaterLevel(int level) {
waterLevel = level;
}
boolean[][][] dirt;
boolean[] getDirt(int x, int y) {
return dirt[x][y];
}
boolean[][][] getAllDirt() {
return dirt;
}
void setAllDirt(boolean[][][] value) {
dirt = value;
}
int[][] erosion;
int getErosion(int x, int y) {
return erosion[x][y];
}
int[][] getAllErosion() {
return erosion;
}
void setAllErosion(int[][] value) {
erosion = value;
}
Plant[][] plants;
Plant getPlant(int x, int y) {
return plants[x][y];
}
Plant[][] getAllPlants() {
return plants;
}
void setAllPlants(Plant[][] value) {
plants = value;
}
boolean hotDesertClimate() {
return grassProb() < 0.25 && climate.getTemperature() >= 24;
}
TerrainInfo(int size) {
this.size = size;
}
float grassProb() {
GrowingConditions plant = new GrowingConditions(1, 36, 0, 30, 4,
16, 2, 16, 4);
return plant.conditions(climate);
}
float treeProb() {
GrowingConditions plant = new GrowingConditions(0.03125, 32, 4, 20, 20,
16, 4, 10, 10);
return plant.conditions(climate);
}
float flowerProb() {
GrowingConditions plant = new GrowingConditions(1, 36, 0, 28, 8,
16, 2, 16, 6);
return plant.conditions(climate);
}
float cactusProb() {
GrowingConditions plant = new GrowingConditions(0.03125, 48, 28, 44, 36,
6, 0, 2, 2);
return plant.conditions(climate);
}
float bushProb() {
GrowingConditions plant = new GrowingConditions(1.0 / 128.0, 36, 0, 30, 4,
16, 2, 16, 4);
return plant.conditions(climate);
}
void printInfo() {
println("..:: TerrainInfo ::..");
climate.printClimate();
println("WaterLevel: " + waterLevel);
println("grassProb: " + grassProb());
println("bushProb: " + bushProb());
println("treeProb: " + treeProb());
println("flowerProb: " + flowerProb());
println("cactusProb: " + cactusProb());
if(hotDesertClimate()) {
println("Hot desert climate.");
}
}
}
class SeasonInfo {
int season;
int getSeason() {
return season;
}
Weather weather;
Weather getWeather() {
return weather;
}
SeasonInfo(TerrainInfo info, int season) {
this.season = season;
weather = new Weather(season, info.getClimate());
}
void printInfo() {
println("..:: SeaonInfo ::..");
weather.printWeather();
println("Season: " + season);
}
}