Exemple #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();
        }