Exemple #1
0
        private void LoadGameContent()
        {
            SplashScreen.ShowSplashScreen();
            SplashScreen.SetStatus("Initializing Roslyn");
            SkillEffect.LoadAllEffects();
            SplashScreen.SetStatus("Initializing Graphics");
            BattleMap.DicGlobalVariables = new Dictionary <string, string>();
            BattleMap.DicRouteChoices    = new Dictionary <string, int>();
            GameScreen.LoadHelpers(Content);
            TextHelper.LoadHelpers(Content);

            #region Key mapping

            FileStream   FS = new FileStream("Keys.ini", FileMode.Open, FileAccess.Read);
            StreamReader SR = new StreamReader(FS);
            string       StreamLine;
            string[]     StreamData;
            string[]     StreamKeys;
            List <Keys>  ListNewKeys = new List <Keys>();
            Keys         NewKey;
            Keys[]       UsedKeys;

            while (!SR.EndOfStream)
            {
                StreamLine = SR.ReadLine();
                ListNewKeys.Clear();

                if (StreamLine.Contains('='))
                {
                    StreamData = StreamLine.Split('=');
                    StreamKeys = StreamData[1].Split(',');

                    //Read keys
                    for (int K = 0; K < StreamKeys.Length; K++)
                    {
                        NewKey = ConvertTextToKeys(StreamKeys[K].Trim());
                        if (!ListNewKeys.Contains(NewKey))
                        {
                            ListNewKeys.Add(NewKey);
                        }
                    }
                    UsedKeys = ListNewKeys.ToArray();

                    //Assign keys to the right command.
                    switch (StreamData[0].Trim())
                    {
                    case "Left":
                        KeyboardHelper.MoveLeft = UsedKeys;
                        break;

                    case "Right":
                        KeyboardHelper.MoveRight = UsedKeys;
                        break;

                    case "Up":
                        KeyboardHelper.MoveUp = UsedKeys;
                        break;

                    case "Down":
                        KeyboardHelper.MoveDown = UsedKeys;
                        break;

                    case "Confirm":
                        KeyboardHelper.ConfirmChoice = UsedKeys;
                        break;

                    case "Cancel":
                        KeyboardHelper.CancelChoice = UsedKeys;
                        break;

                    case "Command 1":
                        KeyboardHelper.Command1 = UsedKeys;
                        break;

                    case "Command 2":
                        KeyboardHelper.Command2 = UsedKeys;
                        break;

                    case "L Button":
                        KeyboardHelper.LButton = UsedKeys;
                        break;

                    case "R Button":
                        KeyboardHelper.RButton = UsedKeys;
                        break;

                    case "Skip":
                        KeyboardHelper.Skip = UsedKeys;
                        break;
                    }
                }
            }

            FS.Close();
            SR.Close();

            #endregion

            SplashScreen.SetStatus("Loading Ressources");

            SystemList.LoadSystemLists();

            #region Ressources loading

            string[] Files;
            bool     InstanceIsBaseObject;
            Type     ObjectType;

            #region Battle Maps

            Files = Directory.GetFiles("Mods", "*.dll");
            for (int F = 0; F < Files.Length; F++)
            {
                Assembly ass = Assembly.LoadFile(Path.GetFullPath(Files[F]));
                //Get every classes in it.
                Type[] types = ass.GetTypes();
                for (int t = 0; t < types.Count(); t++)
                {
                    //Look if the class inherit from Unit somewhere.
                    ObjectType           = types[t].BaseType;
                    InstanceIsBaseObject = ObjectType == typeof(BattleMap);
                    while (ObjectType != null && ObjectType != typeof(BattleMap))
                    {
                        ObjectType = ObjectType.BaseType;
                        if (ObjectType == null)
                        {
                            InstanceIsBaseObject = false;
                        }
                    }
                    //If this class is from BaseEditor, load it.
                    if (InstanceIsBaseObject)
                    {
                        BattleMap instance = Activator.CreateInstance(types[t]) as BattleMap;
                        BattleMap.DicBattmeMapType.Add(instance.GetMapType(), instance);
                    }
                }
            }

            #endregion

            #endregion

            SplashScreen.CloseForm();
        }