Example #1
0
        internal static void Main()
        {
            //check if we are in the right place...
            if (!System.IO.Directory.Exists(Application.StartupPath + "\\Data"))
            {
                MessageBox.Show("Run Editor from inside the Client folder!");
                ProjectData.EndApp();
            }

            if (E_Globals.GameStarted == true)
            {
                return;
            }

            SFML.Portable.Activate();

            //Strings.Init(1, "English")

            ClientDataBase.ClearTempTile();

            // set values for directional blocking arrows
            E_Globals.DirArrowX[1] = (byte)12;             // up
            E_Globals.DirArrowY[1] = (byte)0;
            E_Globals.DirArrowX[2] = (byte)12;             // down
            E_Globals.DirArrowY[2] = (byte)23;
            E_Globals.DirArrowX[3] = (byte)0;              // left
            E_Globals.DirArrowY[3] = (byte)12;
            E_Globals.DirArrowX[4] = (byte)23;             // right
            E_Globals.DirArrowY[4] = (byte)12;

            ClientDataBase.CheckTilesets();
            ClientDataBase.CheckCharacters();
            ClientDataBase.CheckPaperdolls();
            ClientDataBase.CheckAnimations();
            E_Items.CheckItems();
            ClientDataBase.CheckResources();
            ClientDataBase.CheckSkillIcons();
            ClientDataBase.CheckFaces();
            ClientDataBase.CheckFog();
            ClientDataBase.CacheMusic();
            ClientDataBase.CacheSound();

            E_Housing.CheckFurniture();
            E_Projectiles.CheckProjectiles();

            E_Graphics.InitGraphics();

            E_AutoTiles.Autotile = new E_AutoTiles.AutotileRec[E_Types.Map.MaxX + 1, E_Types.Map.MaxY + 1];

            for (var X = 0; X <= E_Types.Map.MaxX; X++)
            {
                for (var Y = 0; Y <= E_Types.Map.MaxY; Y++)
                {
                    E_AutoTiles.Autotile[(int)X, (int)Y].Layer = new E_AutoTiles.QuarterTileRec[(int)Enums.LayerType.Count];
                    for (var i = 0; i <= (int)Enums.LayerType.Count - 1; i++)
                    {
                        E_AutoTiles.Autotile[(int)X, (int)Y].Layer[(int)i].srcX        = new int[5];
                        E_AutoTiles.Autotile[(int)X, (int)Y].Layer[(int)i].srcY        = new int[5];
                        E_AutoTiles.Autotile[(int)X, (int)Y].Layer[(int)i].QuarterTile = new E_AutoTiles.PointRec[5];
                    }
                }
            }

            //'Housing
            E_Housing.House       = new E_Housing.HouseRec[E_Housing.MAX_HOUSES + 1];
            E_Housing.HouseConfig = new E_Housing.HouseRec[E_Housing.MAX_HOUSES + 1];

            //quests
            E_Quest.Quest = new E_Quest.QuestRec[E_Quest.MAX_QUESTS + 1];
            E_Quest.ClearQuests();

            E_Types.Map.Npc = new int[Constants.MAX_MAP_NPCS + 1];

            Types.Item = new Types.ItemRec[Constants.MAX_ITEMS + 1];
            for (var i = 0; i <= Constants.MAX_ITEMS; i++)
            {
                for (var x = 0; x <= (int)Enums.StatType.Count - 1; x++)
                {
                    Types.Item[(int)i].Add_Stat = new byte[(int)x + 1];
                }
                for (var x = 0; x <= (int)Enums.StatType.Count - 1; x++)
                {
                    Types.Item[(int)i].Stat_Req = new byte[(int)x + 1];
                }

                Types.Item[(int)i].FurnitureBlocks = new int[4, 4];
                Types.Item[(int)i].FurnitureFringe = new int[4, 4];
            }

            Types.Npc = new Types.NpcRec[Constants.MAX_NPCS + 1];
            for (var i = 0; i <= Constants.MAX_NPCS; i++)
            {
                for (var x = 0; x <= (int)Enums.StatType.Count - 1; x++)
                {
                    Types.Npc[(int)i].Stat = new byte[(int)x + 1];
                }

                Types.Npc[(int)i].DropChance    = new int[6];
                Types.Npc[(int)i].DropItem      = new int[6];
                Types.Npc[(int)i].DropItemValue = new int[6];

                Types.Npc[(int)i].Skill = new byte[7];
            }

            E_Types.MapNpc = new E_Types.MapNpcRec[Constants.MAX_MAP_NPCS + 1];
            for (var i = 0; i <= Constants.MAX_MAP_NPCS; i++)
            {
                for (var x = 0; x <= (int)Enums.VitalType.Count - 1; x++)
                {
                    E_Types.MapNpc[(int)i].Vital = new int[(int)x + 1];
                }
            }

            Types.Shop = new Types.ShopRec[Constants.MAX_SHOPS + 1];
            for (var i = 0; i <= Constants.MAX_SHOPS; i++)
            {
                for (var x = 0; x <= Constants.MAX_TRADES; x++)
                {
                    Types.Shop[(int)i].TradeItem = new Types.TradeItemRec[(int)x + 1];
                }
            }

            Types.Animation = new Types.AnimationRec[Constants.MAX_ANIMATIONS + 1];
            for (var i = 0; i <= Constants.MAX_ANIMATIONS; i++)
            {
                for (var x = 0; x <= 1; x++)
                {
                    Types.Animation[(int)i].Sprite = new int[(int)x + 1];
                }
                for (var x = 0; x <= 1; x++)
                {
                    Types.Animation[(int)i].Frames = new int[(int)x + 1];
                }
                for (var x = 0; x <= 1; x++)
                {
                    Types.Animation[(int)i].LoopCount = new int[(int)x + 1];
                }
                for (var x = 0; x <= 1; x++)
                {
                    Types.Animation[(int)i].LoopTime = new int[(int)x + 1];
                }
            }

            //craft
            E_Crafting.ClearRecipes();

            //pets
            E_Pets.ClearPets();

            // load options
            if (File.Exists(Application.StartupPath + "\\Data\\Config.xml"))
            {
                LoadOptions();
            }
            else
            {
                CreateOptions();
            }

            E_NetworkConfig.InitNetwork();

            E_Globals.GameDestroyed = false;
            E_Globals.GameStarted   = true;

            FrmLogin.Default.Visible = true;

            GameLoop();
        }
