Changeset 915


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

Uusia grafiikoita ja pelilogiikkaa (esim. Fog of War).

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

Legend:

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

    r895 r915  
    4040      <Importer>XImporter</Importer> 
    4141    </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> 
    4252    <Compile Include="Textures\Ownership\aqua.png"> 
    4353      <Name>aqua</Name> 
  • 2010/24/ramipasa/ALTKTileEngine/Peli.cs

    r900 r915  
    2424        int[,] DTerrainMap; // erikoismaastokartta 
    2525        int[,] OwnershipMap; // ruudukon omistuskartta (kenen pelaajan hallinnassa on mikäkin ruutu) 
     26        int[,] ShroudMap; // pelaajan näkymää pienentävä Shroudmap 
    2627 
    2728        string Textpath; 
    2829        string OwnershipColorPath; 
    2930 
    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 
    3235        // !!!!!!!!!!!!!!!!!!!!!!!!!!! 
    3336        // Pitänee tehdä vielä yksi ALTKSUnit-namespace ALTKCoreen. 
     
    3639 
    3740        TextDisplay TileDisp; 
     41        TextDisplay UnitStatsDisp; 
     42        TextDisplay ProductionDisp; 
    3843 
    3944        int kartanLeveys; 
     
    5055        GameObject[,] DTile; 
    5156        GameObject[,] TileOwnership; 
     57        GameObject[,] ShroudTile; 
    5258        //Vector tileVector; 
    5359 
     
    6268        int NegMouseScreenWidth; 
    6369        int NegMouseScreenHeight; 
     70        # region Aloitusruutuvalikko 
    6471        protected override void Begin() 
    6572        { 
     
    7481        void InitStartMenu() 
    7582        { 
     83            Level.BackgroundColor = Color.Gray; 
    7684            Mouse.Enabled = true; 
    7785            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); 
    7894 
    7995            GameObject TrainingButton = new GameObject(250, 30, Shapes.Rectangle); 
     
    104120        } 
    105121 
     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 
    106130        void SetDiffButton(GameObject diffbutton, int difflevel) 
    107131        { 
    108             diffbutton.X = -250; 
    109             diffbutton.Y = ((difflevel * -50) + 400); 
     132            diffbutton.X = 250; 
     133            diffbutton.Y = ((difflevel * -50) + 300); 
    110134            if (difflevel == 0) { diffbutton.Image = LoadImage(Textpath + "training"); } 
    111135            else if (difflevel == 1) { diffbutton.Image = LoadImage(Textpath + "easy"); } 
     
    128152            gamestarted = true; 
    129153        } 
    130          
     154        # endregion 
    131155        # region Kartan luominen 
    132156 
    133157        void InitMap() 
    134158        { 
     159            TurnNumber = new int(); 
    135160            AmountofPlayers = new int(); 
    136161            Int32 i; 
     
    158183            DTerrainMap = new int[kartanKorkeus, kartanLeveys]; 
    159184            OwnershipMap = new int[kartanKorkeus, kartanLeveys]; 
     185            ShroudMap = new int[kartanKorkeus, kartanLeveys]; 
    160186            InitTerrain(0); 
    161187            InitTerrain(1); 
    162188            InitTerrain(2); 
     189            InitTerrain(3); 
    163190 
    164191            tile = new GameObject[kartanKorkeus, kartanLeveys]; 
    165192            DTile = new GameObject[kartanKorkeus, kartanLeveys]; 
    166193            TileOwnership = new GameObject[kartanKorkeus, kartanLeveys]; 
     194            ShroudTile = new GameObject[kartanKorkeus, kartanLeveys]; 
    167195            InitTerrainGraphics(0); 
    168196            InitTerrainGraphics(1); 
    169197            InitTerrainGraphics(2); 
     198            InitTerrainGraphics(3); 
    170199 
    171200            // Koodi käännetty RGE:n VB.netistä 
     
    201230                { 
    202231                    // MessageBox.Show(mLine + " " + j + " " + i); 
     232                    OwnershipMap[i, j] = -1; 
    203233                    TileOwnership[i, j].Shape = Shapes.Rectangle; 
    204234                    TileOwnership[i, j].X = (j * 48) - mapWidthJ; 
     
    211241            } 
    212242 
     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 
    213257            // Asettaa ja piirtää erikoismaaston 
    214258 
     
    218262                for (j = 0; j <= (kartanLeveys - 1); j++) 
    219263                { 
    220                     // MessageBox.Show(mLine + " " + j + " " + i); 
    221264                    DTile[i, j].Shape = Shapes.Rectangle; 
    222265                    DTile[i, j].X = (j * 48) - mapWidthJ; 
     
    229272                        DrawOwnership(i, j); 
    230273                    } 
    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 
    235289            //catch 
    236290            //{ 
     
    244298            //    Rules.pCivs[playernumber].Color = setAIOwnershipColor(playernumber); 
    245299            //} 
    246             Rules.pCivs[0].HumanPlayer = true; 
    247             Rules.pCivs[0].Color = "red"; 
    248300            Level.BackgroundColor = Color.Black; 
    249301            InitGUI(); 
     302            TurnSystem_Start(0); // Antaa pelin alkaa! 
    250303        } 
    251304 
     
    256309            TileDisp.Y = Screen.Bottom + 200; 
    257310            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 
    258324            Add(TileDisp); 
     325            Add(UnitStatsDisp); 
     326            Add(ProductionDisp); 
    259327        } 
    260328 
     
    275343            if (tlayer == 1) { return DTerrainMap; } 
    276344            if (tlayer == 2) { return OwnershipMap; } 
     345            if (tlayer == 3) { return ShroudMap; } 
    277346            return TerrainMap; 
    278347        } 
     
    294363            if (tlayer == 1) {return DTile; } 
    295364            if (tlayer == 2) { return TileOwnership; } 
     365            if (tlayer == 3) { return ShroudTile; } 
    296366            return tile; 
    297367        } 
     
    343413        private void DrawOwnership(int i, int j) 
    344414        { 
    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            } 
    347420            //MessageBox.Show(TileOwnership[i, j].X + "x" + TileOwnership[i, j].Y + " " + DTile[i, j].X + "x" + DTile[i, j].Y + " Params: " + i + " " + j); 
    348421        } 
     
    357430            if (Rules.pCivs[playernumber].HumanPlayer == false) 
    358431            { 
    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                } 
    362446            } 
    363447            OwnershipMap[i, j] = playernumber; 
     
    393477        public string getOwnershipColor_fromInt(Int32 color) 
    394478        { 
    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"; 
    419503        } 
    420504 
     
    433517                if (terraintype == Vuoristo) { return Application.StartupPath + "\\Content\\Textures\\mountain"; } 
    434518                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                } 
    436530                // Jos terraintype on 10 tai enemmän, ruudussa on pelaajan kaupunki (ks. getTerrainType) 
    437531                if (terraintype >= 10) 
     
    460554            BaseRules.Rules.InitDifficulty(); 
    461555            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; 
    462581        } 
    463582 
     
    535654                tileinfo = tileinfo + Environment.NewLine + "Kuusimetsää"; 
    536655                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                } 
    537674            } 
    538675            if (Defensebonus != 0) 
     
    579716        } 
    580717 
    581         private void Mouse_Move() 
    582         { 
    583             // MessageBox.Show(Mouse.PositionOnScreen.X); 
    584         } 
    585  
    586718        private void MoveCamera(Int32 dir) 
    587719        { 
Note: See TracChangeset for help on using the changeset viewer.