1 | using System; // Tämän tarpeellisuus pitäisi olla itsestäänselvyys |
---|
2 | using Jypeli; // Jypeli |
---|
3 | using Jypeli.ScreenObjects; // Jypeli.ScreenObjects |
---|
4 | using Jypeli.Assets; // Jypeli.Assets |
---|
5 | using System.Collections.Generic; // Jypelin tutoriaali |
---|
6 | using System.IO; // Streamreader vaatii tämän |
---|
7 | using System.Windows.Forms; // jotta voin näyttää msgboxeja |
---|
8 | using ALTKTechs; // Avaruuslaatikon moottorikomponentit |
---|
9 | using ALTKUnits; |
---|
10 | using ALTKCiv; |
---|
11 | using ALTKPromotions; |
---|
12 | using ALTKDiff; |
---|
13 | using ALTKAIBehaviour; |
---|
14 | using BaseRules; // Avaruuslaatikon sääntötiedosto, helpottaa modien tekemistä |
---|
15 | using System.Threading; // voin käyttää Thread.Sleepiä |
---|
16 | |
---|
17 | namespace ALTKTileEngine |
---|
18 | { |
---|
19 | public class Peli : Game |
---|
20 | { |
---|
21 | bool gamestarted = false; |
---|
22 | int currDiffLevel; // jotta tätä voidaan käyttää missä tahansa |
---|
23 | |
---|
24 | int[,] TerrainMap; // perusmaastokartta |
---|
25 | int[,] DTerrainMap; // erikoismaastokartta |
---|
26 | int[,] OwnershipMap; // ruudukon omistuskartta (kenen pelaajan hallinnassa on mikäkin ruutu) |
---|
27 | int[,] ShroudMap; // pelaajan näkymää pienentävä Shroudmap |
---|
28 | int[,] UnitMap; // yksikkökartta |
---|
29 | |
---|
30 | string Textpath; |
---|
31 | string OwnershipColorPath; |
---|
32 | |
---|
33 | int AmountofPlayers; // Ihmispelaajien määrä, tällä hetkellä peli tukee vain yhtä |
---|
34 | int TurnNumber; // vuoron numero |
---|
35 | int CurrProduction; // pelaajan tämänhetkinen tuotanto |
---|
36 | int PlayerAmount = 2; |
---|
37 | |
---|
38 | // !!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
39 | // Pitänee tehdä vielä yksi ALTKSUnit-namespace ALTKCoreen. |
---|
40 | // Tämä sisältäisi tiedot yksiköiden omistajasta, yksikön perusyksiköstä ym. sekä myös karttakoordinaatit |
---|
41 | // (karttakoordinaatit säilyttää myös UnitMap, josta on helppo tarkastaa esim. liikuttaessa yksiköitä, onko ruudussa jo esim. vihollisyksiköitä. |
---|
42 | |
---|
43 | int SelectedUnit = -1; |
---|
44 | |
---|
45 | bool UnitsSelected = new bool(); |
---|
46 | |
---|
47 | TextDisplay TileDisp; |
---|
48 | TextDisplay UnitStatsDisp; |
---|
49 | TextDisplay ProductionDisp; |
---|
50 | TextDisplay BuildCityDisp; |
---|
51 | TextDisplay BuildUnitsDisp; |
---|
52 | TextDisplay Unit1Disp; |
---|
53 | TextDisplay Unit2Disp; |
---|
54 | TextDisplay Unit3Disp; |
---|
55 | TextDisplay Unit4Disp; |
---|
56 | TextDisplay ResearchDisp; |
---|
57 | TextDisplay ResearchableTech1; |
---|
58 | TextDisplay ResearchableTech2; |
---|
59 | TextDisplay ResearchableTech3; |
---|
60 | TextDisplay ClicktoResearch; |
---|
61 | |
---|
62 | int kartanLeveys; |
---|
63 | int kartanKorkeus; |
---|
64 | |
---|
65 | int CurrentPlayer; |
---|
66 | |
---|
67 | bool CityPlaceSelection; |
---|
68 | bool TileClickAllowed = false; |
---|
69 | |
---|
70 | bool UnitBuildingMode = false; |
---|
71 | bool UnitPositioningMode = false; |
---|
72 | int currentunit = new int(); |
---|
73 | |
---|
74 | // perusmaastotyypit |
---|
75 | const int Aavikko = 2, Tundra = 3, Vuoristo = 1, Lehtimetsa = 0; |
---|
76 | |
---|
77 | // erikoismaastotyypit |
---|
78 | const int Havumetsa = 2, Tyhja = 0, Kuusimetsa = 3; |
---|
79 | |
---|
80 | // Pelissä on viisi eri tasoa, toisella perusmaasto ja toisella tarkempaa tietoa (esim. onko ruutu metsää ym.) |
---|
81 | // Kolmas taso kertoo, kenen valtion hallinnassa ruutu on, neljäs on Fog of War, ja viides piirtää yksiköt. |
---|
82 | GameObject[,] tile; |
---|
83 | GameObject[,] DTile; |
---|
84 | GameObject[,] TileOwnership; |
---|
85 | GameObject[,] ShroudTile; |
---|
86 | GameObject[,] UnitTile; |
---|
87 | //Vector tileVector; |
---|
88 | |
---|
89 | Vector CamSpeedEast = new Vector(20.0, .0); |
---|
90 | Vector CamSpeedWest = new Vector(-20.0, .0); |
---|
91 | Vector CamSpeedNorth = new Vector(.0, 20.0); |
---|
92 | Vector CamSpeedSouth = new Vector(.0, -20.0); |
---|
93 | |
---|
94 | // Käytän ennemmin enemmän muistia kuin prosessoria, joten lasken nämä jo täällä |
---|
95 | int MouseScreenWidth; |
---|
96 | int MouseScreenHeight; |
---|
97 | int NegMouseScreenWidth; |
---|
98 | int NegMouseScreenHeight; |
---|
99 | # region Aloitusruutuvalikko |
---|
100 | protected override void Begin() |
---|
101 | { |
---|
102 | //SetWindowSize(true); |
---|
103 | Textpath = Application.StartupPath + "\\Content\\Textures\\"; |
---|
104 | OwnershipColorPath = Textpath + "Ownership\\"; |
---|
105 | InitRules(); |
---|
106 | InitStartMenu(); |
---|
107 | //InitControls(); |
---|
108 | //InitMap(); |
---|
109 | } |
---|
110 | void InitStartMenu() |
---|
111 | { |
---|
112 | Level.BackgroundColor = Color.Gray; |
---|
113 | Mouse.Enabled = true; |
---|
114 | Mouse.IsCursorVisible = true; |
---|
115 | |
---|
116 | InputQueryWindow input = new InputQueryWindow(); |
---|
117 | input.InputConfirmed += Player_SetName; |
---|
118 | input.QueryText.Text = "Kirjoita valtiosi nimi:"; |
---|
119 | input.Size = new Vector(300.0, 100.0); |
---|
120 | input.Position = new Vector(-250.0, 350.0); |
---|
121 | input.InputBox.BorderColor = Color.GreenYellow; |
---|
122 | ShowWindow(input); |
---|
123 | |
---|
124 | GameObject TrainingButton = new GameObject(250, 30, Shapes.Rectangle); |
---|
125 | GameObject EasyButton = new GameObject(250, 30, Shapes.Rectangle); |
---|
126 | GameObject NormalButton = new GameObject(250, 30, Shapes.Rectangle); |
---|
127 | GameObject HardButton = new GameObject(250, 30, Shapes.Rectangle); |
---|
128 | GameObject VHardButton = new GameObject(250, 30, Shapes.Rectangle); |
---|
129 | GameObject NightmareButton = new GameObject(250, 30, Shapes.Rectangle); |
---|
130 | GameObject InsanityButton = new GameObject(250, 30, Shapes.Rectangle); |
---|
131 | |
---|
132 | for (int a = 0; a <= 6; a++) |
---|
133 | { |
---|
134 | if (a == 0) { SetDiffButton(TrainingButton, 0); } |
---|
135 | if (a == 1) { SetDiffButton(EasyButton, 1); } |
---|
136 | if (a == 2) { SetDiffButton(NormalButton, 2); } |
---|
137 | if (a == 3) { SetDiffButton(HardButton, 3); } |
---|
138 | if (a == 4) { SetDiffButton(VHardButton, 4); } |
---|
139 | if (a == 5) { SetDiffButton(NightmareButton, 5); } |
---|
140 | if (a == 6) { SetDiffButton(InsanityButton, 6); } |
---|
141 | } |
---|
142 | Mouse.ListenOn(TrainingButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 0); |
---|
143 | Mouse.ListenOn(EasyButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 1); |
---|
144 | Mouse.ListenOn(NormalButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 2); |
---|
145 | Mouse.ListenOn(HardButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 3); |
---|
146 | Mouse.ListenOn(VHardButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 4); |
---|
147 | Mouse.ListenOn(NightmareButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 5); |
---|
148 | Mouse.ListenOn(InsanityButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 6); |
---|
149 | } |
---|
150 | |
---|
151 | void Player_SetName(InputQueryWindow sender, string input) |
---|
152 | { |
---|
153 | Rules.pCivs[0].Name = input; |
---|
154 | Rules.pCivs[0].HumanPlayer = true; |
---|
155 | Rules.pCivs[0].Enabled = true; |
---|
156 | Rules.pCivs[0].Color = "red"; |
---|
157 | } |
---|
158 | |
---|
159 | void SetDiffButton(GameObject diffbutton, int difflevel) |
---|
160 | { |
---|
161 | diffbutton.X = 250; |
---|
162 | diffbutton.Y = ((difflevel * -50) + 300); |
---|
163 | if (difflevel == 0) { diffbutton.Image = LoadImage(Textpath + "training"); } |
---|
164 | else if (difflevel == 1) { diffbutton.Image = LoadImage(Textpath + "easy"); } |
---|
165 | else if (difflevel == 2) { diffbutton.Image = LoadImage(Textpath + "normal"); } |
---|
166 | else if (difflevel == 3) { diffbutton.Image = LoadImage(Textpath + "hard"); } |
---|
167 | else if (difflevel == 4) { diffbutton.Image = LoadImage(Textpath + "vhard"); } |
---|
168 | else if (difflevel == 5) { diffbutton.Image = LoadImage(Textpath + "nightmare"); } |
---|
169 | else if (difflevel == 6) { diffbutton.Image = LoadImage(Textpath + "insanity"); } |
---|
170 | Add(diffbutton); |
---|
171 | //return diffbutton; |
---|
172 | } |
---|
173 | |
---|
174 | void SelectDifficulty(int difflevel) |
---|
175 | { |
---|
176 | ClearAll(); |
---|
177 | currDiffLevel = new int(); |
---|
178 | currDiffLevel = difflevel; |
---|
179 | InitControls(); |
---|
180 | InitMap(); |
---|
181 | gamestarted = true; |
---|
182 | } |
---|
183 | # endregion |
---|
184 | # region Kartan luominen |
---|
185 | |
---|
186 | void InitMap() |
---|
187 | { |
---|
188 | TurnNumber = new int(); |
---|
189 | AmountofPlayers = new int(); |
---|
190 | Int32 i; |
---|
191 | Int32 j; |
---|
192 | string mLine; |
---|
193 | TextReader bReader; |
---|
194 | bReader = new StreamReader("Content\\Maps\\1\\base.txt"); |
---|
195 | //try |
---|
196 | //{ |
---|
197 | |
---|
198 | // Yleensä kartan kaksi ensimmäistä riviä ovat kommentteja |
---|
199 | bReader.ReadLine(); |
---|
200 | bReader.ReadLine(); |
---|
201 | |
---|
202 | kartanLeveys = Convert.ToInt32(bReader.ReadLine().Substring(9, 2)); |
---|
203 | kartanKorkeus = Convert.ToInt32(bReader.ReadLine().Substring(10, 2)); |
---|
204 | |
---|
205 | Int32 mapWidthJ = (kartanLeveys * 48) / 2; |
---|
206 | Int32 mapHeightJ = (kartanKorkeus * 48) / 2; |
---|
207 | |
---|
208 | bReader.ReadLine(); |
---|
209 | // Ladataan TerrainMapit muistiin myöhempää käyttöä varten |
---|
210 | |
---|
211 | TerrainMap = new int[kartanKorkeus, kartanLeveys]; |
---|
212 | DTerrainMap = new int[kartanKorkeus, kartanLeveys]; |
---|
213 | OwnershipMap = new int[kartanKorkeus, kartanLeveys]; |
---|
214 | ShroudMap = new int[kartanKorkeus, kartanLeveys]; |
---|
215 | UnitMap = new int[kartanKorkeus, kartanLeveys]; |
---|
216 | InitTerrain(0); |
---|
217 | InitTerrain(1); |
---|
218 | InitTerrain(2); |
---|
219 | InitTerrain(3); |
---|
220 | InitTerrain(4); |
---|
221 | |
---|
222 | tile = new GameObject[kartanKorkeus, kartanLeveys]; |
---|
223 | DTile = new GameObject[kartanKorkeus, kartanLeveys]; |
---|
224 | TileOwnership = new GameObject[kartanKorkeus, kartanLeveys]; |
---|
225 | ShroudTile = new GameObject[kartanKorkeus, kartanLeveys]; |
---|
226 | UnitTile = new GameObject[kartanKorkeus, kartanLeveys]; |
---|
227 | InitTerrainGraphics(0); |
---|
228 | InitTerrainGraphics(1); |
---|
229 | InitTerrainGraphics(2); |
---|
230 | InitTerrainGraphics(3); |
---|
231 | InitTerrainGraphics(4); |
---|
232 | |
---|
233 | for (i = 0; i <= (kartanKorkeus - 1); i++) |
---|
234 | { |
---|
235 | for (j = 0; j <= (kartanLeveys - 1); j++) |
---|
236 | { |
---|
237 | UnitMap[i, j] = -1; |
---|
238 | } |
---|
239 | } |
---|
240 | |
---|
241 | // Initialisoidaan Unitmap |
---|
242 | |
---|
243 | for (i = 0; i <= (kartanKorkeus - 1); i++) |
---|
244 | { |
---|
245 | for (j = 0; j <= (kartanLeveys - 1); j++) |
---|
246 | { |
---|
247 | UnitTile[i, j].Shape = Shapes.Rectangle; |
---|
248 | UnitTile[i, j].X = (j * 48) - mapWidthJ; |
---|
249 | UnitTile[i, j].Y = (i * 48) - mapHeightJ; |
---|
250 | UnitTile[i, j].Image = LoadImage(Textpath + "nothing"); |
---|
251 | Add(UnitTile[i, j]); |
---|
252 | } |
---|
253 | } |
---|
254 | |
---|
255 | // Koodi käännetty RGE:n VB.netistä |
---|
256 | // Asettaa ja piirtää pohjamaaston |
---|
257 | |
---|
258 | for (i = 0; i <= (kartanKorkeus - 1); i++) |
---|
259 | { |
---|
260 | mLine = bReader.ReadLine(); |
---|
261 | for (j = 0; j <= (kartanLeveys - 1); j++) |
---|
262 | { |
---|
263 | // MessageBox.Show(mLine + " " + j + " " + i);s |
---|
264 | tile[i, j].Shape = Shapes.Rectangle; |
---|
265 | tile[i, j].X = (j * 48) - mapWidthJ; |
---|
266 | tile[i, j].Y = (i * 48) - mapHeightJ; |
---|
267 | TerrainMap[i, j] = getTerrainType(mLine.Substring(j, 1), 0, i, j); |
---|
268 | tile[i, j].Image = LoadImage(getTexture_fromTerrainType(TerrainMap[i, j], 0, i, j)); |
---|
269 | Add(tile[i, j]); |
---|
270 | Mouse.ListenOn(tile[i, j], MouseButton.Left, Jypeli.ButtonState.Released, TileClicked, "", i, j); |
---|
271 | //Mouse.ListenMovement(tile[i, j], showTileInfo_forTileDisp, null, i, j); |
---|
272 | // MessageBox.Show(Convert.ToString(TerrainMap[i, j])); |
---|
273 | } |
---|
274 | } |
---|
275 | |
---|
276 | // Luetaan karttatiedoston rivivälit |
---|
277 | bReader.ReadLine(); |
---|
278 | bReader.ReadLine(); |
---|
279 | |
---|
280 | // Rami 16. 6. 2010: Omistuskartta pitää sittenkin säätää ennen erikoismaastoa, sillä |
---|
281 | // kaupungit ja omistusrinki piirretään erikoismaaston asettamiskoodin kutsusta |
---|
282 | for (i = 0; i <= (kartanKorkeus - 1); i++) |
---|
283 | { |
---|
284 | for (j = 0; j <= (kartanLeveys - 1); j++) |
---|
285 | { |
---|
286 | // MessageBox.Show(mLine + " " + j + " " + i); |
---|
287 | OwnershipMap[i, j] = -1; |
---|
288 | TileOwnership[i, j].Shape = Shapes.Rectangle; |
---|
289 | TileOwnership[i, j].X = (j * 48) - mapWidthJ; |
---|
290 | TileOwnership[i, j].Y = (i * 48) - mapHeightJ; |
---|
291 | TileOwnership[i, j].Image = LoadImage(Textpath + "nothing"); |
---|
292 | Add(TileOwnership[i, j]); |
---|
293 | //MessageBox.Show(TileOwnership[i, j].X + "x" + TileOwnership[i, j].Y + " " + DTile[i, j].X + "x" + DTile[i, j].Y + " Params: " + i + " " + j); |
---|
294 | // MessageBox.Show(Convert.ToString(TerrainMap[i, j])); |
---|
295 | } |
---|
296 | } |
---|
297 | |
---|
298 | // Initialisoidaan Shroudmap |
---|
299 | |
---|
300 | for (i = 0; i <= (kartanKorkeus - 1); i++) |
---|
301 | { |
---|
302 | for (j = 0; j <= (kartanLeveys - 1); j++) |
---|
303 | { |
---|
304 | ShroudMap[i, j] = 1; |
---|
305 | ShroudTile[i, j].Shape = Shapes.Rectangle; |
---|
306 | ShroudTile[i, j].X = (j * 48) - mapWidthJ; |
---|
307 | ShroudTile[i, j].Y = (i * 48) - mapHeightJ; |
---|
308 | ShroudTile[i, j].Image = LoadImage(Textpath + "fogofwar"); |
---|
309 | } |
---|
310 | } |
---|
311 | |
---|
312 | |
---|
313 | // Asettaa ja piirtää erikoismaaston |
---|
314 | |
---|
315 | for (i = 0; i <= (kartanKorkeus - 1); i++) |
---|
316 | { |
---|
317 | mLine = bReader.ReadLine(); |
---|
318 | for (j = 0; j <= (kartanLeveys - 1); j++) |
---|
319 | { |
---|
320 | DTile[i, j].Shape = Shapes.Rectangle; |
---|
321 | DTile[i, j].X = (j * 48) - mapWidthJ; |
---|
322 | DTile[i, j].Y = (i * 48) - mapHeightJ; |
---|
323 | DTerrainMap[i, j] = getTerrainType(mLine.Substring(j, 1), 1, i, j); |
---|
324 | DTile[i, j].Image = LoadImage(getTexture_fromTerrainType(DTerrainMap[i, j], 1, i, j)); |
---|
325 | Add(DTile[i, j]); |
---|
326 | if (getTexture_fromTerrainType(DTerrainMap[i, j], 1, i, j).Contains("city")) |
---|
327 | { |
---|
328 | DrawOwnership(i, j); |
---|
329 | } |
---|
330 | } |
---|
331 | } |
---|
332 | |
---|
333 | // Piirretään ShroudTile vasta tässä, jotta se olisi DTilen päällä |
---|
334 | for (i = 0; i <= (kartanKorkeus - 1); i++) |
---|
335 | { |
---|
336 | for (j = 0; j <= (kartanLeveys - 1); j++) |
---|
337 | { |
---|
338 | if (ShroudMap[i, j] == 1) |
---|
339 | { |
---|
340 | Add(ShroudTile[i, j]); |
---|
341 | } |
---|
342 | } |
---|
343 | } |
---|
344 | |
---|
345 | //catch |
---|
346 | //{ |
---|
347 | // MessageBox.Show("Map error!"); |
---|
348 | // bReader.Close(); |
---|
349 | // Exit(); |
---|
350 | //} |
---|
351 | bReader.Close(); |
---|
352 | //for (int playernumber = 0; playernumber <= 30; playernumber++) |
---|
353 | //{ |
---|
354 | // Rules.pCivs[playernumber].Color = setAIOwnershipColor(playernumber); |
---|
355 | //} |
---|
356 | Level.BackgroundColor = Color.Black; |
---|
357 | InitGUI(); |
---|
358 | |
---|
359 | Application.DoEvents(); |
---|
360 | TurnSystem_Start(0); // Antaa pelin alkaa! |
---|
361 | } |
---|
362 | |
---|
363 | private void InitTerrain(int tlayer) |
---|
364 | { |
---|
365 | for (int a = 0; a <= (kartanKorkeus - 1); a++) |
---|
366 | { |
---|
367 | for (int b = 0; b <= (kartanLeveys - 1); b++) |
---|
368 | { |
---|
369 | GetTerrainLayer(tlayer)[a, b] = new int(); |
---|
370 | } |
---|
371 | } |
---|
372 | } |
---|
373 | |
---|
374 | int[,] GetTerrainLayer(int tlayer) |
---|
375 | { |
---|
376 | if (tlayer == 0) { return TerrainMap; } |
---|
377 | if (tlayer == 1) { return DTerrainMap; } |
---|
378 | if (tlayer == 2) { return OwnershipMap; } |
---|
379 | if (tlayer == 3) { return ShroudMap; } |
---|
380 | if (tlayer == 4) { return UnitMap; } |
---|
381 | return TerrainMap; |
---|
382 | } |
---|
383 | |
---|
384 | private void InitTerrainGraphics(int tlayer) |
---|
385 | { |
---|
386 | for (int a = 0; a <= (kartanKorkeus - 1); a++) |
---|
387 | { |
---|
388 | for (int b = 0; b <= (kartanLeveys - 1); b++) |
---|
389 | { |
---|
390 | GetGraphicsLayer(tlayer)[a, b] = new PhysicsObject(48.0, 48.0); |
---|
391 | } |
---|
392 | } |
---|
393 | } |
---|
394 | |
---|
395 | GameObject[,] GetGraphicsLayer(int tlayer) |
---|
396 | { |
---|
397 | if (tlayer == 0) {return tile; } |
---|
398 | if (tlayer == 1) {return DTile; } |
---|
399 | if (tlayer == 2) { return TileOwnership; } |
---|
400 | if (tlayer == 3) { return ShroudTile; } |
---|
401 | if (tlayer == 4) { return UnitTile; } |
---|
402 | return tile; |
---|
403 | } |
---|
404 | |
---|
405 | int getTerrainType(string ch, int terrainlayer, int i, int j) |
---|
406 | { |
---|
407 | if (terrainlayer == 0) |
---|
408 | { |
---|
409 | /*/ Maastotyypit |
---|
410 | * 0 = lehtimetsää |
---|
411 | * 1 = vuoristoa |
---|
412 | * 2 = aavikkoa |
---|
413 | * 3 = tundraa |
---|
414 | /*/ |
---|
415 | if (ch == " ") { return Lehtimetsa; } |
---|
416 | if (ch == "V") { return Vuoristo; } |
---|
417 | if (ch == "A") { return Aavikko; } |
---|
418 | if (ch == "T") { return Tundra; } |
---|
419 | } |
---|
420 | else if (terrainlayer == 1) |
---|
421 | { |
---|
422 | /*/ Erikoismaastotyypit |
---|
423 | * 0 = ei mitään |
---|
424 | * 1 = vuoristoa |
---|
425 | * 2 = metsää |
---|
426 | * 3 = kuusimetsää |
---|
427 | /*/ |
---|
428 | if (ch == " ") { return Tyhja; } |
---|
429 | if (ch == "M") { return Havumetsa; } |
---|
430 | if (ch == "V") { return Vuoristo; } |
---|
431 | if (ch == "K") { return Kuusimetsa; } |
---|
432 | try |
---|
433 | { |
---|
434 | //MessageBox.Show(TileOwnership[i, j].X + "x" + TileOwnership[i, j].Y + " " + DTile[i, j].X + "x" + DTile[i, j].Y + " Params: " + i + " " + j); |
---|
435 | int Playerstartloc; |
---|
436 | Playerstartloc = Convert.ToInt32(ch); |
---|
437 | AmountofPlayers = AmountofPlayers + 1; |
---|
438 | AddStartingCity(Playerstartloc, i, j); |
---|
439 | return (Playerstartloc + 10); |
---|
440 | } |
---|
441 | catch |
---|
442 | { |
---|
443 | } |
---|
444 | return Tyhja; |
---|
445 | } |
---|
446 | return 0; |
---|
447 | } |
---|
448 | |
---|
449 | private void TileClicked(int i, int j) |
---|
450 | { |
---|
451 | //MessageBox.Show(i + " " + j + Convert.ToString(CityPlaceSelection) + " " + Convert.ToString(UnitPositioningMode)); |
---|
452 | //if (TileClickAllowed == true) |
---|
453 | //{ |
---|
454 | if (CityPlaceSelection == true) |
---|
455 | { |
---|
456 | if (OwnershipMap[i, j] > -1 && OwnershipMap[i, j] != CurrentPlayer) |
---|
457 | { |
---|
458 | MessageDisplay.Add("Ruutu on vihollisen (" + Rules.pCivs[OwnershipMap[i, j]].Name + ") hallinnassa, etkä voi rakentaa siihen kaupunkia."); |
---|
459 | } |
---|
460 | else |
---|
461 | { |
---|
462 | if (DTerrainMap[i, j] == Vuoristo | DTerrainMap[i, j] > 9) |
---|
463 | { |
---|
464 | if (DTerrainMap[i, j] == Vuoristo) |
---|
465 | { |
---|
466 | MessageDisplay.Add("Et voi rakentaa kaupunkia vuorelle!"); |
---|
467 | } |
---|
468 | else |
---|
469 | { |
---|
470 | MessageDisplay.Add("Et voi rakentaa kaupunkia valmiin kaupungin päälle!"); |
---|
471 | } |
---|
472 | } |
---|
473 | else |
---|
474 | { |
---|
475 | bool cityAllowed = false; |
---|
476 | int b; |
---|
477 | int c; |
---|
478 | |
---|
479 | int d; |
---|
480 | int e; |
---|
481 | int f; |
---|
482 | for (int a = 0; a <= Rules.pCivs[CurrentPlayer].NumberofCities - 1; a++) |
---|
483 | { |
---|
484 | b = Rules.pCivs[CurrentPlayer].CityCoords[a, 0]; |
---|
485 | c = Rules.pCivs[CurrentPlayer].CityCoords[a, 1]; |
---|
486 | |
---|
487 | d = i - b; |
---|
488 | e = j - c; |
---|
489 | if (d == 2 | d == 1 | d == 0 | d == -1 | d == -2) |
---|
490 | { |
---|
491 | if (e == 2 | e == 1 | e == 0 | e == -1 | e == -2) |
---|
492 | { |
---|
493 | cityAllowed = true; |
---|
494 | } |
---|
495 | } |
---|
496 | } |
---|
497 | if (cityAllowed == true) |
---|
498 | { |
---|
499 | BuildCityDisp.TextColor = Color.Green; |
---|
500 | BuildCityDisp.X = BuildCityDisp.X + 20; |
---|
501 | Rules.pCivs[CurrentPlayer].BuiltFromCity = 0; |
---|
502 | Rules.pCivs[CurrentPlayer].Production = Rules.pCivs[CurrentPlayer].Production + 10; |
---|
503 | Rules.pCivs[CurrentPlayer].NumberofCities = Rules.pCivs[CurrentPlayer].NumberofCities + 1; |
---|
504 | Rules.pCivs[CurrentPlayer].CityCoords[Rules.pCivs[CurrentPlayer].NumberofCities - 1, 0] = i; |
---|
505 | Rules.pCivs[CurrentPlayer].CityCoords[Rules.pCivs[CurrentPlayer].NumberofCities - 1, 1] = j; |
---|
506 | BuildCityDisp.Text = "Rakenna kaupunki (B) (" + Rules.pCivs[CurrentPlayer].BuiltFromCity + " / " + Rules.pCivs[CurrentPlayer].Production + ")"; |
---|
507 | CityPlaceSelection = false; |
---|
508 | ChangeProductionDispText(); |
---|
509 | DTerrainMap[i, j] = CurrentPlayer + 10; |
---|
510 | DTile[i, j].Image = LoadImage(Textpath + "cityancient"); |
---|
511 | if (OwnershipMap[i, j] == -1) |
---|
512 | { |
---|
513 | OwnershipMap[i, j] = CurrentPlayer; |
---|
514 | DrawOwnership(i, j); |
---|
515 | CheckAndRemoveShroud_FromPos(i, j); |
---|
516 | } |
---|
517 | } |
---|
518 | else |
---|
519 | { |
---|
520 | MessageDisplay.Add("Valitsemasi sijainti on liian kaukana; Maksimietäisyys muista kaupungeista on 2 ruutua."); |
---|
521 | } |
---|
522 | } |
---|
523 | } |
---|
524 | } |
---|
525 | else if (UnitPositioningMode == true) |
---|
526 | { |
---|
527 | MessageBox.Show(Convert.ToString(UnitPositioningMode)); |
---|
528 | if (DTerrainMap[i, j] == CurrentPlayer + 10) |
---|
529 | { |
---|
530 | CreateUnit(i, j, BaseRules.Rules.getUnit_FromId(currentunit), CurrentPlayer); |
---|
531 | UnitPositioningMode = false; |
---|
532 | BuildUnitsClicked(); |
---|
533 | MessageDisplay.Add("Rakensit yksikön " + BaseRules.Rules.getUnit_FromId(currentunit).Name + " kohteeseen " + i + "; " + j + "."); |
---|
534 | currentunit = -1; |
---|
535 | } |
---|
536 | else |
---|
537 | { |
---|
538 | MessageDisplay.Add("Yksikkö täytyy rakentaa kaupunkiin."); |
---|
539 | } |
---|
540 | } |
---|
541 | else |
---|
542 | { |
---|
543 | if (OwnershipMap[i, j] == 0 && UnitMap[i, j] > -1) |
---|
544 | { |
---|
545 | UnitSelect(i, j); |
---|
546 | } |
---|
547 | } |
---|
548 | } |
---|
549 | //} |
---|
550 | |
---|
551 | private void UnitSelect(int i, int j) |
---|
552 | { |
---|
553 | //MessageBox.Show("UnitSelect: " + Convert.ToString(Rules.pCivs[CurrentPlayer].Units[GetUnit_FromPositionForSelection(i, j)].CurrentMovementPoints)); |
---|
554 | if (Rules.pCivs[CurrentPlayer].Units[GetUnit_FromPositionForSelection(i, j)].CurrentMovementPoints > 0) |
---|
555 | { |
---|
556 | MessageDisplay.Add("Valitsit yksikön " + Rules.pCivs[CurrentPlayer].Units[GetUnit_FromPositionForSelection(i, j)].UnitType.Name + " kohteesta " + Rules.pCivs[CurrentPlayer].Units[GetUnit_FromPositionForSelection(i, j)].PosY + "; " + Rules.pCivs[CurrentPlayer].Units[GetUnit_FromPositionForSelection(i, j)].PosX); |
---|
557 | MessageDisplay.Add("Liikuta valittua yksikköä Numpadista."); |
---|
558 | UnitStatsDisp.Text = "Valittu yksikkö:" + Environment.NewLine + Rules.pCivs[CurrentPlayer].Units[GetUnit_FromPositionForSelection(i, j)].UnitType.Name + |
---|
559 | Environment.NewLine + "-Voimakkuus: " + Rules.pCivs[CurrentPlayer].Units[GetUnit_FromPositionForSelection(i, j)].UnitType.Strength + Environment.NewLine + |
---|
560 | "-Liikkuvuus: " + Rules.pCivs[CurrentPlayer].Units[GetUnit_FromPositionForSelection(i, j)].UnitType.Movement + Environment.NewLine + |
---|
561 | Rules.pCivs[CurrentPlayer].Units[GetUnit_FromPositionForSelection(i, j)].UnitType.Description + Environment.NewLine + |
---|
562 | " HP: " + Rules.pCivs[CurrentPlayer].Units[GetUnit_FromPositionForSelection(i, j)].HP * 100 + "/100"; |
---|
563 | SelectedUnit = GetUnit_FromPositionForSelection(i, j); |
---|
564 | UnitTile[i, j].Image = LoadImage(OwnershipColorPath + "unitsOnTileSelected"); |
---|
565 | UnitsSelected = true; |
---|
566 | //Keyboard.Enable(Key.NumPad1); |
---|
567 | //Keyboard.Enable(Key.NumPad2); |
---|
568 | //Keyboard.Enable(Key.NumPad3); |
---|
569 | //Keyboard.Enable(Key.NumPad4); |
---|
570 | //Keyboard.Enable(Key.NumPad5); |
---|
571 | //Keyboard.Enable(Key.NumPad6); |
---|
572 | //Keyboard.Enable(Key.NumPad7); |
---|
573 | //Keyboard.Enable(Key.NumPad8); |
---|
574 | //Keyboard.Enable(Key.NumPad9); |
---|
575 | } |
---|
576 | } |
---|
577 | |
---|
578 | private void DrawOwnership(int i, int j) |
---|
579 | { |
---|
580 | if (ShroudMap[i, j] == 0) |
---|
581 | { |
---|
582 | TileOwnership[i, j].Image = LoadImage(OwnershipColorPath + Rules.pCivs[OwnershipMap[i, j]].Color); |
---|
583 | //if (TileOwnership[i, j].IsAddedToGame == false | TileOwnership[i, j]. == true) |
---|
584 | //{ |
---|
585 | //try |
---|
586 | //{ |
---|
587 | // Add(TileOwnership[i, j]); |
---|
588 | //} |
---|
589 | //catch |
---|
590 | //{ |
---|
591 | // //MessageDisplay.Add("TileOwnership not added at " + i + "; " + j + " ;; because of an exception."); |
---|
592 | //} |
---|
593 | //} |
---|
594 | } |
---|
595 | //MessageBox.Show(TileOwnership[i, j].X + "x" + TileOwnership[i, j].Y + " " + DTile[i, j].X + "x" + DTile[i, j].Y + " Params: " + i + " " + j); |
---|
596 | } |
---|
597 | |
---|
598 | //private void DrawUnit(int i, int j) |
---|
599 | //{ |
---|
600 | // if (UnitTile[i, j].IsAddedToGame == false) |
---|
601 | // { |
---|
602 | // Add(UnitTile[i, j]); |
---|
603 | // //Mouse.ListenOn(UnitTile[i, j], MouseButton.Left, Jypeli.ButtonState.Pressed, UnitSelect, "Valitse yksikkö painamalla ruutua", i, j); |
---|
604 | // } |
---|
605 | //} |
---|
606 | |
---|
607 | private void RemoveOwnership(int i, int j) |
---|
608 | { |
---|
609 | OwnershipMap[i, j] = -1; |
---|
610 | TileOwnership[i, j].Destroy(); |
---|
611 | } |
---|
612 | |
---|
613 | private void AddStartingCity(int playernumber, int i, int j) |
---|
614 | { |
---|
615 | //MessageBox.Show(TileOwnership[i, j].X + "x" + TileOwnership[i, j].Y + " " + DTile[i, j].X + "x" + DTile[i, j].Y + " Params: " + i + " " + j); |
---|
616 | Rules.pCivs[playernumber].Production = Rules.pCivs[playernumber].Production + 10; |
---|
617 | Rules.pCivs[playernumber].CityCoords[Rules.pCivs[playernumber].NumberofCities, 0] = i; |
---|
618 | Rules.pCivs[playernumber].CityCoords[Rules.pCivs[playernumber].NumberofCities, 1] = j; |
---|
619 | Rules.pCivs[playernumber].NumberofCities = Rules.pCivs[playernumber].NumberofCities + 1; |
---|
620 | //MessageBox.Show("AddStartingCity: " + i + " " + j + " Playernumber: " + playernumber + "CityCoords: " + Rules.pCivs[playernumber].CityCoords[0, 0] + " " + Rules.pCivs[playernumber].CityCoords[0, 1]); |
---|
621 | if (Rules.pCivs[playernumber].HumanPlayer == false) |
---|
622 | { |
---|
623 | Rules.pCivs[playernumber].Color = setAIOwnershipColor(playernumber); |
---|
624 | Rules.pCivs[playernumber].Enabled = true; |
---|
625 | Rules.pCivs[playernumber].Name = Rules.pCivs[playernumber].Color + " " + "Empire"; |
---|
626 | } |
---|
627 | else |
---|
628 | { |
---|
629 | CheckAndRemoveShroud_FromPos(i, j); |
---|
630 | } |
---|
631 | OwnershipMap[i, j] = playernumber; |
---|
632 | // 16. 6. 2010: Kutsutaanpa DrawOwnership sittenkin vasta kaupungin piirtämisen jälkeen (ks. InitMap ja DTilen asettaminen) |
---|
633 | //DrawOwnership(i, j); |
---|
634 | |
---|
635 | //DTile[i, j].Image = LoadImage("\\Content\\Textures\\cityancient"); |
---|
636 | } |
---|
637 | |
---|
638 | // Aliohjelma yksikön luomiseen |
---|
639 | private void CreateUnit(int i, int j, ALTKUnits.UnitClass unittype, int civnumber) |
---|
640 | { |
---|
641 | //MessageBox.Show(i + " " + j); |
---|
642 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits] = new BaseRules.Unit(); |
---|
643 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits].HP = 1.00; |
---|
644 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits].PosY = i; |
---|
645 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits].PosX = j; |
---|
646 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits].UnitType = unittype; |
---|
647 | Rules.pCivs[civnumber].NumberofUnits = Rules.pCivs[civnumber].NumberofUnits + 1; |
---|
648 | UnitMap[i, j] = civnumber; |
---|
649 | |
---|
650 | UnitTile[i, j].Image = LoadImage(OwnershipColorPath + "unitsOnTile"); |
---|
651 | |
---|
652 | if (OwnershipMap[i, j] == -1) |
---|
653 | { |
---|
654 | } |
---|
655 | else |
---|
656 | { |
---|
657 | OwnershipMap[i, j] = civnumber; |
---|
658 | DrawOwnership(i, j); |
---|
659 | } |
---|
660 | } |
---|
661 | |
---|
662 | public string GetUnits_FromPositionForView(int i, int j) |
---|
663 | { |
---|
664 | //MessageBox.Show("GetUnits..."); |
---|
665 | string units = ""; |
---|
666 | int civid; |
---|
667 | civid = OwnershipMap[i, j]; |
---|
668 | //int[] UnitAmount = new int[23]; |
---|
669 | //MessageBox.Show("GetUnits... Stage 0.5"); |
---|
670 | //for (int c = 0; c <= 23; c++) |
---|
671 | //{ |
---|
672 | //MessageBox.Show("GetUnits... Stage 0.8"); |
---|
673 | //UnitAmount[c] = new int(); |
---|
674 | //} |
---|
675 | //MessageBox.Show("GetUnits... Stage 1"); |
---|
676 | for (int a = 0; a <= Rules.pCivs[civid].NumberofUnits - 1; a++) |
---|
677 | { |
---|
678 | //MessageBox.Show("GetUnits... Stage 2"); |
---|
679 | if (Rules.pCivs[civid].Units[a].PosY == i && Rules.pCivs[civid].Units[a].PosX == j) // && (units.Contains(Rules.pCivs[civid].Units[a].UnitType.Name))) |
---|
680 | { |
---|
681 | //MessageBox.Show("ffff"); |
---|
682 | // UnitAmount[Rules.pCivs[civid].Units[a].UnitType.UnitId] = UnitAmount[Rules.pCivs[civid].Units[a].UnitType.UnitId] + 1; |
---|
683 | units = units + Rules.pCivs[civid].Units[a].UnitType.Name + "(" + BaseRules.Rules.GetUnitType_FromInt(Rules.pCivs[civid].Units[a].UnitType.UnitType) + BaseRules.Rules.GetMountedStatus_FromBool(Rules.pCivs[civid].Units[a].UnitType.Mounted) + ") HP: " + Rules.pCivs[civid].Units[a].HP * 100 + ";; " + Rules.pCivs[civid].Units[a].UnitType.Strength + " : " + |
---|
684 | Rules.pCivs[civid].Units[a].UnitType.Movement + " : " + Rules.pCivs[civid].Units[a].UnitType.Description + Environment.NewLine; |
---|
685 | //UnitAmount[Rules.pCivs[civid].Units[a].UnitType.UnitId] = Rules.pCivs[civid].Units[a].UnitType.UnitId + 1; |
---|
686 | } |
---|
687 | } |
---|
688 | return units; |
---|
689 | //} |
---|
690 | //return units; |
---|
691 | //MessageBox.Show(units); |
---|
692 | //MessageBox.Show("GetUnits... Stage 5"); |
---|
693 | //for (int b = 0; b <= 23; b++) |
---|
694 | //{ |
---|
695 | // if (UnitAmount[b] > 0) |
---|
696 | // { |
---|
697 | // // MessageBox.Show("GetUnits... Stage 6"); |
---|
698 | // if (UnitAmount[b] > 1) |
---|
699 | // { |
---|
700 | // //MessageBox.Show("GetUnits... Stage 7"); |
---|
701 | // units = units + BaseRules.Rules.getUnit_FromId(UnitAmount[b]).Name + " x" + UnitAmount[b] + Environment.NewLine; |
---|
702 | // return units; |
---|
703 | // } |
---|
704 | // else if (UnitAmount[b] == 1) |
---|
705 | // { |
---|
706 | // // MessageBox.Show("GetUnits... Stage 8"); |
---|
707 | // units = units + BaseRules.Rules.getUnit_FromId(UnitAmount[b]).Name + Environment.NewLine; |
---|
708 | // return units; |
---|
709 | // } |
---|
710 | // } |
---|
711 | //} |
---|
712 | //return units; |
---|
713 | // //MessageBox.Show("GetUnits... Stage 9"); |
---|
714 | |
---|
715 | // MessageBox.Show("GetUnits... Stage 10"); |
---|
716 | } |
---|
717 | |
---|
718 | public int GetUnit_FromPositionForSelection(int i, int j) |
---|
719 | { |
---|
720 | int civid; |
---|
721 | civid = OwnershipMap[i, j]; |
---|
722 | for (int a = 0; a <= Rules.pCivs[civid].NumberofUnits - 1; a++) |
---|
723 | { |
---|
724 | if (Rules.pCivs[civid].Units[a].PosY == i && Rules.pCivs[civid].Units[a].PosX == j) |
---|
725 | { |
---|
726 | return a; |
---|
727 | } |
---|
728 | } |
---|
729 | return -1; |
---|
730 | } |
---|
731 | |
---|
732 | public int GetUnit_FromPositionForRemoval(int i, int j, ALTKUnits.UnitClass unittype, double unitHP) |
---|
733 | { |
---|
734 | // MessageBox.Show("GetUnit_FromPosition: " + i + " " + j); |
---|
735 | int civid; |
---|
736 | civid = OwnershipMap[i, j]; |
---|
737 | for (int a = 0; a <= Rules.pCivs[civid].NumberofUnits - 1; a++) |
---|
738 | { |
---|
739 | if (Rules.pCivs[civid].Units[a].PosY == i && Rules.pCivs[civid].Units[a].PosX == j && Rules.pCivs[civid].Units[a].UnitType.Equals(unittype) && Rules.pCivs[civid].Units[a].HP == unitHP) |
---|
740 | { |
---|
741 | return a; |
---|
742 | } |
---|
743 | } |
---|
744 | return -1; |
---|
745 | } |
---|
746 | |
---|
747 | private void RemoveUnit(int i, int j, int civnumber, ALTKUnits.UnitClass unittype, double unitHP) |
---|
748 | { |
---|
749 | //MessageBox.Show(i + " " + j + " " + civnumber); |
---|
750 | int unitpos = GetUnit_FromPositionForRemoval(i, j, unittype, unitHP); |
---|
751 | if (unitpos > 0 && Rules.pCivs[civnumber].NumberofUnits > 2) |
---|
752 | { |
---|
753 | MessageBox.Show("FirstMethod"); |
---|
754 | for (int a = unitpos + 1; a <= Rules.pCivs[civnumber].NumberofUnits - 1; a++) |
---|
755 | { |
---|
756 | Rules.pCivs[civnumber].Units[a - 1].HP = Rules.pCivs[civnumber].Units[a].HP; |
---|
757 | Rules.pCivs[civnumber].Units[a - 1].PosY = Rules.pCivs[civnumber].Units[a].PosY; |
---|
758 | Rules.pCivs[civnumber].Units[a - 1].PosX = Rules.pCivs[civnumber].Units[a].PosX; |
---|
759 | Rules.pCivs[civnumber].Units[a - 1].UnitType = Rules.pCivs[civnumber].Units[a].UnitType; |
---|
760 | } |
---|
761 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosX = 0; |
---|
762 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosY = 0; |
---|
763 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].HP = 0.0; |
---|
764 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].UnitType = null; |
---|
765 | } |
---|
766 | else if (unitpos == 0 && Rules.pCivs[civnumber].NumberofUnits > 1) |
---|
767 | { |
---|
768 | MessageBox.Show("SecondMethod"); |
---|
769 | for (int a = 1; a <= Rules.pCivs[civnumber].NumberofUnits - 1; a++) |
---|
770 | { |
---|
771 | Rules.pCivs[civnumber].Units[a - 1].HP = Rules.pCivs[civnumber].Units[a].HP; |
---|
772 | Rules.pCivs[civnumber].Units[a - 1].PosY = Rules.pCivs[civnumber].Units[a].PosY; |
---|
773 | Rules.pCivs[civnumber].Units[a - 1].PosX = Rules.pCivs[civnumber].Units[a].PosX; |
---|
774 | Rules.pCivs[civnumber].Units[a - 1].UnitType = Rules.pCivs[civnumber].Units[a].UnitType; |
---|
775 | } |
---|
776 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosX = 0; |
---|
777 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosY = 0; |
---|
778 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].HP = 0.0; |
---|
779 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].UnitType = null; |
---|
780 | } |
---|
781 | else if (unitpos == 0 && Rules.pCivs[civnumber].NumberofUnits == 1) |
---|
782 | { |
---|
783 | MessageBox.Show("ThirdMethod"); |
---|
784 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosX = 0; |
---|
785 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosY = 0; |
---|
786 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].HP = 0.0; |
---|
787 | Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].UnitType = null; |
---|
788 | } |
---|
789 | Rules.pCivs[civnumber].NumberofUnits = Rules.pCivs[civnumber].NumberofUnits - 1; |
---|
790 | } |
---|
791 | |
---|
792 | public string setAIOwnershipColor(int playernumber) |
---|
793 | { |
---|
794 | int c; |
---|
795 | int b; |
---|
796 | bool ColorInUse = false; |
---|
797 | for (b = 0; b <= 20; b++) |
---|
798 | { |
---|
799 | ColorInUse = false; |
---|
800 | for (c = 0; c <= 30; c++) |
---|
801 | { |
---|
802 | if (Rules.pCivs[c].Color == getOwnershipColor_fromInt(b)) |
---|
803 | { |
---|
804 | ColorInUse = true; |
---|
805 | } |
---|
806 | } |
---|
807 | if (ColorInUse == false) |
---|
808 | { |
---|
809 | return getOwnershipColor_fromInt(b); |
---|
810 | } |
---|
811 | } |
---|
812 | return getOwnershipColor_fromInt(0); |
---|
813 | } |
---|
814 | |
---|
815 | public string getOwnershipColor_fromInt(Int32 color) |
---|
816 | { |
---|
817 | if (color == 0) { return "Aqua"; } |
---|
818 | if (color == 1) { return "Beige"; } |
---|
819 | if (color == 2) { return "Limegreen"; } |
---|
820 | if (color == 3) { return "Orange"; } |
---|
821 | if (color == 4) { return "Black"; } |
---|
822 | if (color == 5) { return "Red"; } |
---|
823 | if (color == 6) { return "Rustred"; } |
---|
824 | if (color == 7) { return "Yellow"; } |
---|
825 | if (color == 8) { return "Blue"; } |
---|
826 | if (color == 9) { return "Darkblue"; } |
---|
827 | if (color == 10) { return "Darkgreen"; } |
---|
828 | if (color == 11) { return "Lightblue"; } |
---|
829 | if (color == 12) { return "Purple"; } |
---|
830 | if (color == 13) { return "Darkpurple"; } |
---|
831 | if (color == 14) { return "Lightpurple"; } |
---|
832 | if (color == 15) { return "Gold"; } |
---|
833 | if (color == 16) { return "Silver"; } |
---|
834 | if (color == 17) { return "Pink"; } |
---|
835 | if (color == 18) { return "Teal"; } |
---|
836 | if (color == 19) { return "Greenyellow"; } |
---|
837 | if (color == 20) { return "Darkorange"; } |
---|
838 | if (color == 21) { return "White"; } |
---|
839 | if (color == 22) { return "Darkgray"; } |
---|
840 | return "Aqua"; |
---|
841 | } |
---|
842 | |
---|
843 | string getTexture_fromTerrainType(int terraintype, int terrainlayer, int i, int j) |
---|
844 | { |
---|
845 | if (terrainlayer == 0) |
---|
846 | { |
---|
847 | if (terraintype == Lehtimetsa) { return Application.StartupPath + "\\Content\\Textures\\grassland"; } |
---|
848 | if (terraintype == Vuoristo) { return Application.StartupPath + "\\Content\\Textures\\mountain"; } |
---|
849 | if (terraintype == Aavikko) { return Application.StartupPath + "\\Content\\Textures\\desert"; } |
---|
850 | if (terraintype == Tundra) { return Application.StartupPath + "\\Content\\Textures\\tundra"; } |
---|
851 | } |
---|
852 | else if (terrainlayer == 1) |
---|
853 | { |
---|
854 | if (terraintype == Tyhja) { return Application.StartupPath + "\\Content\\Textures\\nothing"; } |
---|
855 | if (terraintype == Vuoristo) { return Application.StartupPath + "\\Content\\Textures\\mountain"; } |
---|
856 | if (terraintype == Havumetsa) { return Application.StartupPath + "\\Content\\Textures\\forest"; } |
---|
857 | if (terraintype == Kuusimetsa) |
---|
858 | { |
---|
859 | if (TerrainMap[i, j] == 3) |
---|
860 | { |
---|
861 | return Application.StartupPath + "\\Content\\Textures\\spruceforestS"; |
---|
862 | } |
---|
863 | else |
---|
864 | { |
---|
865 | return Application.StartupPath + "\\Content\\Textures\\spruceforest"; |
---|
866 | } |
---|
867 | } |
---|
868 | // Jos terraintype on 10 tai enemmän, ruudussa on pelaajan kaupunki (ks. getTerrainType) |
---|
869 | if (terraintype >= 10) |
---|
870 | { |
---|
871 | if (TerrainMap[i, j] == Tundra) |
---|
872 | { |
---|
873 | return Application.StartupPath + "\\Content\\Textures\\cityancientTundra"; |
---|
874 | //DrawOwnership(i, j); |
---|
875 | } |
---|
876 | else |
---|
877 | { |
---|
878 | return Application.StartupPath + "\\Content\\Textures\\cityancient"; |
---|
879 | } |
---|
880 | } |
---|
881 | return Application.StartupPath + "\\Content\\Textures\\nothing"; |
---|
882 | } |
---|
883 | return Application.StartupPath + "\\Content\\Textures\\grassland.jpg"; |
---|
884 | } |
---|
885 | # endregion |
---|
886 | |
---|
887 | private void InitGUI() |
---|
888 | { |
---|
889 | TileDisp = new TextDisplay(); |
---|
890 | TileDisp.X = Screen.Left + 120; |
---|
891 | TileDisp.Y = Screen.Bottom + 200; |
---|
892 | TileDisp.TextColor = Color.White; |
---|
893 | |
---|
894 | UnitStatsDisp = new TextDisplay(); |
---|
895 | UnitStatsDisp.X = Screen.Left + 300; |
---|
896 | UnitStatsDisp.Y = Screen.Bottom + 400; |
---|
897 | UnitStatsDisp.Text = "d23"; |
---|
898 | UnitStatsDisp.TextColor = Color.DarkRed; |
---|
899 | |
---|
900 | ProductionDisp = new TextDisplay(); |
---|
901 | ProductionDisp.X = Screen.Right - 150; |
---|
902 | ProductionDisp.Y = Screen.Top - 50; |
---|
903 | ProductionDisp.Text = "Tuotanto: 10/120"; |
---|
904 | ProductionDisp.TextColor = Color.Wheat; |
---|
905 | |
---|
906 | BuildCityDisp = new TextDisplay(); |
---|
907 | BuildCityDisp.X = Screen.Right - 200; |
---|
908 | BuildCityDisp.Y = Screen.Top - 150; |
---|
909 | BuildCityDisp.TextColor = Color.Green; |
---|
910 | BuildCityDisp.Text = "Rakenna kaupunki"; |
---|
911 | |
---|
912 | //Mouse.ListenOn(BuildCityDisp, MouseButton.Left, Jypeli.ButtonState.Pressed, BuildCityClicked, "Rakenna kaupunki"); |
---|
913 | Keyboard.Listen(Key.B, Jypeli.ButtonState.Pressed, BuildCityClicked, "Rakenna kaupunki"); |
---|
914 | |
---|
915 | BuildUnitsDisp = new TextDisplay(); |
---|
916 | BuildUnitsDisp.X = Screen.Right - 120; |
---|
917 | BuildUnitsDisp.Y = Screen.Top - 200; |
---|
918 | BuildUnitsDisp.TextColor = Color.Green; |
---|
919 | BuildUnitsDisp.Text = "Rakenna yksiköitä (U)"; |
---|
920 | |
---|
921 | Keyboard.Listen(Key.U, Jypeli.ButtonState.Pressed, BuildUnitsClicked, "Näytä yksikkövalikko"); |
---|
922 | |
---|
923 | Unit1Disp = new TextDisplay(); |
---|
924 | Unit1Disp.X = Screen.Right - 150; |
---|
925 | Unit1Disp.Y = Screen.Top - 250; |
---|
926 | Unit1Disp.TextColor = Color.DarkGreen; |
---|
927 | Unit1Disp.Text = ""; |
---|
928 | |
---|
929 | Keyboard.Listen(Key.D1, Jypeli.ButtonState.Pressed, BuildUnit, "Rakenna 1. puun yksikkö", 1); |
---|
930 | |
---|
931 | Unit2Disp = new TextDisplay(); |
---|
932 | Unit2Disp.X = Screen.Right - 150; |
---|
933 | Unit2Disp.Y = Screen.Top - 300; |
---|
934 | Unit2Disp.TextColor = Color.DarkGreen; |
---|
935 | Unit2Disp.Text = ""; |
---|
936 | |
---|
937 | Keyboard.Listen(Key.D2, Jypeli.ButtonState.Pressed, BuildUnit, "Rakenna 2. puun yksikkö", 2); |
---|
938 | |
---|
939 | Unit3Disp = new TextDisplay(); |
---|
940 | Unit3Disp.X = Screen.Right - 150; |
---|
941 | Unit3Disp.Y = Screen.Top - 350; |
---|
942 | Unit3Disp.TextColor = Color.DarkGreen; |
---|
943 | Unit3Disp.Text = ""; |
---|
944 | |
---|
945 | Keyboard.Listen(Key.D3, Jypeli.ButtonState.Pressed, BuildUnit, "Rakenna 3. puun yksikkö", 3); |
---|
946 | |
---|
947 | Unit4Disp = new TextDisplay(); |
---|
948 | Unit4Disp.X = Screen.Right - 150; |
---|
949 | Unit4Disp.Y = Screen.Top - 400; |
---|
950 | Unit4Disp.TextColor = Color.DarkGreen; |
---|
951 | Unit4Disp.Text = ""; |
---|
952 | |
---|
953 | Keyboard.Listen(Key.D4, Jypeli.ButtonState.Pressed, BuildUnit, "Rakenna 4. puun yksikkö", 4); |
---|
954 | |
---|
955 | ResearchDisp = new TextDisplay(); |
---|
956 | ResearchDisp.X = Screen.Right - 200; |
---|
957 | ResearchDisp.Y = Screen.Top - 500; |
---|
958 | ResearchDisp.TextColor = Color.Green; |
---|
959 | ResearchDisp.Text = "Teknologia:" + Environment.NewLine + "Horseback Riding 199/200"; |
---|
960 | |
---|
961 | ResearchableTech1 = new TextDisplay(); |
---|
962 | ResearchableTech2 = new TextDisplay(); |
---|
963 | ResearchableTech3 = new TextDisplay(); |
---|
964 | |
---|
965 | ClicktoResearch = new TextDisplay(); |
---|
966 | ClicktoResearch.X = Screen.Right - 200; |
---|
967 | ClicktoResearch.Y = Screen.Top - 600; |
---|
968 | ClicktoResearch.TextColor = Color.Green; |
---|
969 | ClicktoResearch.Text = "Kehitä teknologiaa"; |
---|
970 | |
---|
971 | MessageDisplay.TextColor = Color.Orange; |
---|
972 | |
---|
973 | Add(TileDisp); |
---|
974 | Add(UnitStatsDisp); |
---|
975 | Add(ProductionDisp); |
---|
976 | Add(BuildCityDisp); |
---|
977 | Add(BuildUnitsDisp); |
---|
978 | Add(Unit1Disp); |
---|
979 | Add(Unit2Disp); |
---|
980 | Add(Unit3Disp); |
---|
981 | Add(Unit4Disp); |
---|
982 | //Add(ResearchDisp); |
---|
983 | //Add(ClicktoResearch); |
---|
984 | } |
---|
985 | |
---|
986 | private void BuildUnit(int unittree) |
---|
987 | { |
---|
988 | if (UnitBuildingMode == true) |
---|
989 | { |
---|
990 | int UnitCost = new int(); |
---|
991 | if (unittree == 1) |
---|
992 | { |
---|
993 | UnitCost = 20; |
---|
994 | } |
---|
995 | else if (unittree == 2) |
---|
996 | { |
---|
997 | UnitCost = 30; |
---|
998 | } |
---|
999 | else if (unittree == 3) |
---|
1000 | { |
---|
1001 | UnitCost = 30; |
---|
1002 | } |
---|
1003 | else if (unittree == 4) |
---|
1004 | { |
---|
1005 | UnitCost = 40; |
---|
1006 | } |
---|
1007 | |
---|
1008 | if (UnitCost > CurrProduction) |
---|
1009 | { |
---|
1010 | MessageDisplay.Add("Sinulla ei ole tarpeeksi tuotantoa yksikön rakentamiseen."); |
---|
1011 | } |
---|
1012 | else |
---|
1013 | { |
---|
1014 | CurrProduction = CurrProduction - UnitCost; |
---|
1015 | ChangeProductionDispText(); |
---|
1016 | MessageDisplay.Add("Rakensit yksikön " + GetBuildableUnit(unittree).Name + ". Valitse kaupunki, mihin yksikkö rakennetaan."); |
---|
1017 | currentunit = GetBuildableUnit(unittree).UnitId; |
---|
1018 | UnitPositioningMode = true; |
---|
1019 | } |
---|
1020 | } |
---|
1021 | else |
---|
1022 | { |
---|
1023 | MessageDisplay.Add("Et ole yksikönrakennustilassa."); |
---|
1024 | } |
---|
1025 | } |
---|
1026 | |
---|
1027 | private ALTKUnits.UnitClass GetBuildableUnit(int unittree) |
---|
1028 | { |
---|
1029 | if (unittree == 1) |
---|
1030 | { |
---|
1031 | return BaseRules.Rules.Warrior; |
---|
1032 | } |
---|
1033 | if (unittree == 2) |
---|
1034 | { |
---|
1035 | return BaseRules.Rules.Archer; |
---|
1036 | } |
---|
1037 | if (unittree == 3) |
---|
1038 | { |
---|
1039 | return BaseRules.Rules.Spearman; |
---|
1040 | } |
---|
1041 | if (unittree == 4) |
---|
1042 | { |
---|
1043 | return BaseRules.Rules.Horseman; |
---|
1044 | } |
---|
1045 | return BaseRules.Rules.Warrior; |
---|
1046 | } |
---|
1047 | |
---|
1048 | private void BuildUnitsClicked() |
---|
1049 | { |
---|
1050 | if (UnitPositioningMode == true) |
---|
1051 | { |
---|
1052 | MessageDisplay.Add("Määritä aikaisemmalle yksikölle rakennussijainti."); |
---|
1053 | } |
---|
1054 | |
---|
1055 | if (UnitBuildingMode == true) |
---|
1056 | { |
---|
1057 | Unit1Disp.Text = ""; |
---|
1058 | Unit2Disp.Text = ""; |
---|
1059 | Unit3Disp.Text = ""; |
---|
1060 | Unit4Disp.Text = ""; |
---|
1061 | UnitBuildingMode = false; |
---|
1062 | } |
---|
1063 | else |
---|
1064 | { |
---|
1065 | UnitBuildingMode = true; |
---|
1066 | |
---|
1067 | // Muutetaan tekstit |
---|
1068 | SetUnitDispText(1); |
---|
1069 | SetUnitDispText(2); |
---|
1070 | SetUnitDispText(3); |
---|
1071 | SetUnitDispText(4); |
---|
1072 | } |
---|
1073 | } |
---|
1074 | |
---|
1075 | private void SetUnitDispText(int unitdisp) |
---|
1076 | { |
---|
1077 | if (unitdisp == 1) |
---|
1078 | { |
---|
1079 | Unit1Disp.Text = "Rakenna " + BaseRules.Rules.getUnit_FromId(BaseRules.Rules.T1Units[0]).Name + " [1] (20)"; |
---|
1080 | } |
---|
1081 | else if (unitdisp == 2) |
---|
1082 | { |
---|
1083 | Unit2Disp.Text = "Rakenna " + BaseRules.Rules.getUnit_FromId(BaseRules.Rules.T2Units[0]).Name + " [2] (30)"; |
---|
1084 | } |
---|
1085 | else if (unitdisp == 3) |
---|
1086 | { |
---|
1087 | Unit3Disp.Text = "Rakenna " + BaseRules.Rules.getUnit_FromId(BaseRules.Rules.T3Units[0]).Name + " [3] (30)"; |
---|
1088 | } |
---|
1089 | else if (unitdisp == 4) |
---|
1090 | { |
---|
1091 | Unit4Disp.Text = "Rakenna " + BaseRules.Rules.getUnit_FromId(BaseRules.Rules.T4Units[0]).Name + " [4] (40)"; |
---|
1092 | } |
---|
1093 | } |
---|
1094 | |
---|
1095 | private void BuildCityClicked() |
---|
1096 | { |
---|
1097 | TileClickAllowed = false; |
---|
1098 | if (CityPlaceSelection == false) |
---|
1099 | { |
---|
1100 | Rules.pCivs[CurrentPlayer].BuiltFromCity = Rules.pCivs[CurrentPlayer].BuiltFromCity + CurrProduction; |
---|
1101 | CurrProduction = 0; |
---|
1102 | BuildCityDisp.Text = "Rakenna kaupunki (B) (" + Rules.pCivs[CurrentPlayer].BuiltFromCity + " / " + Rules.pCivs[CurrentPlayer].Production + ")"; |
---|
1103 | ChangeProductionDispText(); |
---|
1104 | if (Rules.pCivs[CurrentPlayer].BuiltFromCity > Rules.pCivs[CurrentPlayer].Production | Rules.pCivs[CurrentPlayer].BuiltFromCity == Rules.pCivs[CurrentPlayer].Production) |
---|
1105 | { |
---|
1106 | CurrProduction = Rules.pCivs[CurrentPlayer].BuiltFromCity - Rules.pCivs[CurrentPlayer].Production; |
---|
1107 | MessageDisplay.Add("Sait kaupungin valmiiksi; valitse uuden kaupungin sijainti."); |
---|
1108 | BuildCityDisp.Text = "Peruuta kaupungin rakentaminen (B) (" + Rules.pCivs[CurrentPlayer].Production / 2 + ")"; |
---|
1109 | BuildCityDisp.TextColor = Color.Red; |
---|
1110 | BuildCityDisp.X = BuildCityDisp.X - 20; |
---|
1111 | ChangeProductionDispText(); |
---|
1112 | CityPlaceSelection = true; |
---|
1113 | } |
---|
1114 | } |
---|
1115 | else |
---|
1116 | { |
---|
1117 | BuildCityDisp.TextColor = Color.Green; |
---|
1118 | BuildCityDisp.X = BuildCityDisp.X + 20; |
---|
1119 | Rules.pCivs[CurrentPlayer].BuiltFromCity = 0; |
---|
1120 | BuildCityDisp.Text = "Rakenna kaupunki (B) (" + Rules.pCivs[CurrentPlayer].BuiltFromCity + " / " + Rules.pCivs[CurrentPlayer].Production + ")"; |
---|
1121 | CityPlaceSelection = false; |
---|
1122 | CurrProduction = CurrProduction + (Rules.pCivs[CurrentPlayer].Production / 2); |
---|
1123 | ChangeProductionDispText(); |
---|
1124 | } |
---|
1125 | TileClickAllowed = true; |
---|
1126 | } |
---|
1127 | |
---|
1128 | private void ChangeProductionDispText() |
---|
1129 | { |
---|
1130 | ProductionDisp.Text = "Vuoro: " + TurnNumber + Environment.NewLine + |
---|
1131 | "Tuotantoa vuorossa: " + Rules.pCivs[CurrentPlayer].Production + Environment.NewLine + |
---|
1132 | "Tuotantoa jäljellä: " + CurrProduction; |
---|
1133 | } |
---|
1134 | |
---|
1135 | private void InitRules() |
---|
1136 | { |
---|
1137 | // Käytetään valmiiksi tehtyjä DLL-tiedostoja |
---|
1138 | BaseRules.Rules.InitTechs(); |
---|
1139 | BaseRules.Rules.InitUnits(); |
---|
1140 | BaseRules.Rules.InitDifficulty(); |
---|
1141 | BaseRules.Rules.InitCivs(); |
---|
1142 | BaseRules.Rules.InitAIBehaviour(); |
---|
1143 | } |
---|
1144 | |
---|
1145 | private void RemoveShroud(int i, int j) |
---|
1146 | { |
---|
1147 | try |
---|
1148 | { |
---|
1149 | ShroudMap[i, j] = 0; |
---|
1150 | ShroudTile[i, j].Destroy(); |
---|
1151 | try |
---|
1152 | { |
---|
1153 | if (OwnershipMap[i, j] > -1) |
---|
1154 | { |
---|
1155 | DrawOwnership(i, j); |
---|
1156 | } |
---|
1157 | } |
---|
1158 | catch |
---|
1159 | { |
---|
1160 | } |
---|
1161 | } |
---|
1162 | catch |
---|
1163 | { |
---|
1164 | MessageDisplay.Add("Shroud not removed from tile " + i + "; " + j + " because of IndexoutofRange exception."); |
---|
1165 | } |
---|
1166 | } |
---|
1167 | |
---|
1168 | private void CheckAndRemoveShroud_FromPos(int i, int j) |
---|
1169 | { |
---|
1170 | RemoveShroud(i, j); |
---|
1171 | for (int shri = i - 2; shri <= i + 2; shri++) |
---|
1172 | { |
---|
1173 | for (int shrj = j - 2; shrj <= j + 2; shrj++) |
---|
1174 | { |
---|
1175 | RemoveShroud(shri, shrj); |
---|
1176 | } |
---|
1177 | } |
---|
1178 | } |
---|
1179 | |
---|
1180 | private void TurnSystem_PlayAITurn(int playernumber) |
---|
1181 | { |
---|
1182 | //DisableInput(); |
---|
1183 | int AIProduction = new int(); |
---|
1184 | double AIProduction2 = new double(); |
---|
1185 | AIProduction = Rules.pCivs[playernumber].Production; |
---|
1186 | AIProduction2 = Rules.GetDifficulty_FromInt(currDiffLevel).ComputerProductionBonus * AIProduction; |
---|
1187 | CurrProduction = Convert.ToInt32(AIProduction2); |
---|
1188 | if (TurnNumber == 1) |
---|
1189 | { |
---|
1190 | for (int a = 0; a <= Rules.pCivs[playernumber].NumberofCities - 1; a++) |
---|
1191 | { |
---|
1192 | for (int b = 0; b <= 4 + currDiffLevel; b++) |
---|
1193 | { |
---|
1194 | CreateUnit(Rules.pCivs[playernumber].CityCoords[a, 0], Rules.pCivs[playernumber].CityCoords[a, 1], Rules.Archer, playernumber); |
---|
1195 | } |
---|
1196 | } |
---|
1197 | } |
---|
1198 | //MessageBox.Show(Convert.ToString(CurrProduction)); |
---|
1199 | EnableInput(); |
---|
1200 | EndTurn(); |
---|
1201 | } |
---|
1202 | |
---|
1203 | private void TurnSystem_Start(int playernumber) |
---|
1204 | { |
---|
1205 | if (Rules.pCivs[playernumber].HumanPlayer == false) |
---|
1206 | { |
---|
1207 | TurnSystem_PlayAITurn(playernumber); |
---|
1208 | return; |
---|
1209 | } |
---|
1210 | TurnNumber = TurnNumber + 1; |
---|
1211 | MessageDisplay.Add("Vuorosi on alkanut!"); |
---|
1212 | CurrentPlayer = playernumber; |
---|
1213 | CurrProduction = Rules.pCivs[playernumber].Production; |
---|
1214 | ProductionDisp.Text = "Vuoro: " + TurnNumber + Environment.NewLine + |
---|
1215 | "Tuotantoa vuorossa: " + Rules.pCivs[playernumber].Production + Environment.NewLine + |
---|
1216 | "Tuotantoa jäljellä: " + CurrProduction; |
---|
1217 | BuildCityDisp.Text = "Rakenna kaupunki (B) (" + Rules.pCivs[playernumber].BuiltFromCity + " / " + Rules.pCivs[playernumber].Production + ")"; |
---|
1218 | if (TurnNumber == 1) |
---|
1219 | { |
---|
1220 | //CreateUnit(Rules.pCivs[playernumber].CityCoords[0, 0], Rules.pCivs[playernumber].CityCoords[0, 1], Rules.Archer, playernumber); |
---|
1221 | //CreateUnit(Rules.pCivs[playernumber].CityCoords[0, 0], Rules.pCivs[playernumber].CityCoords[0, 1], Rules.Archer, playernumber); |
---|
1222 | CreateUnit(Rules.pCivs[playernumber].CityCoords[0, 0], Rules.pCivs[playernumber].CityCoords[0, 1], Rules.Deathbringer, playernumber); |
---|
1223 | //RemoveUnit(Rules.pCivs[playernumber].Units[0].PosY, Rules.pCivs[playernumber].Units[0].PosX, playernumber); |
---|
1224 | } |
---|
1225 | for (int a = 0; a < Rules.pCivs[playernumber].NumberofUnits; a++) |
---|
1226 | { |
---|
1227 | Rules.pCivs[playernumber].Units[a].CurrentMovementPoints = Rules.pCivs[playernumber].Units[a].UnitType.Movement; |
---|
1228 | } |
---|
1229 | } |
---|
1230 | |
---|
1231 | protected override void Update(Time time) |
---|
1232 | { |
---|
1233 | base.Update(time); |
---|
1234 | // Mouse.PositionOnScreen voisi olla vain positiivinen, eikä ruudun pitäisi jakautua keskeltä kahtia |
---|
1235 | // negatiivisiin ja positiivisiin kokonaislukuihin |
---|
1236 | |
---|
1237 | if (gamestarted == true) |
---|
1238 | { |
---|
1239 | for (int i = 0; i <= (kartanKorkeus - 1); i++) |
---|
1240 | { |
---|
1241 | for (int j = 0; j <= (kartanLeveys - 1); j++) |
---|
1242 | { |
---|
1243 | if (Mouse.IsCursorOnGameObject(tile[i, j])) |
---|
1244 | { |
---|
1245 | TileDisp.Text = getTileInfo_forTileDisp(i, j); |
---|
1246 | if (UnitsSelected == false) |
---|
1247 | { |
---|
1248 | UnitStatsDisp.Text = getUnitDisp(i, j, 0); |
---|
1249 | } |
---|
1250 | //Application.DoEvents(); |
---|
1251 | } |
---|
1252 | //Mouse.ListenMovement(tile[i, j], showTileInfo_forTileDisp, null, i, j); |
---|
1253 | // MessageBox.Show(Convert.ToString(TerrainMap[i, j])); |
---|
1254 | } |
---|
1255 | } |
---|
1256 | //TileDisp.Text = getTileInfo_forTileDisp(Convert.ToInt32(Mouse.PositionOnWorld.X) / -48, Convert.ToInt32(Mouse.PositionOnWorld.Y) / 48); |
---|
1257 | if (Mouse.PositionOnScreen.X > MouseScreenWidth) { MoveCamera(0); } |
---|
1258 | else if (Mouse.PositionOnScreen.X < NegMouseScreenWidth) { MoveCamera(2); } |
---|
1259 | else if (Mouse.PositionOnScreen.Y > MouseScreenHeight) { MoveCamera(1); } |
---|
1260 | else if (Mouse.PositionOnScreen.Y < NegMouseScreenHeight) { MoveCamera(3); } |
---|
1261 | } |
---|
1262 | } |
---|
1263 | |
---|
1264 | public string getTileInfo_forTileDisp(int i, int j) |
---|
1265 | { |
---|
1266 | // Haetaan tiedot ruudulle |
---|
1267 | string tileinfo; |
---|
1268 | int Defensebonus = new int(); |
---|
1269 | tileinfo = i + "; " + j + " :" + Environment.NewLine; |
---|
1270 | //MessageBox.Show(i + " " + j); |
---|
1271 | // Maaston perustiedot |
---|
1272 | if (TerrainMap[i, j] == 0) |
---|
1273 | { |
---|
1274 | tileinfo = tileinfo + "Ruohotasankoa"; |
---|
1275 | } |
---|
1276 | else if (TerrainMap[i, j] == 1) |
---|
1277 | { |
---|
1278 | tileinfo = tileinfo + "Vuoristoa"; |
---|
1279 | } |
---|
1280 | else if (TerrainMap[i, j] == 2) |
---|
1281 | { |
---|
1282 | tileinfo = tileinfo + "Aavikkoa"; |
---|
1283 | Defensebonus = Defensebonus - 25; |
---|
1284 | } |
---|
1285 | else if (TerrainMap[i, j] == 3) |
---|
1286 | { |
---|
1287 | tileinfo = tileinfo + "Tundraa"; |
---|
1288 | Defensebonus = Defensebonus + 10; |
---|
1289 | } |
---|
1290 | |
---|
1291 | // Erikoismaaston tiedot |
---|
1292 | |
---|
1293 | if (DTerrainMap[i, j] == 0) |
---|
1294 | { |
---|
1295 | } |
---|
1296 | else if (DTerrainMap[i, j] == 1) |
---|
1297 | { |
---|
1298 | tileinfo = tileinfo + Environment.NewLine + "Vuoristoa" + Environment.NewLine + "Läpipääsemätön"; |
---|
1299 | } |
---|
1300 | else if (DTerrainMap[i, j] == 2) |
---|
1301 | { |
---|
1302 | tileinfo = tileinfo + Environment.NewLine + "Lehtimetsää"; |
---|
1303 | Defensebonus = Defensebonus + 10; |
---|
1304 | } |
---|
1305 | else if (DTerrainMap[i, j] == 3) |
---|
1306 | { |
---|
1307 | tileinfo = tileinfo + Environment.NewLine + "Kuusimetsää"; |
---|
1308 | Defensebonus = Defensebonus + 25; |
---|
1309 | } |
---|
1310 | else |
---|
1311 | { |
---|
1312 | // MessageBox.Show(Convert.ToString(ShroudMap[i, j])); |
---|
1313 | if (ShroudMap[i, j] == 0) |
---|
1314 | { |
---|
1315 | try |
---|
1316 | { |
---|
1317 | if (OwnershipMap[i, j] >= -1) |
---|
1318 | { |
---|
1319 | tileinfo = tileinfo + Environment.NewLine + "Kaupunki"; |
---|
1320 | } |
---|
1321 | } |
---|
1322 | catch |
---|
1323 | { |
---|
1324 | } |
---|
1325 | } |
---|
1326 | } |
---|
1327 | |
---|
1328 | if (ShroudMap[i, j] == 0) |
---|
1329 | { |
---|
1330 | try |
---|
1331 | { |
---|
1332 | if (OwnershipMap[i, j] > -1) |
---|
1333 | { |
---|
1334 | tileinfo = tileinfo + Environment.NewLine + Rules.pCivs[OwnershipMap[i, j]].Name; |
---|
1335 | } |
---|
1336 | } |
---|
1337 | catch |
---|
1338 | { |
---|
1339 | } |
---|
1340 | |
---|
1341 | if (Defensebonus != 0) |
---|
1342 | { |
---|
1343 | return tileinfo = tileinfo + Environment.NewLine + "Puolustusbonus: " + Defensebonus + "%"; |
---|
1344 | } |
---|
1345 | else |
---|
1346 | { |
---|
1347 | return tileinfo; |
---|
1348 | } |
---|
1349 | } |
---|
1350 | return tileinfo; |
---|
1351 | } |
---|
1352 | |
---|
1353 | public string getUnitDisp(int i, int j, int s) |
---|
1354 | { |
---|
1355 | string unitinfo = ""; |
---|
1356 | if (ShroudMap[i, j] == 0) |
---|
1357 | { |
---|
1358 | try |
---|
1359 | { |
---|
1360 | if (OwnershipMap[i, j] > -1) |
---|
1361 | { |
---|
1362 | //MessageBox.Show("OwnershipMap passed:" + i + " " + j + " UnitMap: " + UnitMap[i, j]); |
---|
1363 | //MessageBox.Show(Convert.ToString(0 > -1)); |
---|
1364 | if (UnitMap[i, j] > -1) |
---|
1365 | { |
---|
1366 | //MessageBox.Show("UnitMap passed:" + i + " " + j); |
---|
1367 | //string unitstats; |
---|
1368 | if (s == 0) |
---|
1369 | { |
---|
1370 | unitinfo = "Ruudun yksiköt: " + Environment.NewLine + GetUnits_FromPositionForView(i, j); |
---|
1371 | } |
---|
1372 | else if (s == 1) |
---|
1373 | { |
---|
1374 | unitinfo = "Valitut yksiköt: " + Environment.NewLine + GetUnits_FromPositionForView(i, j); |
---|
1375 | } |
---|
1376 | } |
---|
1377 | } |
---|
1378 | } |
---|
1379 | catch |
---|
1380 | { |
---|
1381 | } |
---|
1382 | } |
---|
1383 | return unitinfo; |
---|
1384 | } |
---|
1385 | |
---|
1386 | private void EndTurn() |
---|
1387 | { |
---|
1388 | if (Rules.pCivs[CurrentPlayer].HumanPlayer == true) |
---|
1389 | { |
---|
1390 | MessageDisplay.Add("Lopetit vuorosi.."); |
---|
1391 | } |
---|
1392 | if (SelectedUnit > -1) |
---|
1393 | { |
---|
1394 | DeselectUnit(); |
---|
1395 | } |
---|
1396 | if (CurrentPlayer == PlayerAmount - 1) |
---|
1397 | { |
---|
1398 | CurrentPlayer = CurrentPlayer - 1; |
---|
1399 | } |
---|
1400 | else |
---|
1401 | { |
---|
1402 | CurrentPlayer = CurrentPlayer + 1; |
---|
1403 | } |
---|
1404 | TurnSystem_Start(CurrentPlayer); |
---|
1405 | } |
---|
1406 | |
---|
1407 | private void DisableInput() |
---|
1408 | { |
---|
1409 | Keyboard.Disable(Key.NumPad1); |
---|
1410 | Keyboard.Disable(Key.NumPad2); |
---|
1411 | Keyboard.Disable(Key.NumPad3); |
---|
1412 | Keyboard.Disable(Key.NumPad4); |
---|
1413 | Keyboard.Disable(Key.NumPad5); |
---|
1414 | Keyboard.Disable(Key.NumPad6); |
---|
1415 | Keyboard.Disable(Key.NumPad7); |
---|
1416 | Keyboard.Disable(Key.NumPad8); |
---|
1417 | Keyboard.Disable(Key.NumPad9); |
---|
1418 | |
---|
1419 | Keyboard.Disable(Key.B); |
---|
1420 | Keyboard.Disable(Key.U); |
---|
1421 | Keyboard.Disable(Key.D1); |
---|
1422 | Keyboard.Disable(Key.D2); |
---|
1423 | Keyboard.Disable(Key.D3); |
---|
1424 | Keyboard.Disable(Key.D4); |
---|
1425 | Keyboard.Disable(Key.End); |
---|
1426 | Keyboard.Disable(Key.Home); |
---|
1427 | |
---|
1428 | Mouse.Disable(MouseButton.Left); |
---|
1429 | } |
---|
1430 | |
---|
1431 | private void EnableInput() |
---|
1432 | { |
---|
1433 | Keyboard.Enable(Key.NumPad1); |
---|
1434 | Keyboard.Enable(Key.NumPad2); |
---|
1435 | Keyboard.Enable(Key.NumPad3); |
---|
1436 | Keyboard.Enable(Key.NumPad4); |
---|
1437 | Keyboard.Enable(Key.NumPad5); |
---|
1438 | Keyboard.Enable(Key.NumPad6); |
---|
1439 | Keyboard.Enable(Key.NumPad7); |
---|
1440 | Keyboard.Enable(Key.NumPad8); |
---|
1441 | Keyboard.Enable(Key.NumPad9); |
---|
1442 | |
---|
1443 | Keyboard.Enable(Key.B); |
---|
1444 | Keyboard.Enable(Key.U); |
---|
1445 | Keyboard.Enable(Key.D1); |
---|
1446 | Keyboard.Enable(Key.D2); |
---|
1447 | Keyboard.Enable(Key.D3); |
---|
1448 | Keyboard.Enable(Key.D4); |
---|
1449 | Keyboard.Enable(Key.End); |
---|
1450 | Keyboard.Enable(Key.Home); |
---|
1451 | |
---|
1452 | Mouse.Enable(MouseButton.Left); |
---|
1453 | } |
---|
1454 | |
---|
1455 | private void InitControls() |
---|
1456 | { |
---|
1457 | Keyboard.Listen(Key.Right, Jypeli.ButtonState.Down, MoveCamera, null, 0); |
---|
1458 | Keyboard.Listen(Key.Left, Jypeli.ButtonState.Down, MoveCamera, null, 2); |
---|
1459 | Keyboard.Listen(Key.Up, Jypeli.ButtonState.Down, MoveCamera, null, 1); |
---|
1460 | Keyboard.Listen(Key.Down, Jypeli.ButtonState.Down, MoveCamera, null, 3); |
---|
1461 | Keyboard.Listen(Key.Tab, Jypeli.ButtonState.Down, ActivateDebug, null, 0); |
---|
1462 | Keyboard.Listen(Key.Enter, Jypeli.ButtonState.Pressed, EndTurn, null); |
---|
1463 | |
---|
1464 | Keyboard.Listen(Key.NumPad1, Jypeli.ButtonState.Pressed, MoveUnit, "Liikuta yksikköä lounaaseen.", 1); |
---|
1465 | Keyboard.Listen(Key.NumPad2, Jypeli.ButtonState.Pressed, MoveUnit, "Liikuta yksikköä etelään.", 2); |
---|
1466 | Keyboard.Listen(Key.NumPad3, Jypeli.ButtonState.Pressed, MoveUnit, "Liikuta yksikköä kaakkoon.", 3); |
---|
1467 | Keyboard.Listen(Key.NumPad4, Jypeli.ButtonState.Pressed, MoveUnit, "Liikuta yksikköä länteen.", 4); |
---|
1468 | Keyboard.Listen(Key.NumPad5, Jypeli.ButtonState.Pressed, MoveUnit, "Hyppää yksikkö yli.", 5); |
---|
1469 | Keyboard.Listen(Key.NumPad6, Jypeli.ButtonState.Pressed, MoveUnit, "Liikuta yksikköä itään.", 6); |
---|
1470 | Keyboard.Listen(Key.NumPad7, Jypeli.ButtonState.Pressed, MoveUnit, "Liikuta yksikköä luoteeseen.", 7); |
---|
1471 | Keyboard.Listen(Key.NumPad8, Jypeli.ButtonState.Pressed, MoveUnit, "Liikuta yksikköä pohjoiseen.", 8); |
---|
1472 | Keyboard.Listen(Key.NumPad9, Jypeli.ButtonState.Pressed, MoveUnit, "Liikuta yksikköä koilliseen.", 9); |
---|
1473 | Keyboard.Listen(Key.End, Jypeli.ButtonState.Pressed, SelectUnits, "Valitsee yksiköitä."); |
---|
1474 | Keyboard.Listen(Key.Home, Jypeli.ButtonState.Pressed, SelectNextUnit, "Valitsee seuraavan yksikön."); |
---|
1475 | |
---|
1476 | //Keyboard.Disable(Key.NumPad1); |
---|
1477 | //Keyboard.Disable(Key.NumPad2); |
---|
1478 | //Keyboard.Disable(Key.NumPad3); |
---|
1479 | //Keyboard.Disable(Key.NumPad4); |
---|
1480 | //Keyboard.Disable(Key.NumPad5); |
---|
1481 | //Keyboard.Disable(Key.NumPad6); |
---|
1482 | //Keyboard.Disable(Key.NumPad7); |
---|
1483 | //Keyboard.Disable(Key.NumPad8); |
---|
1484 | //Keyboard.Disable(Key.NumPad9); |
---|
1485 | |
---|
1486 | MouseScreenWidth = new int(); |
---|
1487 | MouseScreenWidth = Convert.ToInt32(Peli.Screen.Width / 2) - 5; |
---|
1488 | MouseScreenHeight = new int(); |
---|
1489 | MouseScreenHeight = Convert.ToInt32(Peli.Screen.Height / 2) - 5; |
---|
1490 | NegMouseScreenWidth = new int(); |
---|
1491 | NegMouseScreenWidth = Convert.ToInt32(Peli.Screen.Width / -2) + 5; |
---|
1492 | NegMouseScreenHeight = new int(); |
---|
1493 | NegMouseScreenHeight = Convert.ToInt32(Peli.Screen.Height / -2) + 20; |
---|
1494 | } |
---|
1495 | |
---|
1496 | # region Combat |
---|
1497 | public double CalculateAttackerStrength(int unit, int terraintype, int dterraintype, int civid, int i, int j) |
---|
1498 | { |
---|
1499 | double returnvalue = new double(); |
---|
1500 | double baseStrength = new double(); |
---|
1501 | |
---|
1502 | baseStrength = Rules.pCivs[civid].Units[unit].UnitType.Strength; |
---|
1503 | |
---|
1504 | if (Rules.pCivs[OwnershipMap[i, j]].Units[GetUnit_FromPositionForSelection(i, j)].UnitType.FirstStrikes > 0) |
---|
1505 | { |
---|
1506 | if (Rules.pCivs[civid].Units[unit].UnitType.FirstStrikes == 0 | Rules.pCivs[civid].Units[unit].UnitType.FSOnAttack == false) |
---|
1507 | { |
---|
1508 | baseStrength = baseStrength - ((Rules.pCivs[OwnershipMap[i, j]].Units[GetUnit_FromPositionForSelection(i, j)].UnitType.Strength / 4) * Rules.pCivs[OwnershipMap[i, j]].Units[GetUnit_FromPositionForSelection(i, j)].UnitType.FirstStrikes); |
---|
1509 | } |
---|
1510 | } |
---|
1511 | |
---|
1512 | if (dterraintype > 9) |
---|
1513 | { |
---|
1514 | baseStrength = (baseStrength * (Rules.pCivs[civid].Units[unit].UnitType.CityAttackBonus + 1.00)); |
---|
1515 | } |
---|
1516 | |
---|
1517 | returnvalue = (baseStrength * Rules.pCivs[civid].Units[unit].UnitType.HP); |
---|
1518 | |
---|
1519 | return returnvalue; |
---|
1520 | } |
---|
1521 | |
---|
1522 | public double CalculateDefenderStrength(int unit, int terraintype, int dterraintype, int civid, int i, int j) |
---|
1523 | { |
---|
1524 | double returnvalue = new double(); |
---|
1525 | double baseStrength = new double(); |
---|
1526 | |
---|
1527 | baseStrength = Rules.pCivs[civid].Units[unit].UnitType.Strength; |
---|
1528 | |
---|
1529 | if (dterraintype > 9) |
---|
1530 | { |
---|
1531 | baseStrength = (baseStrength * (Rules.pCivs[civid].Units[unit].UnitType.CityDefenseBonus + 1.00)); |
---|
1532 | } |
---|
1533 | |
---|
1534 | returnvalue = (baseStrength * Rules.pCivs[civid].Units[unit].UnitType.HP); |
---|
1535 | |
---|
1536 | return returnvalue; |
---|
1537 | } |
---|
1538 | |
---|
1539 | private void EnterCombat(int i, int j, int ab, int bb) |
---|
1540 | { |
---|
1541 | if (DTerrainMap[i, j] > 9) |
---|
1542 | { |
---|
1543 | if (UnitMap[i, j] > -1) |
---|
1544 | { |
---|
1545 | double attackerStrength; |
---|
1546 | double defenderStrength; |
---|
1547 | int chances = new int(); |
---|
1548 | attackerStrength = CalculateAttackerStrength(SelectedUnit, TerrainMap[i, j], DTerrainMap[i, j], CurrentPlayer, i, j); |
---|
1549 | defenderStrength = CalculateDefenderStrength(GetUnit_FromPositionForSelection(i, j), TerrainMap[i, j], DTerrainMap[i, j], OwnershipMap[i, j], i, j); |
---|
1550 | chances = CountChances(attackerStrength, defenderStrength); |
---|
1551 | int WinNumber = RandomGen.NextInt(1, 100); |
---|
1552 | double dNumber = new double(); |
---|
1553 | if (chances > WinNumber) |
---|
1554 | { |
---|
1555 | MessageDisplay.Add("Sinun " + Rules.pCivs[CurrentPlayer].Units[SelectedUnit].UnitType.Name + " on hyökätessään tuhonnut vihollisen " + Rules.pCivs[OwnershipMap[i, j]].Units[GetUnit_FromPositionForSelection(i, j)].UnitType.Name + "in!"); |
---|
1556 | RemoveUnit(i, j, OwnershipMap[i, j], Rules.pCivs[OwnershipMap[i, j]].Units[GetUnit_FromPositionForSelection(i, j)].UnitType, Rules.pCivs[OwnershipMap[i, j]].Units[GetUnit_FromPositionForSelection(i, j)].HP); |
---|
1557 | dNumber = ((chances - WinNumber) / 100); |
---|
1558 | Rules.pCivs[CurrentPlayer].Units[SelectedUnit].HP = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].HP - dNumber; |
---|
1559 | } |
---|
1560 | else |
---|
1561 | { |
---|
1562 | MessageDisplay.Add("Sinun " + Rules.pCivs[CurrentPlayer].Units[SelectedUnit].UnitType.Name + " on kuollut hyökätessään vihollisen " + Rules.pCivs[OwnershipMap[i, j]].Units[GetUnit_FromPositionForSelection(i, j)].UnitType.Name + "iin!"); |
---|
1563 | RemoveUnit(ab, bb, OwnershipMap[ab, bb], Rules.pCivs[OwnershipMap[ab, bb]].Units[SelectedUnit].UnitType, Rules.pCivs[OwnershipMap[ab, bb]].Units[SelectedUnit].HP); |
---|
1564 | DeselectUnit(); |
---|
1565 | dNumber = ((chances - WinNumber) / 100); |
---|
1566 | Rules.pCivs[OwnershipMap[i, j]].Units[GetUnit_FromPositionForSelection(i, j)].HP = Rules.pCivs[OwnershipMap[i, j]].Units[GetUnit_FromPositionForSelection(i, j)].HP - dNumber; |
---|
1567 | } |
---|
1568 | } |
---|
1569 | else |
---|
1570 | { |
---|
1571 | CityCapture(i, j, ab, bb); |
---|
1572 | } |
---|
1573 | } |
---|
1574 | } |
---|
1575 | |
---|
1576 | public int CountChances(double attackerStrength, double defenderStrength) |
---|
1577 | { |
---|
1578 | int chances = new int(); |
---|
1579 | if (defenderStrength > attackerStrength) |
---|
1580 | { |
---|
1581 | MessageBox.Show(Convert.ToString((((defenderStrength / attackerStrength) / 2) * 100))); |
---|
1582 | chances = Convert.ToInt32((((attackerStrength / defenderStrength) / 2) * 100)); |
---|
1583 | return chances; |
---|
1584 | } |
---|
1585 | else |
---|
1586 | { |
---|
1587 | MessageBox.Show(Convert.ToString((((defenderStrength / attackerStrength) / 2) * 100))); |
---|
1588 | chances = Convert.ToInt32((((defenderStrength / attackerStrength) / 2) * 100)); |
---|
1589 | return chances; |
---|
1590 | } |
---|
1591 | } |
---|
1592 | |
---|
1593 | private void CityCapture(int i, int j, int ab, int bb) |
---|
1594 | { |
---|
1595 | RemoveCity_FromCivFromPosition(i, j); |
---|
1596 | Rules.pCivs[OwnershipMap[i, j]].NumberofCities = Rules.pCivs[OwnershipMap[i, j]].NumberofCities - 1; |
---|
1597 | Rules.pCivs[OwnershipMap[i, j]].Production = Rules.pCivs[OwnershipMap[i, j]].Production - 10; |
---|
1598 | MessageDisplay.TextColor = Color.Red; |
---|
1599 | MessageDisplay.Add(Rules.pCivs[CurrentPlayer].Name + " on valloittanut kaupungin ruudusta " + i + "; " + j + " (" + Rules.pCivs[OwnershipMap[i, j]].Name + ")"); |
---|
1600 | Thread.Sleep(1000); |
---|
1601 | if (Rules.pCivs[OwnershipMap[i, j]].NumberofCities == 0) |
---|
1602 | { |
---|
1603 | MessageDisplay.Add(Rules.pCivs[OwnershipMap[i, j]].Name + " has been destroyed!"); |
---|
1604 | Rules.pCivs[OwnershipMap[i, j]].Enabled = false; |
---|
1605 | } |
---|
1606 | OwnershipMap[i, j] = CurrentPlayer; |
---|
1607 | DrawOwnership(i, j); |
---|
1608 | Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY = i; |
---|
1609 | Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX = j; |
---|
1610 | MessageDisplay.TextColor = Color.Orange; |
---|
1611 | AddCity(i, j); |
---|
1612 | |
---|
1613 | if (GetUnit_FromPositionForSelection(ab, bb) == -1) |
---|
1614 | { |
---|
1615 | OwnershipMap[ab, bb] = -1; |
---|
1616 | TileOwnership[ab, bb].Image = LoadImage(Textpath + "nothing"); |
---|
1617 | } |
---|
1618 | DrawUnit(i, j); |
---|
1619 | } |
---|
1620 | # endregion |
---|
1621 | private void AddCity(int i, int j) |
---|
1622 | { |
---|
1623 | Rules.pCivs[CurrentPlayer].Production = Rules.pCivs[CurrentPlayer].Production + 10; |
---|
1624 | Rules.pCivs[CurrentPlayer].NumberofCities = Rules.pCivs[CurrentPlayer].NumberofCities + 1; |
---|
1625 | Rules.pCivs[CurrentPlayer].CityCoords[Rules.pCivs[CurrentPlayer].NumberofCities - 1, 0] = i; |
---|
1626 | Rules.pCivs[CurrentPlayer].CityCoords[Rules.pCivs[CurrentPlayer].NumberofCities - 1, 1] = j; |
---|
1627 | BuildCityDisp.Text = "Rakenna kaupunki (B) (" + Rules.pCivs[CurrentPlayer].BuiltFromCity + " / " + Rules.pCivs[CurrentPlayer].Production + ")"; |
---|
1628 | CityPlaceSelection = false; |
---|
1629 | ChangeProductionDispText(); |
---|
1630 | DTerrainMap[i, j] = CurrentPlayer + 10; |
---|
1631 | DTile[i, j].Image = LoadImage(Textpath + "cityancient"); |
---|
1632 | CheckAndRemoveShroud_FromPos(i, j); |
---|
1633 | if (OwnershipMap[i, j] == -1) |
---|
1634 | { |
---|
1635 | OwnershipMap[i, j] = CurrentPlayer; |
---|
1636 | DrawOwnership(i, j); |
---|
1637 | CheckAndRemoveShroud_FromPos(i, j); |
---|
1638 | } |
---|
1639 | } |
---|
1640 | |
---|
1641 | public int GetCityPosInArray_ForRemoval(int i, int j, int civid) |
---|
1642 | { |
---|
1643 | for (int a = 0; a <= Rules.pCivs[civid].NumberofCities - 1; a++) |
---|
1644 | { |
---|
1645 | if (Rules.pCivs[civid].CityCoords[a, 0] == i && Rules.pCivs[civid].CityCoords[a, 1] == j) |
---|
1646 | { |
---|
1647 | return a; |
---|
1648 | } |
---|
1649 | } |
---|
1650 | return 0; |
---|
1651 | } |
---|
1652 | |
---|
1653 | private void RemoveCity_FromCivFromPosition(int i, int j) |
---|
1654 | { |
---|
1655 | int civowner = new int(); |
---|
1656 | civowner = OwnershipMap[i, j]; |
---|
1657 | int cityPosInArray = GetCityPosInArray_ForRemoval(i, j, civowner); |
---|
1658 | |
---|
1659 | if (cityPosInArray > 0 && Rules.pCivs[civowner].NumberofCities > 2) |
---|
1660 | { |
---|
1661 | for (int a = cityPosInArray + 1; a <= Rules.pCivs[civowner].NumberofCities - 1; a++) |
---|
1662 | { |
---|
1663 | Rules.pCivs[civowner].CityCoords[a - 1, 0] = Rules.pCivs[civowner].CityCoords[a, 0]; |
---|
1664 | Rules.pCivs[civowner].CityCoords[a - 1, 1] = Rules.pCivs[civowner].CityCoords[a, 1]; |
---|
1665 | } |
---|
1666 | Rules.pCivs[civowner].CityCoords[Rules.pCivs[civowner].NumberofCities - 1, 0] = 0; |
---|
1667 | Rules.pCivs[civowner].CityCoords[Rules.pCivs[civowner].NumberofCities - 1, 1] = 0; |
---|
1668 | } |
---|
1669 | else if (cityPosInArray == 0 && Rules.pCivs[civowner].NumberofCities > 1) |
---|
1670 | { |
---|
1671 | for (int a = 1; a <= Rules.pCivs[civowner].NumberofCities - 1; a++) |
---|
1672 | { |
---|
1673 | Rules.pCivs[civowner].CityCoords[a - 1, 0] = Rules.pCivs[civowner].CityCoords[a, 0]; |
---|
1674 | Rules.pCivs[civowner].CityCoords[a - 1, 1] = Rules.pCivs[civowner].CityCoords[a, 1]; |
---|
1675 | } |
---|
1676 | Rules.pCivs[civowner].CityCoords[Rules.pCivs[civowner].NumberofCities - 1, 0] = 0; |
---|
1677 | Rules.pCivs[civowner].CityCoords[Rules.pCivs[civowner].NumberofCities - 1, 1] = 0; |
---|
1678 | } |
---|
1679 | else if (Rules.pCivs[civowner].NumberofCities == 1) |
---|
1680 | { |
---|
1681 | Rules.pCivs[civowner].CityCoords[0, 0] = 0; |
---|
1682 | Rules.pCivs[civowner].CityCoords[0, 1] = 0; |
---|
1683 | Rules.pCivs[civowner].Enabled = false; |
---|
1684 | } |
---|
1685 | // int unitpos = GetUnit_FromPositionForRemoval(i, j, unittype, unitHP); |
---|
1686 | // if (unitpos > 0 && Rules.pCivs[civnumber].NumberofUnits > 2) |
---|
1687 | // { |
---|
1688 | // MessageBox.Show("FirstMethod"); |
---|
1689 | // for (int a = unitpos + 1; a <= Rules.pCivs[civnumber].NumberofUnits - 1; a++) |
---|
1690 | // { |
---|
1691 | // Rules.pCivs[civnumber].Units[a - 1].HP = Rules.pCivs[civnumber].Units[a].HP; |
---|
1692 | // Rules.pCivs[civnumber].Units[a - 1].PosY = Rules.pCivs[civnumber].Units[a].PosY; |
---|
1693 | // Rules.pCivs[civnumber].Units[a - 1].PosX = Rules.pCivs[civnumber].Units[a].PosX; |
---|
1694 | // Rules.pCivs[civnumber].Units[a - 1].UnitType = Rules.pCivs[civnumber].Units[a].UnitType; |
---|
1695 | // } |
---|
1696 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosX = 0; |
---|
1697 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosY = 0; |
---|
1698 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].HP = 0.0; |
---|
1699 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].UnitType = null; |
---|
1700 | // } |
---|
1701 | // else if (unitpos == 0 && Rules.pCivs[civnumber].NumberofUnits > 1) |
---|
1702 | // { |
---|
1703 | // MessageBox.Show("SecondMethod"); |
---|
1704 | // for (int a = 1; a <= Rules.pCivs[civnumber].NumberofUnits - 1; a++) |
---|
1705 | // { |
---|
1706 | // Rules.pCivs[civnumber].Units[a - 1].HP = Rules.pCivs[civnumber].Units[a].HP; |
---|
1707 | // Rules.pCivs[civnumber].Units[a - 1].PosY = Rules.pCivs[civnumber].Units[a].PosY; |
---|
1708 | // Rules.pCivs[civnumber].Units[a - 1].PosX = Rules.pCivs[civnumber].Units[a].PosX; |
---|
1709 | // Rules.pCivs[civnumber].Units[a - 1].UnitType = Rules.pCivs[civnumber].Units[a].UnitType; |
---|
1710 | // } |
---|
1711 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosX = 0; |
---|
1712 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosY = 0; |
---|
1713 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].HP = 0.0; |
---|
1714 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].UnitType = null; |
---|
1715 | // } |
---|
1716 | // else if (unitpos == 0 && Rules.pCivs[civnumber].NumberofUnits == 1) |
---|
1717 | // { |
---|
1718 | // MessageBox.Show("ThirdMethod"); |
---|
1719 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosX = 0; |
---|
1720 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].PosY = 0; |
---|
1721 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].HP = 0.0; |
---|
1722 | // Rules.pCivs[civnumber].Units[Rules.pCivs[civnumber].NumberofUnits - 1].UnitType = null; |
---|
1723 | // } |
---|
1724 | // Rules.pCivs[civnumber].NumberofUnits = Rules.pCivs[civnumber].NumberofUnits - 1; |
---|
1725 | //} |
---|
1726 | } |
---|
1727 | |
---|
1728 | private void SelectNextUnit() |
---|
1729 | { |
---|
1730 | try |
---|
1731 | { |
---|
1732 | SelectedUnit = SelectedUnit + 1; |
---|
1733 | UnitsSelected = true; |
---|
1734 | UnitTile[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX].Image = LoadImage(OwnershipColorPath + "unitsOnTileSelected"); |
---|
1735 | MessageDisplay.Add("Valitsit yksikön " + Rules.pCivs[CurrentPlayer].Units[SelectedUnit].UnitType.Name + " kohteesta " + Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + "; " + Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX); |
---|
1736 | MessageDisplay.Add("Liikuta valittua yksikköä Numpadista."); |
---|
1737 | UnitStatsDisp.Text = "Valittu yksikkö:" + Environment.NewLine + Rules.pCivs[CurrentPlayer].Units[SelectedUnit].UnitType.Name + |
---|
1738 | Environment.NewLine + "-Voimakkuus: " + Rules.pCivs[CurrentPlayer].Units[SelectedUnit].UnitType.Strength + Environment.NewLine + |
---|
1739 | "-Liikkuvuus: " + Rules.pCivs[CurrentPlayer].Units[SelectedUnit].UnitType.Movement + Environment.NewLine + |
---|
1740 | Rules.pCivs[CurrentPlayer].Units[SelectedUnit].UnitType.Description + Environment.NewLine + |
---|
1741 | " HP: " + Rules.pCivs[CurrentPlayer].Units[SelectedUnit].HP * 100 + "/100"; |
---|
1742 | return; |
---|
1743 | } |
---|
1744 | catch |
---|
1745 | { |
---|
1746 | SelectedUnit = -1; |
---|
1747 | UnitsSelected = false; |
---|
1748 | MessageDisplay.Add("Ei ole enempää yksiköitä valittavaksi."); |
---|
1749 | } |
---|
1750 | } |
---|
1751 | |
---|
1752 | private void SelectUnits() |
---|
1753 | { |
---|
1754 | //MessageBox.Show("SelectNextUnit"); |
---|
1755 | for (int a = 0; a <= Rules.pCivs[CurrentPlayer].NumberofUnits - 1; a++) |
---|
1756 | { |
---|
1757 | if (Rules.pCivs[CurrentPlayer].Units[a].CurrentMovementPoints == 1 | Rules.pCivs[CurrentPlayer].Units[a].CurrentMovementPoints > 1) |
---|
1758 | { |
---|
1759 | SelectedUnit = a; |
---|
1760 | UnitsSelected = true; |
---|
1761 | UnitTile[Rules.pCivs[CurrentPlayer].Units[a].PosY, Rules.pCivs[CurrentPlayer].Units[a].PosX].Image = LoadImage(OwnershipColorPath + "unitsOnTileSelected"); |
---|
1762 | MessageDisplay.Add("Valitsit yksikön " + Rules.pCivs[CurrentPlayer].Units[a].UnitType.Name + " kohteesta " + Rules.pCivs[CurrentPlayer].Units[a].PosY + "; " + Rules.pCivs[CurrentPlayer].Units[a].PosX); |
---|
1763 | MessageDisplay.Add("Liikuta valittua yksikköä Numpadista."); |
---|
1764 | UnitStatsDisp.Text = "Valittu yksikkö:" + Environment.NewLine + Rules.pCivs[CurrentPlayer].Units[a].UnitType.Name + |
---|
1765 | Environment.NewLine + "-Voimakkuus: " + Rules.pCivs[CurrentPlayer].Units[a].UnitType.Strength + Environment.NewLine + |
---|
1766 | "-Liikkuvuus: " + Rules.pCivs[CurrentPlayer].Units[a].UnitType.Movement + Environment.NewLine + |
---|
1767 | Rules.pCivs[CurrentPlayer].Units[a].UnitType.Description + Environment.NewLine + |
---|
1768 | " HP: " + Rules.pCivs[CurrentPlayer].Units[a].HP * 100 + "/100"; |
---|
1769 | return; |
---|
1770 | } |
---|
1771 | } |
---|
1772 | } |
---|
1773 | |
---|
1774 | private void MoveUnit(int direction) |
---|
1775 | { |
---|
1776 | if (SelectedUnit == -1) |
---|
1777 | { |
---|
1778 | MessageDisplay.Add("Ei ole yksikköä valittuna."); |
---|
1779 | } |
---|
1780 | else |
---|
1781 | { |
---|
1782 | if (direction == 1) |
---|
1783 | { |
---|
1784 | UnitMovementMain(-1, -1); |
---|
1785 | } |
---|
1786 | else if (direction == 2) |
---|
1787 | { |
---|
1788 | UnitMovementMain(-1, 0); |
---|
1789 | } |
---|
1790 | else if (direction == 3) |
---|
1791 | { |
---|
1792 | UnitMovementMain(-1, 1); |
---|
1793 | } |
---|
1794 | else if (direction == 4) |
---|
1795 | { |
---|
1796 | UnitMovementMain(0, -1); |
---|
1797 | } |
---|
1798 | else if (direction == 5) |
---|
1799 | { |
---|
1800 | //SelectNextUnitOnTile(-1, 0); |
---|
1801 | } |
---|
1802 | else if (direction == 6) |
---|
1803 | { |
---|
1804 | UnitMovementMain(0, 1); |
---|
1805 | } |
---|
1806 | else if (direction == 7) |
---|
1807 | { |
---|
1808 | UnitMovementMain(1, -1); |
---|
1809 | } |
---|
1810 | else if (direction == 8) |
---|
1811 | { |
---|
1812 | UnitMovementMain(1, 0); |
---|
1813 | } |
---|
1814 | else if (direction == 9) |
---|
1815 | { |
---|
1816 | UnitMovementMain(1, 1); |
---|
1817 | } |
---|
1818 | if (Rules.pCivs[CurrentPlayer].Units[SelectedUnit].CurrentMovementPoints == 0) |
---|
1819 | { |
---|
1820 | DeselectUnit(); |
---|
1821 | } |
---|
1822 | else |
---|
1823 | { |
---|
1824 | UnitTile[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX].Image = LoadImage(OwnershipColorPath + "unitsOnTileSelected"); |
---|
1825 | } |
---|
1826 | } |
---|
1827 | //Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX - 1; |
---|
1828 | //Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY - 1; |
---|
1829 | //OwnershipMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX] = CurrentPlayer; |
---|
1830 | //DrawOwnership(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX); |
---|
1831 | //UnitMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX] = CurrentPlayer; |
---|
1832 | //DrawUnit(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX); |
---|
1833 | //CheckAndRemoveShroud_FromPos(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX); |
---|
1834 | //Rules.pCivs[CurrentPlayer].Units[SelectedUnit].CurrentMovementPoints = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].CurrentMovementPoints - 1; |
---|
1835 | //if (GetUnit_FromPositionForSelection(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + 1, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + 1) == -1) |
---|
1836 | //{ |
---|
1837 | // UnitMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + 1, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + 1] = -1; |
---|
1838 | // UnitTile[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + 1, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + 1].Destroy(); |
---|
1839 | // if (CheckforCityinPos(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + 1, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + 1, CurrentPlayer) == -1) |
---|
1840 | // { |
---|
1841 | // OwnershipMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + 1, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + 1] = -1; |
---|
1842 | // TileOwnership[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + 1, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + 1].Destroy(); |
---|
1843 | // } |
---|
1844 | //} |
---|
1845 | } |
---|
1846 | |
---|
1847 | private void UnitMovementMain(int a, int b) |
---|
1848 | { |
---|
1849 | if (TerrainMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + a, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + b] == Vuoristo | DTerrainMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + a, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + b] == Vuoristo) |
---|
1850 | { |
---|
1851 | MessageDisplay.Add("Et voi liikkua vuorten läpi!"); |
---|
1852 | } |
---|
1853 | else |
---|
1854 | { |
---|
1855 | if (Rules.pCivs[CurrentPlayer].Units[SelectedUnit].CurrentMovementPoints == 0 | Rules.pCivs[CurrentPlayer].Units[SelectedUnit].CurrentMovementPoints < 0) |
---|
1856 | { |
---|
1857 | MessageDisplay.Add("Valitulla yksiköllä ei ollut liikkumapisteitä."); |
---|
1858 | return; |
---|
1859 | } |
---|
1860 | if (OwnershipMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + a, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + b] != -1 && OwnershipMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + a, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + b] != (CurrentPlayer + 10)) |
---|
1861 | { |
---|
1862 | EnterCombat(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + a, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + b, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX); |
---|
1863 | return; |
---|
1864 | } |
---|
1865 | Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + b; |
---|
1866 | Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + a; |
---|
1867 | // MessageBox.Show(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + " " + Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX); |
---|
1868 | //try |
---|
1869 | //{ |
---|
1870 | int posyK; |
---|
1871 | int posxK; |
---|
1872 | posyK = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + (a * -1); |
---|
1873 | posxK = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + (b * -1); |
---|
1874 | OwnershipMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX] = CurrentPlayer; |
---|
1875 | DrawOwnership(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX); |
---|
1876 | UnitMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX] = CurrentPlayer; |
---|
1877 | CheckAndRemoveShroud_FromPos(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX); |
---|
1878 | Rules.pCivs[CurrentPlayer].Units[SelectedUnit].CurrentMovementPoints = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].CurrentMovementPoints - 1; |
---|
1879 | DrawUnit(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX); |
---|
1880 | //MessageBox.Show(Convert.ToString(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].CurrentMovementPoints)); |
---|
1881 | if (GetUnit_FromPositionForSelection(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + (a * -1), Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + (b * -1)) == -1) |
---|
1882 | { |
---|
1883 | UnitMap[posyK, posxK] = -1; |
---|
1884 | UnitTile[posyK, posxK].Image = LoadImage(Textpath + "nothing"); |
---|
1885 | if (CheckforCityinPos(Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + (a * -1), Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + (b * -1), CurrentPlayer) == -1) |
---|
1886 | { |
---|
1887 | OwnershipMap[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + (a * -1), Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + (b * -1)] = -1; |
---|
1888 | TileOwnership[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY + (a * -1), Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX + (b * -1)].Image = LoadImage(Textpath + "nothing"); |
---|
1889 | } |
---|
1890 | } |
---|
1891 | //catch |
---|
1892 | //{ |
---|
1893 | //MessageDisplay.Add("Et voi liikkua kartan ulkopuolelle!"); |
---|
1894 | //Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX - b; |
---|
1895 | //Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY = Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY - a; |
---|
1896 | //} |
---|
1897 | //} |
---|
1898 | } |
---|
1899 | } |
---|
1900 | |
---|
1901 | private void DrawUnit(int i, int j) |
---|
1902 | { |
---|
1903 | UnitTile[i, j].Image = LoadImage(OwnershipColorPath + "unitsOnTileSelected"); |
---|
1904 | UnitTile[i, j].IsVisible = true; |
---|
1905 | //Add(UnitTile[i, j]); |
---|
1906 | } |
---|
1907 | |
---|
1908 | private void DeselectUnit() |
---|
1909 | { |
---|
1910 | UnitTile[Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosY, Rules.pCivs[CurrentPlayer].Units[SelectedUnit].PosX].Image = LoadImage(OwnershipColorPath + "unitsOnTile"); |
---|
1911 | UnitsSelected = false; |
---|
1912 | SelectedUnit = -1; |
---|
1913 | //Keyboard.Disable(Key.NumPad1); |
---|
1914 | //Keyboard.Disable(Key.NumPad2); |
---|
1915 | //Keyboard.Disable(Key.NumPad3); |
---|
1916 | //Keyboard.Disable(Key.NumPad4); |
---|
1917 | //Keyboard.Disable(Key.NumPad5); |
---|
1918 | //Keyboard.Disable(Key.NumPad6); |
---|
1919 | //Keyboard.Disable(Key.NumPad7); |
---|
1920 | //Keyboard.Disable(Key.NumPad8); |
---|
1921 | //Keyboard.Disable(Key.NumPad9); |
---|
1922 | } |
---|
1923 | |
---|
1924 | public int CheckforCityinPos(int i, int j, int civid) |
---|
1925 | { |
---|
1926 | int returnvalue = new int(); |
---|
1927 | if (DTerrainMap[i, j] - 10 == civid) |
---|
1928 | { |
---|
1929 | returnvalue = civid; |
---|
1930 | } |
---|
1931 | else |
---|
1932 | { |
---|
1933 | returnvalue = -1; |
---|
1934 | } |
---|
1935 | return returnvalue; |
---|
1936 | } |
---|
1937 | |
---|
1938 | private void ActivateDebug(int asd) |
---|
1939 | { |
---|
1940 | //Add(MessageDisplay); |
---|
1941 | MessageDisplay.Add("DEBUG MODE ACTIVATED"); |
---|
1942 | Keyboard.Listen(Key.A, Jypeli.ButtonState.Down, ShowColors, null); |
---|
1943 | } |
---|
1944 | |
---|
1945 | private void ShowColors() |
---|
1946 | { |
---|
1947 | for (int a = 0; a <= (AmountofPlayers - 1); a++) |
---|
1948 | { |
---|
1949 | MessageDisplay.Add("Pelaaja: " + a + "; " + Rules.pCivs[a].Color); |
---|
1950 | } |
---|
1951 | } |
---|
1952 | |
---|
1953 | private void MoveCamera(Int32 dir) |
---|
1954 | { |
---|
1955 | if (gamestarted == false) { return; } |
---|
1956 | if ((dir == 0) && (Camera.Position.X < (tile[kartanKorkeus - 1, kartanLeveys - 1].X) - ((Peli.Screen.Width / 2) - 200))) |
---|
1957 | { |
---|
1958 | Camera.Move(CamSpeedEast); |
---|
1959 | } |
---|
1960 | if ((dir == 1) && (Camera.Position.Y < (tile[kartanKorkeus - 1, kartanLeveys - 1].Y) - ((Peli.Screen.Height / 2) - 12))) |
---|
1961 | { |
---|
1962 | Camera.Move(CamSpeedNorth); |
---|
1963 | } |
---|
1964 | if ((dir == 2) && (Camera.Position.X > (tile[0, 0].X) + (Peli.Screen.Width / 2))) |
---|
1965 | { |
---|
1966 | Camera.Move(CamSpeedWest); |
---|
1967 | } |
---|
1968 | if ((dir == 3) && (Camera.Position.Y > (tile[0, 0].Y) + (Peli.Screen.Height / 2))) |
---|
1969 | { |
---|
1970 | Camera.Move(CamSpeedSouth); |
---|
1971 | } |
---|
1972 | } |
---|
1973 | } |
---|
1974 | } |
---|