Changeset 915
- Timestamp:
- 2010-06-16 15:00:28 (13 years ago)
- Location:
- 2010/24/ramipasa/ALTKTileEngine
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/24/ramipasa/ALTKTileEngine/Content/Content.contentproj
r895 r915 40 40 <Importer>XImporter</Importer> 41 41 </Content> 42 <Compile Include="Textures\fogofwar.png"> 43 <Name>fogofwar</Name> 44 <Importer>TextureImporter</Importer> 45 <Processor>TextureProcessor</Processor> 46 </Compile> 47 <Compile Include="Textures\spruceforestS.png"> 48 <Name>spruceforestS</Name> 49 <Importer>TextureImporter</Importer> 50 <Processor>TextureProcessor</Processor> 51 </Compile> 42 52 <Compile Include="Textures\Ownership\aqua.png"> 43 53 <Name>aqua</Name> -
2010/24/ramipasa/ALTKTileEngine/Peli.cs
r900 r915 24 24 int[,] DTerrainMap; // erikoismaastokartta 25 25 int[,] OwnershipMap; // ruudukon omistuskartta (kenen pelaajan hallinnassa on mikäkin ruutu) 26 int[,] ShroudMap; // pelaajan näkymää pienentävä Shroudmap 26 27 27 28 string Textpath; 28 29 string OwnershipColorPath; 29 30 30 int AmountofPlayers; 31 31 int AmountofPlayers; // Ihmispelaajien määrä, tällä hetkellä peli tukee vain yhtä 32 int TurnNumber; // vuoron numero 33 int CurrProduction; // pelaajan tämänhetkinen tuotanto 34 32 35 // !!!!!!!!!!!!!!!!!!!!!!!!!!! 33 36 // Pitänee tehdä vielä yksi ALTKSUnit-namespace ALTKCoreen. … … 36 39 37 40 TextDisplay TileDisp; 41 TextDisplay UnitStatsDisp; 42 TextDisplay ProductionDisp; 38 43 39 44 int kartanLeveys; … … 50 55 GameObject[,] DTile; 51 56 GameObject[,] TileOwnership; 57 GameObject[,] ShroudTile; 52 58 //Vector tileVector; 53 59 … … 62 68 int NegMouseScreenWidth; 63 69 int NegMouseScreenHeight; 70 # region Aloitusruutuvalikko 64 71 protected override void Begin() 65 72 { … … 74 81 void InitStartMenu() 75 82 { 83 Level.BackgroundColor = Color.Gray; 76 84 Mouse.Enabled = true; 77 85 Mouse.IsCursorVisible = true; 86 87 InputQueryWindow input = new InputQueryWindow(); 88 input.InputConfirmed += Player_SetName; 89 input.QueryText.Text = "Kirjoita valtiosi nimi:"; 90 input.Size = new Vector(300.0, 100.0); 91 input.Position = new Vector(-250.0, 350.0); 92 input.InputBox.BorderColor = Color.GreenYellow; 93 ShowWindow(input); 78 94 79 95 GameObject TrainingButton = new GameObject(250, 30, Shapes.Rectangle); … … 104 120 } 105 121 122 void Player_SetName(InputQueryWindow sender, string input) 123 { 124 Rules.pCivs[0].Name = input; 125 Rules.pCivs[0].HumanPlayer = true; 126 Rules.pCivs[0].Enabled = true; 127 Rules.pCivs[0].Color = "red"; 128 } 129 106 130 void SetDiffButton(GameObject diffbutton, int difflevel) 107 131 { 108 diffbutton.X = -250;109 diffbutton.Y = ((difflevel * -50) + 400);132 diffbutton.X = 250; 133 diffbutton.Y = ((difflevel * -50) + 300); 110 134 if (difflevel == 0) { diffbutton.Image = LoadImage(Textpath + "training"); } 111 135 else if (difflevel == 1) { diffbutton.Image = LoadImage(Textpath + "easy"); } … … 128 152 gamestarted = true; 129 153 } 130 154 # endregion 131 155 # region Kartan luominen 132 156 133 157 void InitMap() 134 158 { 159 TurnNumber = new int(); 135 160 AmountofPlayers = new int(); 136 161 Int32 i; … … 158 183 DTerrainMap = new int[kartanKorkeus, kartanLeveys]; 159 184 OwnershipMap = new int[kartanKorkeus, kartanLeveys]; 185 ShroudMap = new int[kartanKorkeus, kartanLeveys]; 160 186 InitTerrain(0); 161 187 InitTerrain(1); 162 188 InitTerrain(2); 189 InitTerrain(3); 163 190 164 191 tile = new GameObject[kartanKorkeus, kartanLeveys]; 165 192 DTile = new GameObject[kartanKorkeus, kartanLeveys]; 166 193 TileOwnership = new GameObject[kartanKorkeus, kartanLeveys]; 194 ShroudTile = new GameObject[kartanKorkeus, kartanLeveys]; 167 195 InitTerrainGraphics(0); 168 196 InitTerrainGraphics(1); 169 197 InitTerrainGraphics(2); 198 InitTerrainGraphics(3); 170 199 171 200 // Koodi käännetty RGE:n VB.netistä … … 201 230 { 202 231 // MessageBox.Show(mLine + " " + j + " " + i); 232 OwnershipMap[i, j] = -1; 203 233 TileOwnership[i, j].Shape = Shapes.Rectangle; 204 234 TileOwnership[i, j].X = (j * 48) - mapWidthJ; … … 211 241 } 212 242 243 // Initialisoidaan Shroudmap 244 245 for (i = 0; i <= (kartanKorkeus - 1); i++) 246 { 247 for (j = 0; j <= (kartanLeveys - 1); j++) 248 { 249 ShroudMap[i, j] = 1; 250 ShroudTile[i, j].Shape = Shapes.Rectangle; 251 ShroudTile[i, j].X = (j * 48) - mapWidthJ; 252 ShroudTile[i, j].Y = (i * 48) - mapHeightJ; 253 ShroudTile[i, j].Image = LoadImage(Textpath + "fogofwar"); 254 } 255 } 256 213 257 // Asettaa ja piirtää erikoismaaston 214 258 … … 218 262 for (j = 0; j <= (kartanLeveys - 1); j++) 219 263 { 220 // MessageBox.Show(mLine + " " + j + " " + i);221 264 DTile[i, j].Shape = Shapes.Rectangle; 222 265 DTile[i, j].X = (j * 48) - mapWidthJ; … … 229 272 DrawOwnership(i, j); 230 273 } 231 //MessageBox.Show(DTile[i, j].X + "x" + DTile[i, j].Y); 232 // MessageBox.Show(Convert.ToString(TerrainMap[i, j])); 233 } 234 } 274 } 275 } 276 277 // Piirretään ShroudTile vasta tässä, jotta se olisi DTilen päällä 278 for (i = 0; i <= (kartanKorkeus - 1); i++) 279 { 280 for (j = 0; j <= (kartanLeveys - 1); j++) 281 { 282 if (ShroudMap[i, j] == 1) 283 { 284 Add(ShroudTile[i, j]); 285 } 286 } 287 } 288 235 289 //catch 236 290 //{ … … 244 298 // Rules.pCivs[playernumber].Color = setAIOwnershipColor(playernumber); 245 299 //} 246 Rules.pCivs[0].HumanPlayer = true;247 Rules.pCivs[0].Color = "red";248 300 Level.BackgroundColor = Color.Black; 249 301 InitGUI(); 302 TurnSystem_Start(0); // Antaa pelin alkaa! 250 303 } 251 304 … … 256 309 TileDisp.Y = Screen.Bottom + 200; 257 310 TileDisp.TextColor = Color.White; 311 312 UnitStatsDisp = new TextDisplay(); 313 UnitStatsDisp.X = Screen.Left + 120; 314 UnitStatsDisp.Y = Screen.Bottom + 300; 315 UnitStatsDisp.Text = "d23"; 316 UnitStatsDisp.TextColor = Color.DarkRed; 317 318 ProductionDisp = new TextDisplay(); 319 ProductionDisp.X = Screen.Right - 150; 320 ProductionDisp.Y = Screen.Top - 50; 321 ProductionDisp.Text = "Tuotanto: 10/120"; 322 ProductionDisp.TextColor = Color.Wheat; 323 258 324 Add(TileDisp); 325 Add(UnitStatsDisp); 326 Add(ProductionDisp); 259 327 } 260 328 … … 275 343 if (tlayer == 1) { return DTerrainMap; } 276 344 if (tlayer == 2) { return OwnershipMap; } 345 if (tlayer == 3) { return ShroudMap; } 277 346 return TerrainMap; 278 347 } … … 294 363 if (tlayer == 1) {return DTile; } 295 364 if (tlayer == 2) { return TileOwnership; } 365 if (tlayer == 3) { return ShroudTile; } 296 366 return tile; 297 367 } … … 343 413 private void DrawOwnership(int i, int j) 344 414 { 345 TileOwnership[i, j].Image = LoadImage(OwnershipColorPath + Rules.pCivs[OwnershipMap[i, j]].Color); 346 Add(TileOwnership[i, j]); 415 if (ShroudMap[i, j] == 0) 416 { 417 TileOwnership[i, j].Image = LoadImage(OwnershipColorPath + Rules.pCivs[OwnershipMap[i, j]].Color); 418 Add(TileOwnership[i, j]); 419 } 347 420 //MessageBox.Show(TileOwnership[i, j].X + "x" + TileOwnership[i, j].Y + " " + DTile[i, j].X + "x" + DTile[i, j].Y + " Params: " + i + " " + j); 348 421 } … … 357 430 if (Rules.pCivs[playernumber].HumanPlayer == false) 358 431 { 359 Rules.pCivs[playernumber].Color = setAIOwnershipColor(playernumber); 360 Rules.pCivs[playernumber].Enabled = true; 361 Rules.pCivs[playernumber].Name = Rules.pCivs[playernumber].Color + " " + "Valtakunta"; 432 Rules.pCivs[playernumber].Color = setAIOwnershipColor(playernumber); 433 Rules.pCivs[playernumber].Enabled = true; 434 Rules.pCivs[playernumber].Name = Rules.pCivs[playernumber].Color + " " + "Empire"; 435 } 436 else 437 { 438 RemoveShroud(i, j); 439 for (int shri = i - 2; shri <= i + 2; shri++) 440 { 441 for (int shrj = j - 2; shrj <= j + 2; shrj++) 442 { 443 RemoveShroud(shri, shrj); 444 } 445 } 362 446 } 363 447 OwnershipMap[i, j] = playernumber; … … 393 477 public string getOwnershipColor_fromInt(Int32 color) 394 478 { 395 if (color == 0) { return " aqua"; }396 if (color == 1) { return " beige"; }397 if (color == 2) { return " limegreen"; }398 if (color == 3) { return " orange"; }399 if (color == 4) { return " black"; }400 if (color == 5) { return " red"; }401 if (color == 6) { return " rustred"; }402 if (color == 7) { return " yellow"; }403 if (color == 8) { return " blue"; }404 if (color == 9) { return " darkblue"; }405 if (color == 10) { return " darkgreen"; }406 if (color == 11) { return " lightblue"; }407 if (color == 12) { return " purple"; }408 if (color == 13) { return " darkpurple"; }409 if (color == 14) { return " lightpurple"; }410 if (color == 15) { return " gold"; }411 if (color == 16) { return " silver"; }412 if (color == 17) { return " pink"; }413 if (color == 18) { return " teal"; }414 if (color == 19) { return " greenyellow"; }415 if (color == 20) { return " darkorange"; }416 if (color == 21) { return " white"; }417 if (color == 22) { return " darkgray"; }418 return " aqua";479 if (color == 0) { return "Aqua"; } 480 if (color == 1) { return "Beige"; } 481 if (color == 2) { return "Limegreen"; } 482 if (color == 3) { return "Orange"; } 483 if (color == 4) { return "Black"; } 484 if (color == 5) { return "Red"; } 485 if (color == 6) { return "Rustred"; } 486 if (color == 7) { return "Yellow"; } 487 if (color == 8) { return "Blue"; } 488 if (color == 9) { return "Darkblue"; } 489 if (color == 10) { return "Darkgreen"; } 490 if (color == 11) { return "Lightblue"; } 491 if (color == 12) { return "Purple"; } 492 if (color == 13) { return "Darkpurple"; } 493 if (color == 14) { return "Lightpurple"; } 494 if (color == 15) { return "Gold"; } 495 if (color == 16) { return "Silver"; } 496 if (color == 17) { return "Pink"; } 497 if (color == 18) { return "Teal"; } 498 if (color == 19) { return "Greenyellow"; } 499 if (color == 20) { return "Darkorange"; } 500 if (color == 21) { return "White"; } 501 if (color == 22) { return "Darkgray"; } 502 return "Aqua"; 419 503 } 420 504 … … 433 517 if (terraintype == Vuoristo) { return Application.StartupPath + "\\Content\\Textures\\mountain"; } 434 518 if (terraintype == Havumetsa) { return Application.StartupPath + "\\Content\\Textures\\forest"; } 435 if (terraintype == Kuusimetsa) { return Application.StartupPath + "\\Content\\Textures\\spruceforest"; } 519 if (terraintype == Kuusimetsa) 520 { 521 if (TerrainMap[i, j] == 3) 522 { 523 return Application.StartupPath + "\\Content\\Textures\\spruceforestS"; 524 } 525 else 526 { 527 return Application.StartupPath + "\\Content\\Textures\\spruceforest"; 528 } 529 } 436 530 // Jos terraintype on 10 tai enemmän, ruudussa on pelaajan kaupunki (ks. getTerrainType) 437 531 if (terraintype >= 10) … … 460 554 BaseRules.Rules.InitDifficulty(); 461 555 BaseRules.Rules.InitCivs(); 556 BaseRules.Rules.InitAIBehaviour(); 557 } 558 559 private void RemoveShroud(int i, int j) 560 { 561 ShroudMap[i, j] = 0; 562 ShroudTile[i, j].Destroy(); 563 try 564 { 565 if (OwnershipMap[i, j] > -1) 566 { 567 DrawOwnership(i, j); 568 } 569 } 570 catch 571 { 572 } 573 } 574 575 private void TurnSystem_Start(int playernumber) 576 { 577 TurnNumber = TurnNumber + 1; 578 ProductionDisp.Text = "Vuoro: " + TurnNumber + Environment.NewLine + 579 "Tuotantoa vuorossa: " + Rules.pCivs[playernumber].Production + Environment.NewLine + 580 "Tuotantoa jäljellä: " + CurrProduction; 462 581 } 463 582 … … 535 654 tileinfo = tileinfo + Environment.NewLine + "Kuusimetsää"; 536 655 Defensebonus = Defensebonus + 25; 656 } 657 else 658 { 659 // MessageBox.Show(Convert.ToString(ShroudMap[i, j])); 660 if (ShroudMap[i, j] == 0) 661 { 662 try 663 { 664 if (OwnershipMap[i, j] >= -1) 665 { 666 tileinfo = tileinfo + Environment.NewLine + "Kaupunki"; 667 tileinfo = tileinfo + Environment.NewLine + Rules.pCivs[OwnershipMap[i, j]].Name; 668 } 669 } 670 catch 671 { 672 } 673 } 537 674 } 538 675 if (Defensebonus != 0) … … 579 716 } 580 717 581 private void Mouse_Move()582 {583 // MessageBox.Show(Mouse.PositionOnScreen.X);584 }585 586 718 private void MoveCamera(Int32 dir) 587 719 {
Note: See TracChangeset
for help on using the changeset viewer.