Changeset 895
- Timestamp:
- 2010-06-16 10:31:32 (13 years ago)
- Location:
- 2010/24/ramipasa/ALTKTileEngine
- Files:
-
- 28 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/24/ramipasa/ALTKTileEngine/ALTKTileEngine.csproj
r838 r895 61 61 <HintPath>..\..\ALTKTechs\ALTKTechs\bin\Release\ALTKCore.dll</HintPath> 62 62 </Reference> 63 <Reference Include="BaseRules, Version=1.0.0. 0, Culture=neutral, processorArchitecture=MSIL">63 <Reference Include="BaseRules, Version=1.0.0.2, Culture=neutral, processorArchitecture=MSIL"> 64 64 <SpecificVersion>False</SpecificVersion> 65 65 <HintPath>..\..\BaseRules.dll</HintPath> 66 66 </Reference> 67 <Reference Include="Jypeli2, Version=2.1. 4.0, Culture=neutral, processorArchitecture=x86">67 <Reference Include="Jypeli2, Version=2.1.7.0, Culture=neutral, processorArchitecture=x86"> 68 68 <SpecificVersion>False</SpecificVersion> 69 69 <HintPath>..\..\..\..\lib\Jypeli2.dll</HintPath> -
2010/24/ramipasa/ALTKTileEngine/Content/Content.contentproj
r878 r895 40 40 <Importer>XImporter</Importer> 41 41 </Content> 42 <Compile Include="Textures\Ownership\aqua.png"> 43 <Name>aqua</Name> 44 <Importer>TextureImporter</Importer> 45 <Processor>TextureProcessor</Processor> 46 </Compile> 47 <Compile Include="Textures\Ownership\beige.png"> 48 <Name>beige</Name> 49 <Importer>TextureImporter</Importer> 50 <Processor>TextureProcessor</Processor> 51 </Compile> 52 <Compile Include="Textures\Ownership\black.png"> 53 <Name>black</Name> 54 <Importer>TextureImporter</Importer> 55 <Processor>TextureProcessor</Processor> 56 </Compile> 57 <Compile Include="Textures\Ownership\blue.png"> 58 <Name>blue</Name> 59 <Importer>TextureImporter</Importer> 60 <Processor>TextureProcessor</Processor> 61 </Compile> 62 <Compile Include="Textures\Ownership\darkblue.png"> 63 <Name>darkblue</Name> 64 <Importer>TextureImporter</Importer> 65 <Processor>TextureProcessor</Processor> 66 </Compile> 67 <Compile Include="Textures\Ownership\darkgreen.png"> 68 <Name>darkgreen</Name> 69 <Importer>TextureImporter</Importer> 70 <Processor>TextureProcessor</Processor> 71 </Compile> 72 <Compile Include="Textures\Ownership\darkorange.png"> 73 <Name>darkorange</Name> 74 <Importer>TextureImporter</Importer> 75 <Processor>TextureProcessor</Processor> 76 </Compile> 77 <Compile Include="Textures\Ownership\darkpurple.png"> 78 <Name>darkpurple</Name> 79 <Importer>TextureImporter</Importer> 80 <Processor>TextureProcessor</Processor> 81 </Compile> 82 <Compile Include="Textures\Ownership\default.png"> 83 <Name>default</Name> 84 <Importer>TextureImporter</Importer> 85 <Processor>TextureProcessor</Processor> 86 </Compile> 87 <Compile Include="Textures\Ownership\def_pohja.png"> 88 <Name>def_pohja</Name> 89 <Importer>TextureImporter</Importer> 90 <Processor>TextureProcessor</Processor> 91 </Compile> 92 <Compile Include="Textures\Ownership\gold.png"> 93 <Name>gold</Name> 94 <Importer>TextureImporter</Importer> 95 <Processor>TextureProcessor</Processor> 96 </Compile> 97 <Compile Include="Textures\Ownership\gray.png"> 98 <Name>gray</Name> 99 <Importer>TextureImporter</Importer> 100 <Processor>TextureProcessor</Processor> 101 </Compile> 102 <Compile Include="Textures\Ownership\greenyellow.png"> 103 <Name>greenyellow</Name> 104 <Importer>TextureImporter</Importer> 105 <Processor>TextureProcessor</Processor> 106 </Compile> 107 <Compile Include="Textures\Ownership\lightblue.png"> 108 <Name>lightblue</Name> 109 <Importer>TextureImporter</Importer> 110 <Processor>TextureProcessor</Processor> 111 </Compile> 112 <Compile Include="Textures\Ownership\lightpurple.png"> 113 <Name>lightpurple</Name> 114 <Importer>TextureImporter</Importer> 115 <Processor>TextureProcessor</Processor> 116 </Compile> 117 <Compile Include="Textures\Ownership\limegreen.png"> 118 <Name>limegreen</Name> 119 <Importer>TextureImporter</Importer> 120 <Processor>TextureProcessor</Processor> 121 </Compile> 122 <Compile Include="Textures\Ownership\none.png"> 123 <Name>none</Name> 124 <Importer>TextureImporter</Importer> 125 <Processor>TextureProcessor</Processor> 126 </Compile> 127 <Compile Include="Textures\Ownership\orange.png"> 128 <Name>orange</Name> 129 <Importer>TextureImporter</Importer> 130 <Processor>TextureProcessor</Processor> 131 </Compile> 132 <Compile Include="Textures\Ownership\pink.png"> 133 <Name>pink</Name> 134 <Importer>TextureImporter</Importer> 135 <Processor>TextureProcessor</Processor> 136 </Compile> 137 <Compile Include="Textures\Ownership\pohja.bmp"> 138 <Name>pohja</Name> 139 <Importer>TextureImporter</Importer> 140 <Processor>TextureProcessor</Processor> 141 </Compile> 142 <Compile Include="Textures\Ownership\purple.png"> 143 <Name>purple</Name> 144 <Importer>TextureImporter</Importer> 145 <Processor>TextureProcessor</Processor> 146 </Compile> 147 <Compile Include="Textures\Ownership\red.png"> 148 <Name>red</Name> 149 <Importer>TextureImporter</Importer> 150 <Processor>TextureProcessor</Processor> 151 </Compile> 152 <Compile Include="Textures\Ownership\rustred.png"> 153 <Name>rustred</Name> 154 <Importer>TextureImporter</Importer> 155 <Processor>TextureProcessor</Processor> 156 </Compile> 157 <Compile Include="Textures\Ownership\silver.png"> 158 <Name>silver</Name> 159 <Importer>TextureImporter</Importer> 160 <Processor>TextureProcessor</Processor> 161 </Compile> 162 <Compile Include="Textures\Ownership\teal.png"> 163 <Name>teal</Name> 164 <Importer>TextureImporter</Importer> 165 <Processor>TextureProcessor</Processor> 166 </Compile> 167 <Compile Include="Textures\Ownership\white.png"> 168 <Name>white</Name> 169 <Importer>TextureImporter</Importer> 170 <Processor>TextureProcessor</Processor> 171 </Compile> 172 <Compile Include="Textures\Ownership\yellow.png"> 173 <Name>yellow</Name> 174 <Importer>TextureImporter</Importer> 175 <Processor>TextureProcessor</Processor> 176 </Compile> 42 177 <Compile Include="Textures\easy.png"> 43 178 <Name>easy</Name> -
2010/24/ramipasa/ALTKTileEngine/Peli.cs
r878 r895 26 26 27 27 string Textpath; 28 28 string OwnershipColorPath; 29 30 int AmountofPlayers; 31 29 32 // !!!!!!!!!!!!!!!!!!!!!!!!!!! 30 33 // Pitänee tehdä vielä yksi ALTKSUnit-namespace ALTKCoreen. … … 44 47 GameObject[,] tile; 45 48 GameObject[,] DTile; 49 GameObject[,] TileOwnership; 46 50 //Vector tileVector; 47 51 … … 58 62 protected override void Begin() 59 63 { 64 //SetWindowSize(true); 60 65 Textpath = Application.StartupPath + "\\Content\\Textures\\"; 66 OwnershipColorPath = Textpath + "Ownership\\"; 61 67 InitRules(); 62 68 InitStartMenu(); … … 76 82 GameObject NightmareButton = new GameObject(250, 30, Shapes.Rectangle); 77 83 GameObject InsanityButton = new GameObject(250, 30, Shapes.Rectangle); 78 for (int a = 1; a <= 7; a++) 79 { 80 if (a == 1) { SetDiffButton(TrainingButton, 1); } 81 if (a == 2) { SetDiffButton(EasyButton, 2); } 82 if (a == 3) { SetDiffButton(NormalButton, 3); } 83 if (a == 4) { SetDiffButton(HardButton, 4); } 84 if (a == 5) { SetDiffButton(VHardButton, 5); } 85 if (a == 6) { SetDiffButton(NightmareButton, 6); } 86 if (a == 7) { SetDiffButton(InsanityButton, 7); } 87 } 88 Mouse.ListenOn(TrainingButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 1); 89 Mouse.ListenOn(EasyButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 2); 90 Mouse.ListenOn(NormalButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 3); 91 Mouse.ListenOn(HardButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 4); 92 Mouse.ListenOn(VHardButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 5); 93 Mouse.ListenOn(NightmareButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 6); 94 Mouse.ListenOn(InsanityButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 7); 84 85 for (int a = 0; a <= 6; a++) 86 { 87 if (a == 0) { SetDiffButton(TrainingButton, 0); } 88 if (a == 1) { SetDiffButton(EasyButton, 1); } 89 if (a == 2) { SetDiffButton(NormalButton, 2); } 90 if (a == 3) { SetDiffButton(HardButton, 3); } 91 if (a == 4) { SetDiffButton(VHardButton, 4); } 92 if (a == 5) { SetDiffButton(NightmareButton, 5); } 93 if (a == 6) { SetDiffButton(InsanityButton, 6); } 94 } 95 Mouse.ListenOn(TrainingButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 0); 96 Mouse.ListenOn(EasyButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 1); 97 Mouse.ListenOn(NormalButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 2); 98 Mouse.ListenOn(HardButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 3); 99 Mouse.ListenOn(VHardButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 4); 100 Mouse.ListenOn(NightmareButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 5); 101 Mouse.ListenOn(InsanityButton, MouseButton.Left, Jypeli.ButtonState.Down, SelectDifficulty, "", 6); 95 102 } 96 103 … … 99 106 diffbutton.X = -250; 100 107 diffbutton.Y = ((difflevel * -50) + 400); 101 if (difflevel == 1) { diffbutton.Image = LoadImage(Textpath + "training"); }102 else if (difflevel == 2) { diffbutton.Image = LoadImage(Textpath + "easy"); }103 else if (difflevel == 3) { diffbutton.Image = LoadImage(Textpath + "normal"); }104 else if (difflevel == 4) { diffbutton.Image = LoadImage(Textpath + "hard"); }105 else if (difflevel == 5) { diffbutton.Image = LoadImage(Textpath + "vhard"); }106 else if (difflevel == 6) { diffbutton.Image = LoadImage(Textpath + "nightmare"); }107 else if (difflevel == 7) { diffbutton.Image = LoadImage(Textpath + "insanity"); }108 if (difflevel == 0) { diffbutton.Image = LoadImage(Textpath + "training"); } 109 else if (difflevel == 1) { diffbutton.Image = LoadImage(Textpath + "easy"); } 110 else if (difflevel == 2) { diffbutton.Image = LoadImage(Textpath + "normal"); } 111 else if (difflevel == 3) { diffbutton.Image = LoadImage(Textpath + "hard"); } 112 else if (difflevel == 4) { diffbutton.Image = LoadImage(Textpath + "vhard"); } 113 else if (difflevel == 5) { diffbutton.Image = LoadImage(Textpath + "nightmare"); } 114 else if (difflevel == 6) { diffbutton.Image = LoadImage(Textpath + "insanity"); } 108 115 Add(diffbutton); 109 116 //return diffbutton; … … 112 119 void SelectDifficulty(int difflevel) 113 120 { 114 //ClearAll();121 ClearAll(); 115 122 currDiffLevel = new int(); 116 123 currDiffLevel = difflevel; … … 124 131 void InitMap() 125 132 { 126 //tileVector = new Vector(); 127 Int32 num; 133 AmountofPlayers = new int(); 128 134 Int32 i; 129 135 Int32 j; 130 136 string mLine; 131 //string chars;132 num = RandomGen.NextInt(1, 6);133 //chars = " VAT";134 137 TextReader bReader; 135 138 bReader = new StreamReader("Content\\Maps\\1\\base.txt"); … … 157 160 InitTerrain(2); 158 161 159 tile = new PhysicsObject[kartanKorkeus, kartanLeveys]; 160 DTile = new PhysicsObject[kartanKorkeus, kartanLeveys]; 162 tile = new GameObject[kartanKorkeus, kartanLeveys]; 163 DTile = new GameObject[kartanKorkeus, kartanLeveys]; 164 TileOwnership = new GameObject[kartanKorkeus, kartanLeveys]; 161 165 InitTerrainGraphics(0); 162 166 InitTerrainGraphics(1); 167 InitTerrainGraphics(2); 163 168 164 169 // Koodi käännetty RGE:n VB.netistä … … 171 176 { 172 177 // MessageBox.Show(mLine + " " + j + " " + i); 173 TerrainMap[i, j] = getTerrainType(mLine.Substring(j, 1), 0, i, j);174 178 tile[i, j].Shape = Shapes.Rectangle; 175 179 tile[i, j].X = (j * 48) - mapWidthJ; 176 180 tile[i, j].Y = (i * 48) - mapHeightJ; 181 TerrainMap[i, j] = getTerrainType(mLine.Substring(j, 1), 0, i, j); 177 182 tile[i, j].Image = LoadImage(getTexture_fromTerrainType(TerrainMap[i, j], 0, i, j)); 178 183 Add(tile[i, j]); … … 185 190 bReader.ReadLine(); 186 191 192 // Rami 16. 6. 2010: Omistuskartta pitää sittenkin säätää ennen erikoismaastoa, sillä 193 // kaupungit ja omistusrinki piirretään erikoismaaston asettamiskoodin kutsusta 194 for (i = 0; i <= (kartanKorkeus - 1); i++) 195 { 196 for (j = 0; j <= (kartanLeveys - 1); j++) 197 { 198 // MessageBox.Show(mLine + " " + j + " " + i); 199 TileOwnership[i, j].Shape = Shapes.Rectangle; 200 TileOwnership[i, j].X = (j * 48) - mapWidthJ; 201 TileOwnership[i, j].Y = (i * 48) - mapHeightJ; 202 //TileOwnership[i, j].Image = LoadImage(Textpath + "nothing"); poistettu optimisoinnin takia 203 //Add(TileOwnership[i, j]); eihän näitä tarvitse vielä lisätä, optimisointia 204 //MessageBox.Show(TileOwnership[i, j].X + "x" + TileOwnership[i, j].Y + " " + DTile[i, j].X + "x" + DTile[i, j].Y + " Params: " + i + " " + j); 205 // MessageBox.Show(Convert.ToString(TerrainMap[i, j])); 206 } 207 } 208 187 209 // Asettaa ja piirtää erikoismaaston 188 210 … … 193 215 { 194 216 // MessageBox.Show(mLine + " " + j + " " + i); 195 DTerrainMap[i, j] = getTerrainType(mLine.Substring(j, 1), 1, i, j);196 217 DTile[i, j].Shape = Shapes.Rectangle; 197 218 DTile[i, j].X = (j * 48) - mapWidthJ; 198 219 DTile[i, j].Y = (i * 48) - mapHeightJ; 220 DTerrainMap[i, j] = getTerrainType(mLine.Substring(j, 1), 1, i, j); 199 221 DTile[i, j].Image = LoadImage(getTexture_fromTerrainType(DTerrainMap[i, j], 1, i, j)); 200 222 Add(DTile[i, j]); 223 if (getTexture_fromTerrainType(DTerrainMap[i, j], 1, i, j).Contains("city")) 224 { 225 DrawOwnership(i, j); 226 } 227 //MessageBox.Show(DTile[i, j].X + "x" + DTile[i, j].Y); 201 228 // MessageBox.Show(Convert.ToString(TerrainMap[i, j])); 202 229 } … … 209 236 //} 210 237 bReader.Close(); 238 //for (int playernumber = 0; playernumber <= 30; playernumber++) 239 //{ 240 // Rules.pCivs[playernumber].Color = setAIOwnershipColor(playernumber); 241 //} 242 Rules.pCivs[0].HumanPlayer = true; 243 Rules.pCivs[0].Color = "red"; 211 244 Level.BackgroundColor = Color.Black; 212 245 } … … 246 279 if (tlayer == 0) {return tile; } 247 280 if (tlayer == 1) {return DTile; } 281 if (tlayer == 2) { return TileOwnership; } 248 282 return tile; 249 283 } … … 277 311 try 278 312 { 313 //MessageBox.Show(TileOwnership[i, j].X + "x" + TileOwnership[i, j].Y + " " + DTile[i, j].X + "x" + DTile[i, j].Y + " Params: " + i + " " + j); 279 314 int Playerstartloc; 280 315 Playerstartloc = Convert.ToInt32(ch); 316 AmountofPlayers = AmountofPlayers + 1; 281 317 AddStartingCity(Playerstartloc, i, j); 282 318 return (Playerstartloc + 10); … … 290 326 } 291 327 328 private void DrawOwnership(int i, int j) 329 { 330 TileOwnership[i, j].Image = LoadImage(OwnershipColorPath + Rules.pCivs[OwnershipMap[i, j]].Color); 331 Add(TileOwnership[i, j]); 332 //MessageBox.Show(TileOwnership[i, j].X + "x" + TileOwnership[i, j].Y + " " + DTile[i, j].X + "x" + DTile[i, j].Y + " Params: " + i + " " + j); 333 } 334 292 335 private void AddStartingCity(int playernumber, int i, int j) 293 336 { 294 Rules.pCivs[playernumber].Enabled = true;337 //MessageBox.Show(TileOwnership[i, j].X + "x" + TileOwnership[i, j].Y + " " + DTile[i, j].X + "x" + DTile[i, j].Y + " Params: " + i + " " + j); 295 338 Rules.pCivs[playernumber].Production = Rules.pCivs[playernumber].Production + 10; 296 339 Rules.pCivs[playernumber].NumberofCities = Rules.pCivs[playernumber].NumberofCities + 1; 297 340 Rules.pCivs[playernumber].CityCoords[Rules.pCivs[playernumber].NumberofCities, 0] = i; 298 341 Rules.pCivs[playernumber].CityCoords[Rules.pCivs[playernumber].NumberofCities, 1] = j; 299 //DTile[i, j].Image.Name = "\\Content\\Textures\\cityancient"; 342 if (Rules.pCivs[playernumber].HumanPlayer == false) 343 { 344 Rules.pCivs[playernumber].Color = setAIOwnershipColor(playernumber); 345 Rules.pCivs[playernumber].Enabled = true; 346 } 347 OwnershipMap[i, j] = playernumber; 348 // 16. 6. 2010: Kutsutaanpa DrawOwnership sittenkin vasta kaupungin piirtämisen jälkeen (ks. InitMap ja DTilen asettaminen) 349 //DrawOwnership(i, j); 350 351 //DTile[i, j].Image = LoadImage("\\Content\\Textures\\cityancient"); 352 } 353 354 public string setAIOwnershipColor(int playernumber) 355 { 356 int c; 357 int b; 358 bool ColorInUse = false; 359 for (b = 0; b <= 20; b++) 360 { 361 ColorInUse = false; 362 for (c = 0; c <= 30; c++) 363 { 364 if (Rules.pCivs[c].Color == getOwnershipColor_fromInt(b)) 365 { 366 ColorInUse = true; 367 } 368 } 369 if (ColorInUse == false) 370 { 371 return getOwnershipColor_fromInt(b); 372 } 373 } 374 return getOwnershipColor_fromInt(0); 375 } 376 377 public string getOwnershipColor_fromInt(Int32 color) 378 { 379 if (color == 0) { return "aqua"; } 380 if (color == 1) { return "beige"; } 381 if (color == 2) { return "limegreen"; } 382 if (color == 3) { return "orange"; } 383 if (color == 4) { return "black"; } 384 if (color == 5) { return "red"; } 385 if (color == 6) { return "rustred"; } 386 if (color == 7) { return "yellow"; } 387 if (color == 8) { return "blue"; } 388 if (color == 9) { return "darkblue"; } 389 if (color == 10) { return "darkgreen"; } 390 if (color == 11) { return "lightblue"; } 391 if (color == 12) { return "purple"; } 392 if (color == 13) { return "darkpurple"; } 393 if (color == 14) { return "lightpurple"; } 394 if (color == 15) { return "gold"; } 395 if (color == 16) { return "silver"; } 396 if (color == 17) { return "pink"; } 397 if (color == 18) { return "teal"; } 398 if (color == 19) { return "greenyellow"; } 399 if (color == 20) { return "darkorange"; } 400 if (color == 21) { return "white"; } 401 if (color == 22) { return "darkgray"; } 402 return "aqua"; 300 403 } 301 404 … … 321 424 { 322 425 return Application.StartupPath + "\\Content\\Textures\\cityancientTundra"; 426 //DrawOwnership(i, j); 323 427 } 324 428 else … … 338 442 BaseRules.Rules.InitTechs(); 339 443 BaseRules.Rules.InitUnits(); 444 BaseRules.Rules.InitDifficulty(); 340 445 BaseRules.Rules.InitCivs(); 341 446 } … … 358 463 Keyboard.Listen(Key.Up, Jypeli.ButtonState.Down, MoveCamera, null, 1); 359 464 Keyboard.Listen(Key.Down, Jypeli.ButtonState.Down, MoveCamera, null, 3); 465 Keyboard.Listen(Key.Tab, Jypeli.ButtonState.Down, ActivateDebug, null, 0); 360 466 361 467 MouseScreenWidth = new int(); … … 369 475 } 370 476 477 private void ActivateDebug(int asd) 478 { 479 //Add(MessageDisplay); 480 MessageDisplay.Add("DEBUG MODE ACTIVATED"); 481 Keyboard.Listen(Key.A, Jypeli.ButtonState.Down, ShowColors, null); 482 } 483 484 private void ShowColors() 485 { 486 for (int a = 0; a <= (AmountofPlayers - 1); a++) 487 { 488 MessageDisplay.Add("Pelaaja: " + a + "; " + Rules.pCivs[a].Color); 489 } 490 } 491 371 492 private void Mouse_Move() 372 493 { … … 377 498 { 378 499 if (gamestarted == false) { return; } 379 if ((dir == 0) && (Camera.Position.X < (tile[kartanKorkeus - 1, kartanLeveys - 1].X) - (Peli.Screen.Width / 2)))500 if ((dir == 0) && (Camera.Position.X < (tile[kartanKorkeus - 1, kartanLeveys - 1].X) - (Peli.Screen.Width / 2))) 380 501 { 381 502 Camera.Move(CamSpeedEast);
Note: See TracChangeset
for help on using the changeset viewer.