Changeset 869


Ignore:
Timestamp:
2010-06-15 15:00:31 (13 years ago)
Author:
ramipasa
Message:

Päivitetty ALTKCore.dll:ää (vaikeustasot ja tekoälyn käyttäytyminen) ja BaseRules?.dll:ää, pelissä voi nyt valita vaikeustasot (kuvat ovat väliaikaisia) ja kartan. Muitakin, pienempiä muutoksia.

Location:
2010/24/ramipasa/ALTKTileEngine
Files:
9 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2010/24/ramipasa/ALTKTileEngine/Content/Content.contentproj

    r838 r869  
    4040      <Importer>XImporter</Importer> 
    4141    </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> 
    4257  </ItemGroup> 
    4358  <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> 
    4681      <Importer>TextureImporter</Importer> 
    4782      <Processor>TextureProcessor</Processor> 
     
    5186      <Importer>TextureImporter</Importer> 
    5287      <Processor>TextureProcessor</Processor> 
    53       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 
    5488    </Compile> 
    55     <Compile Include="Textures\forest.png"> 
    56       <Name>forest</Name> 
     89    <Compile Include="Textures\spruceforest.png"> 
     90      <Name>spruceforest</Name> 
    5791      <Importer>TextureImporter</Importer> 
    5892      <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> 
    8093    </Compile> 
    8194    <Compile Include="Textures\tundra.jpg"> 
     
    8396      <Importer>TextureImporter</Importer> 
    8497      <Processor>TextureProcessor</Processor> 
    85       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 
    8698    </Compile> 
    8799  </ItemGroup> 
  • 2010/24/ramipasa/ALTKTileEngine/Peli.cs

    r838 r869  
    66using System.IO;                     // Streamreader vaatii tämän 
    77using System.Windows.Forms;          // jotta voin näyttää msgboxeja 
    8 using ALTKTechs; 
     8using ALTKTechs;                     // Avaruuslaatikon moottorikomponentit 
    99using ALTKUnits; 
    1010using ALTKCiv; 
    1111using ALTKPromotions; 
    12 using BaseRules; 
     12using ALTKDiff; 
     13using ALTKAIBehaviour; 
     14using BaseRules;                     // Avaruuslaatikon sääntötiedosto, helpottaa modien tekemistä 
    1315 
    1416namespace ALTKTileEngine 
     
    1618    public class Peli : Game 
    1719    { 
     20        bool gamestarted = false; 
     21         
    1822        //int[,] MapObjectCoords; 
    1923        int[,] TerrainMap; 
     
    2529        // Tämä sisältäisi tiedot yksiköiden omistajasta, yksikön perusyksiköstä ym. sekä myös karttakoordinaatit 
    2630        // (karttakoordinaatit säilyttää myös UnitMap, josta on helppo tarkastaa esim. liikuttaessa yksiköitä, onko ruudussa jo esim. vihollisyksiköitä. 
    27  
     31         
    2832        int kartanLeveys; 
    2933        int kartanKorkeus; 
     
    3640 
    3741        // 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; 
    4044        //Vector tileVector; 
    4145 
     
    4549        Vector CamSpeedSouth = new Vector(.0, -20.0); 
    4650 
     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; 
    4757        protected override void Begin() 
    4858        { 
    49             InitControls(); 
    5059            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         
    5396        # region Kartan luominen 
     97 
    5498        void InitMap() 
    5599        { 
     
    105149                    tile[i, j].X = (j * 48) - mapWidthJ; 
    106150                    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)); 
    109152                    Add(tile[i, j]); 
    110153                    // MessageBox.Show(Convert.ToString(TerrainMap[i, j])); 
     
    128171                    DTile[i, j].X = (j * 48) - mapWidthJ; 
    129172                    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)); 
    132174                    Add(DTile[i, j]); 
    133175                    // MessageBox.Show(Convert.ToString(TerrainMap[i, j])); 
     
    174216        } 
    175217 
    176         PhysicsObject[,] GetGraphicsLayer(int tlayer) 
     218        GameObject[,] GetGraphicsLayer(int tlayer) 
    177219        { 
    178220            if (tlayer == 0) {return tile; } 
     
    212254                    Playerstartloc = Convert.ToInt32(ch); 
    213255                    AddStartingCity(Playerstartloc, i, j); 
     256                    return (Playerstartloc + 10); 
    214257                } 
    215258                catch 
     
    223266        private void AddStartingCity(int playernumber, int i, int j) 
    224267        { 
     268            Rules.pCivs[playernumber].Enabled = true; 
    225269            Rules.pCivs[playernumber].Production = Rules.pCivs[playernumber].Production + 10; 
    226270            Rules.pCivs[playernumber].NumberofCities = Rules.pCivs[playernumber].NumberofCities + 1; 
    227271            Rules.pCivs[playernumber].CityCoords[Rules.pCivs[playernumber].NumberofCities, 0] = i; 
    228272            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) 
    233277        { 
    234278            if (terrainlayer == 0) 
     
    245289                if (terraintype == Havumetsa) { return Application.StartupPath + "\\Content\\Textures\\forest"; } 
    246290                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                } 
    247303                return Application.StartupPath + "\\Content\\Textures\\nothing"; 
    248304            } 
     
    259315        } 
    260316 
     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 
    261328        private void InitControls() 
    262329        { 
    263             Mouse.Enabled = true; 
    264             Mouse.IsCursorVisible = true; 
    265  
    266330            Keyboard.Listen(Key.Right, Jypeli.ButtonState.Down, MoveCamera, null, 0); 
    267331            Keyboard.Listen(Key.Left, Jypeli.ButtonState.Down, MoveCamera, null, 2); 
    268332            Keyboard.Listen(Key.Up, Jypeli.ButtonState.Down, MoveCamera, null, 1); 
    269333            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; 
    271343        } 
    272344 
     
    278350        private void MoveCamera(Int32 dir) 
    279351        { 
     352            if (gamestarted == false) { return; } 
    280353            if ((dir == 0) && (Camera.Position.X < (tile[kartanKorkeus - 1, kartanLeveys - 1].X) - (Peli.Screen.Width / 2))) 
    281354            { 
Note: See TracChangeset for help on using the changeset viewer.