Changeset 869
- Timestamp:
- 2010-06-15 15:00:31 (13 years ago)
- Location:
- 2010/24/ramipasa/ALTKTileEngine
- Files:
-
- 9 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/24/ramipasa/ALTKTileEngine/Content/Content.contentproj
r838 r869 40 40 <Importer>XImporter</Importer> 41 41 </Content> 42 <Compile Include="Textures\cityancientTundra.png"> 43 <Name>cityancientTundra</Name> 44 <Importer>TextureImporter</Importer> 45 <Processor>TextureProcessor</Processor> 46 </Compile> 47 <Compile Include="Textures\dirt.jpg"> 48 <Name>dirt</Name> 49 <Importer>TextureImporter</Importer> 50 <Processor>TextureProcessor</Processor> 51 </Compile> 52 <Compile Include="Textures\plain.jpg"> 53 <Name>plain</Name> 54 <Importer>TextureImporter</Importer> 55 <Processor>TextureProcessor</Processor> 56 </Compile> 42 57 </ItemGroup> 43 58 <ItemGroup> 44 <Compile Include="Textures\spruceforest.png"> 45 <Name>spruceforest</Name> 59 <Compile Include="Textures\cityancient.png"> 60 <Name>cityancient</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 </Compile> 64 <Compile Include="Textures\desert.jpg"> 65 <Name>desert</Name> 66 <Importer>TextureImporter</Importer> 67 <Processor>TextureProcessor</Processor> 68 </Compile> 69 <Compile Include="Textures\forest.png"> 70 <Name>forest</Name> 71 <Importer>TextureImporter</Importer> 72 <Processor>TextureProcessor</Processor> 73 </Compile> 74 <Compile Include="Textures\grassland.jpg"> 75 <Name>grassland</Name> 76 <Importer>TextureImporter</Importer> 77 <Processor>TextureProcessor</Processor> 78 </Compile> 79 <Compile Include="Textures\mountain.png"> 80 <Name>mountain</Name> 46 81 <Importer>TextureImporter</Importer> 47 82 <Processor>TextureProcessor</Processor> … … 51 86 <Importer>TextureImporter</Importer> 52 87 <Processor>TextureProcessor</Processor> 53 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>54 88 </Compile> 55 <Compile Include="Textures\ forest.png">56 <Name> forest</Name>89 <Compile Include="Textures\spruceforest.png"> 90 <Name>spruceforest</Name> 57 91 <Importer>TextureImporter</Importer> 58 92 <Processor>TextureProcessor</Processor> 59 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>60 </Compile>61 <Compile Include="Textures\mountain.png">62 <Name>mountain</Name>63 <Importer>TextureImporter</Importer>64 <Processor>TextureProcessor</Processor>65 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>66 </Compile>67 </ItemGroup>68 <ItemGroup>69 <Compile Include="Textures\grassland.jpg">70 <Name>grassland</Name>71 <Importer>TextureImporter</Importer>72 <Processor>TextureProcessor</Processor>73 <CopyToOutputDirectory>Always</CopyToOutputDirectory>74 </Compile>75 <Compile Include="Textures\desert.jpg">76 <Name>desert</Name>77 <Importer>TextureImporter</Importer>78 <Processor>TextureProcessor</Processor>79 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>80 93 </Compile> 81 94 <Compile Include="Textures\tundra.jpg"> … … 83 96 <Importer>TextureImporter</Importer> 84 97 <Processor>TextureProcessor</Processor> 85 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>86 98 </Compile> 87 99 </ItemGroup> -
2010/24/ramipasa/ALTKTileEngine/Peli.cs
r838 r869 6 6 using System.IO; // Streamreader vaatii tämän 7 7 using System.Windows.Forms; // jotta voin näyttää msgboxeja 8 using ALTKTechs; 8 using ALTKTechs; // Avaruuslaatikon moottorikomponentit 9 9 using ALTKUnits; 10 10 using ALTKCiv; 11 11 using ALTKPromotions; 12 using BaseRules; 12 using ALTKDiff; 13 using ALTKAIBehaviour; 14 using BaseRules; // Avaruuslaatikon sääntötiedosto, helpottaa modien tekemistä 13 15 14 16 namespace ALTKTileEngine … … 16 18 public class Peli : Game 17 19 { 20 bool gamestarted = false; 21 18 22 //int[,] MapObjectCoords; 19 23 int[,] TerrainMap; … … 25 29 // Tämä sisältäisi tiedot yksiköiden omistajasta, yksikön perusyksiköstä ym. sekä myös karttakoordinaatit 26 30 // (karttakoordinaatit säilyttää myös UnitMap, josta on helppo tarkastaa esim. liikuttaessa yksiköitä, onko ruudussa jo esim. vihollisyksiköitä. 27 31 28 32 int kartanLeveys; 29 33 int kartanKorkeus; … … 36 40 37 41 // Pelissä on kaksi eri tasoa, toisella perusmaasto ja toisella tarkempaa tietoa (esim. onko ruutu metsää ym.) 38 PhysicsObject[,] tile;39 PhysicsObject[,] DTile;42 GameObject[,] tile; 43 GameObject[,] DTile; 40 44 //Vector tileVector; 41 45 … … 45 49 Vector CamSpeedSouth = new Vector(.0, -20.0); 46 50 51 // Käytän ennemmin enemmän RAM-muistia kuin prosessoria, joten lasken nämä jo täällä 52 53 int MouseScreenWidth; 54 int MouseScreenHeight; 55 int NegMouseScreenWidth; 56 int NegMouseScreenHeight; 47 57 protected override void Begin() 48 58 { 49 InitControls();50 59 InitRules(); 51 InitMap(); 52 } 60 InitStartMenu(); 61 //InitControls(); 62 //InitMap(); 63 } 64 void InitStartMenu() 65 { 66 Mouse.Enabled = true; 67 Mouse.IsCursorVisible = true; 68 69 GameObject TrainingButton = new GameObject(250, 30, Shapes.Rectangle); 70 GameObject EasyButton = new GameObject(250, 30, Shapes.Rectangle); 71 GameObject NormalButton = new GameObject(250, 30, Shapes.Rectangle); 72 GameObject HardButton = new GameObject(250, 30, Shapes.Rectangle); 73 GameObject VHardButton = new GameObject(250, 30, Shapes.Rectangle); 74 GameObject NightmareButton = new GameObject(250, 30, Shapes.Rectangle); 75 GameObject InsanityButton = new GameObject(250, 30, Shapes.Rectangle); 76 for (int a = 1; a <= 7; a++) 77 { 78 if (a == 1) { SetDiffButton(TrainingButton, 1); } 79 if (a == 2) { SetDiffButton(EasyButton, 2); } 80 if (a == 3) { SetDiffButton(NormalButton, 3); } 81 if (a == 4) { SetDiffButton(HardButton, 4); } 82 if (a == 5) { SetDiffButton(VHardButton, 5); } 83 if (a == 6) { SetDiffButton(NightmareButton, 6); } 84 if (a == 7) { SetDiffButton(InsanityButton, 7); } 85 } 86 } 87 88 void SetDiffButton(GameObject diffbutton, int difflevel) 89 { 90 diffbutton.X = -250; 91 diffbutton.Y = (difflevel * 50); 92 Add(diffbutton); 93 //return diffbutton; 94 } 95 53 96 # region Kartan luominen 97 54 98 void InitMap() 55 99 { … … 105 149 tile[i, j].X = (j * 48) - mapWidthJ; 106 150 tile[i, j].Y = (i * 48) - mapHeightJ; 107 tile[i, j].Restitution = 0.0; 108 tile[i, j].Image = LoadImage(getTexture_fromTerrainType(TerrainMap[i, j], 0)); 151 tile[i, j].Image = LoadImage(getTexture_fromTerrainType(TerrainMap[i, j], 0, i, j)); 109 152 Add(tile[i, j]); 110 153 // MessageBox.Show(Convert.ToString(TerrainMap[i, j])); … … 128 171 DTile[i, j].X = (j * 48) - mapWidthJ; 129 172 DTile[i, j].Y = (i * 48) - mapHeightJ; 130 DTile[i, j].Restitution = 0.0; 131 DTile[i, j].Image = LoadImage(getTexture_fromTerrainType(DTerrainMap[i, j], 1)); 173 DTile[i, j].Image = LoadImage(getTexture_fromTerrainType(DTerrainMap[i, j], 1, i, j)); 132 174 Add(DTile[i, j]); 133 175 // MessageBox.Show(Convert.ToString(TerrainMap[i, j])); … … 174 216 } 175 217 176 PhysicsObject[,] GetGraphicsLayer(int tlayer)218 GameObject[,] GetGraphicsLayer(int tlayer) 177 219 { 178 220 if (tlayer == 0) {return tile; } … … 212 254 Playerstartloc = Convert.ToInt32(ch); 213 255 AddStartingCity(Playerstartloc, i, j); 256 return (Playerstartloc + 10); 214 257 } 215 258 catch … … 223 266 private void AddStartingCity(int playernumber, int i, int j) 224 267 { 268 Rules.pCivs[playernumber].Enabled = true; 225 269 Rules.pCivs[playernumber].Production = Rules.pCivs[playernumber].Production + 10; 226 270 Rules.pCivs[playernumber].NumberofCities = Rules.pCivs[playernumber].NumberofCities + 1; 227 271 Rules.pCivs[playernumber].CityCoords[Rules.pCivs[playernumber].NumberofCities, 0] = i; 228 272 Rules.pCivs[playernumber].CityCoords[Rules.pCivs[playernumber].NumberofCities, 1] = j; 229 230 } 231 232 string getTexture_fromTerrainType(int terraintype, int terrainlayer )273 //DTile[i, j].Image.Name = "\\Content\\Textures\\cityancient"; 274 } 275 276 string getTexture_fromTerrainType(int terraintype, int terrainlayer, int i, int j) 233 277 { 234 278 if (terrainlayer == 0) … … 245 289 if (terraintype == Havumetsa) { return Application.StartupPath + "\\Content\\Textures\\forest"; } 246 290 if (terraintype == Kuusimetsa) { return Application.StartupPath + "\\Content\\Textures\\spruceforest"; } 291 // Jos terraintype on 10 tai enemmän, ruudussa on pelaajan kaupunki (ks. getTerrainType) 292 if (terraintype >= 10) 293 { 294 if (TerrainMap[i, j] == Tundra) 295 { 296 return Application.StartupPath + "\\Content\\Textures\\cityancientTundra"; 297 } 298 else 299 { 300 return Application.StartupPath + "\\Content\\Textures\\cityancient"; 301 } 302 } 247 303 return Application.StartupPath + "\\Content\\Textures\\nothing"; 248 304 } … … 259 315 } 260 316 317 protected override void Update(Time time) 318 { 319 base.Update(time); 320 // Mouse.PositionOnScreen voisi olla vain positiivinen, eikä ruudun pitäisi jakautua keskeltä kahtia 321 // negatiivisiin ja positiivisiin kokonaislukuihin 322 if (Mouse.PositionOnScreen.X > MouseScreenWidth) { MoveCamera(0); } 323 else if (Mouse.PositionOnScreen.X < NegMouseScreenWidth) { MoveCamera(2); } 324 else if (Mouse.PositionOnScreen.Y > MouseScreenHeight) { MoveCamera(1); } 325 else if (Mouse.PositionOnScreen.Y < NegMouseScreenHeight) { MoveCamera(3); } 326 } 327 261 328 private void InitControls() 262 329 { 263 Mouse.Enabled = true;264 Mouse.IsCursorVisible = true;265 266 330 Keyboard.Listen(Key.Right, Jypeli.ButtonState.Down, MoveCamera, null, 0); 267 331 Keyboard.Listen(Key.Left, Jypeli.ButtonState.Down, MoveCamera, null, 2); 268 332 Keyboard.Listen(Key.Up, Jypeli.ButtonState.Down, MoveCamera, null, 1); 269 333 Keyboard.Listen(Key.Down, Jypeli.ButtonState.Down, MoveCamera, null, 3); 270 // Mouse.ListenMovement(1, Mouse_Move, ""); 334 335 MouseScreenWidth = new int(); 336 MouseScreenWidth = Convert.ToInt32(Peli.Screen.Width / 2) - 5; 337 MouseScreenHeight = new int(); 338 MouseScreenHeight = Convert.ToInt32(Peli.Screen.Height / 2) - 5; 339 NegMouseScreenWidth = new int(); 340 NegMouseScreenWidth = Convert.ToInt32(Peli.Screen.Width / -2) + 5; 341 NegMouseScreenHeight = new int(); 342 NegMouseScreenHeight = Convert.ToInt32(Peli.Screen.Height / -2) + 20; 271 343 } 272 344 … … 278 350 private void MoveCamera(Int32 dir) 279 351 { 352 if (gamestarted == false) { return; } 280 353 if ((dir == 0) && (Camera.Position.X < (tile[kartanKorkeus - 1, kartanLeveys - 1].X) - (Peli.Screen.Width / 2))) 281 354 {
Note: See TracChangeset
for help on using the changeset viewer.