Example #2
0
        public void BtnSetSize_Click(object sender, EventArgs e)
        {
            int X  = 0;
            int x2 = 0;
            int i  = 0;
            int Y  = 0;
            int y2 = 0;

            Types.TileRec[,] tempArr;

            if (nudMaxX.Value < E_Globals.SCREEN_MAPX)
            {
                nudMaxX.Value = E_Globals.SCREEN_MAPX;
            }
            if (nudMaxY.Value < E_Globals.SCREEN_MAPY)
            {
                nudMaxY.Value = E_Globals.SCREEN_MAPY;
            }

            E_Globals.GettingMap = true;

            // set the data before changing it
            tempArr = new Types.TileRec[E_Types.Map.MaxX + 1, E_Types.Map.MaxY + 1];
            for (X = 0; X <= E_Types.Map.MaxX; X++)
            {
                for (Y = 0; Y <= E_Types.Map.MaxY; Y++)
                {
                    tempArr[X, Y].Layer = new Types.TileDataRec[(int)Enums.LayerType.Count];

                    tempArr[X, Y].Data1    = E_Types.Map.Tile[X, Y].Data1;
                    tempArr[X, Y].Data2    = E_Types.Map.Tile[X, Y].Data2;
                    tempArr[X, Y].Data3    = E_Types.Map.Tile[X, Y].Data3;
                    tempArr[X, Y].DirBlock = E_Types.Map.Tile[X, Y].DirBlock;
                    tempArr[X, Y].Type     = E_Types.Map.Tile[X, Y].Type;

                    for (i = 1; i <= (int)Enums.LayerType.Count - 1; i++)
                    {
                        tempArr[X, Y].Layer[i].AutoTile = E_Types.Map.Tile[X, Y].Layer[i].AutoTile;
                        tempArr[X, Y].Layer[i].Tileset  = E_Types.Map.Tile[X, Y].Layer[i].Tileset;
                        tempArr[X, Y].Layer[i].X        = E_Types.Map.Tile[X, Y].Layer[i].X;
                        tempArr[X, Y].Layer[i].Y        = E_Types.Map.Tile[X, Y].Layer[i].Y;
                    }
                }
            }

            x2 = E_Types.Map.MaxX;
            y2 = E_Types.Map.MaxY;
            // change the data
            E_Types.Map.MaxX = (byte)nudMaxX.Value;
            E_Types.Map.MaxY = (byte)nudMaxY.Value;

            E_Types.Map.Tile     = new Types.TileRec[E_Types.Map.MaxX + 1, E_Types.Map.MaxY + 1];
            E_AutoTiles.Autotile = new E_AutoTiles.AutotileRec[E_Types.Map.MaxX + 1, E_Types.Map.MaxY + 1];

            if (x2 > E_Types.Map.MaxX)
            {
                x2 = E_Types.Map.MaxX;
            }
            if (y2 > E_Types.Map.MaxY)
            {
                y2 = E_Types.Map.MaxY;
            }

            for (X = 0; X <= E_Types.Map.MaxX; X++)
            {
                for (Y = 0; Y <= E_Types.Map.MaxY; Y++)
                {
                    Array.Resize(ref E_Types.Map.Tile[X, Y].Layer, (int)Enums.LayerType.Count);

                    Array.Resize(ref E_AutoTiles.Autotile[X, Y].Layer, (int)Enums.LayerType.Count);

                    if (X <= x2)
                    {
                        if (Y <= y2)
                        {
                            E_Types.Map.Tile[X, Y].Data1    = tempArr[X, Y].Data1;
                            E_Types.Map.Tile[X, Y].Data2    = tempArr[X, Y].Data2;
                            E_Types.Map.Tile[X, Y].Data3    = tempArr[X, Y].Data3;
                            E_Types.Map.Tile[X, Y].DirBlock = tempArr[X, Y].DirBlock;
                            E_Types.Map.Tile[X, Y].Type     = tempArr[X, Y].Type;

                            for (i = 1; i <= (int)Enums.LayerType.Count - 1; i++)
                            {
                                E_Types.Map.Tile[X, Y].Layer[i].AutoTile = tempArr[X, Y].Layer[i].AutoTile;
                                E_Types.Map.Tile[X, Y].Layer[i].Tileset  = tempArr[X, Y].Layer[i].Tileset;
                                E_Types.Map.Tile[X, Y].Layer[i].X        = tempArr[X, Y].Layer[i].X;
                                E_Types.Map.Tile[X, Y].Layer[i].Y        = tempArr[X, Y].Layer[i].Y;
                            }
                        }
                    }
                }
            }
            E_AutoTiles.InitAutotiles();
            ClientDataBase.ClearTempTile();
            //MapEditorSend()

            E_Globals.GettingMap = false;
        }