private static Texture GetTexture()
        {
            string path = ModuleHelper.GetModuleFullPath("Native") + "LoadingTextures/";

            try
            {
                string[] files  = Directory.GetFiles(path, "*.tif");
                int      length = files.Length;
                if (length != 0)
                {
                    int    index    = new Random().Next(length);
                    string fileName = files[index];
                    int    num      = files[index].IndexOf("/LoadingTextures/");
                    if (num != -1)
                    {
                        int startIndex = num + 17;
                        fileName = files[index].Substring(startIndex);
                    }
                    return(Texture.CreateTextureFromPath(path, fileName));
                }
            }
            catch (Exception ex)
            {
                MBDebug.Print(ex.ToString());
            }
            return((Texture)null);
        }
 private void AddGameTexts()
 {
     this.CurrentGame.GameTextManager.LoadGameTexts(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/multiplayer_strings.xml");
     this.CurrentGame.GameTextManager.LoadGameTexts(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/global_strings.xml");
     this.CurrentGame.GameTextManager.LoadGameTexts(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/module_strings.xml");
     this.CurrentGame.GameTextManager.LoadGameTexts(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/native_strings.xml");
 }
 private void InitializeGameTexts(GameTextManager gameTextManager)
 {
     gameTextManager.LoadGameTexts(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/multiplayer_strings.xml");
     gameTextManager.LoadGameTexts(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/global_strings.xml");
     gameTextManager.LoadGameTexts(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/module_strings.xml");
     gameTextManager.LoadGameTexts(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/native_strings.xml");
 }
Exemplo n.º 4
0
        internal static List <Formula> InitializeFormulas()
        {
            // Shamelessly copied from Custom Troop Upgrades because it's my mod
            if (!Modules.IsEmpty())
            {
                Modules.Clear();
            }

            string[] moduleNames = Utilities.GetModulesNames();
            foreach (string moduleName in moduleNames)
            {
                ModuleInfo m = new ModuleInfo();
                m.LoadWithFullPath(ModuleHelper.GetModuleFullPath(moduleName));

                if (m.Id == "BattleRegeneration")
                {
                    Modules.Insert(0, m);                               // original mod should load first
                }
                else
                {
                    Modules.Add(m);
                }
            }

            formulas = new List <Formula>();
            CompileScripts("battleregen.cs", GenerateCSharpCode);
            CompileScripts("battleregen.vb", GenerateVisualBasicCode);
            return(formulas);
        }
 public static void InitializeFromConfigFile(string fileName)
 {
     if (fileName.IsStringNoneOrEmpty())
     {
         return;
     }
     foreach (string readAllLine in File.ReadAllLines(ModuleHelper.GetModuleFullPath("Native") + fileName))
     {
         GameNetwork.HandleConsoleCommand(readAllLine);
     }
 }
        public static void LoadFromXml()
        {
            MusicParameters._parameters = new float[18];
            string       path         = ModuleHelper.GetModuleFullPath("Native") + "ModuleData/music_parameters.xml";
            XmlDocument  xmlDocument  = new XmlDocument();
            StreamReader streamReader = new StreamReader(path);
            string       end          = streamReader.ReadToEnd();

            xmlDocument.LoadXml(end);
            streamReader.Close();
            foreach (XmlNode childNode in xmlDocument.ChildNodes)
            {
                if (childNode.NodeType == XmlNodeType.Element && childNode.Name == "music_parameters")
                {
                    IEnumerator enumerator = childNode.ChildNodes.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            XmlNode current = (XmlNode)enumerator.Current;
                            if (current.NodeType == XmlNodeType.Element)
                            {
                                MusicParameters.MusicParametersEnum musicParametersEnum = (MusicParameters.MusicParametersEnum)Enum.Parse(typeof(MusicParameters.MusicParametersEnum), current.Attributes["id"].Value);
                                float num = float.Parse(current.Attributes["value"].Value);
                                MusicParameters._parameters[(int)musicParametersEnum] = num;
                            }
                        }
                        break;
                    }
                    finally
                    {
                        if (enumerator is IDisposable disposable5)
                        {
                            disposable5.Dispose();
                        }
                    }
                }
            }
            Debug.Print("MusicParameters have been resetted.", color: Debug.DebugColor.Green, debugFilter: 281474976710656UL);
            Debug.Print("MusicParameters have been resetted.", color: Debug.DebugColor.Green, debugFilter: 64UL);
        }
        protected override void OnInitialize()
        {
            Game currentGame = this.CurrentGame;

            currentGame.FirstInitialize(false);
            if (!GameNetwork.IsDedicatedServer)
            {
                this.AddGameTexts();
            }
            IGameStarter gameStarter = (IGameStarter) new BasicGameStarter();

            this.AddGameModels(gameStarter);
            this.GameManager.OnGameStart(this.CurrentGame, gameStarter);
            currentGame.SecondInitialize(gameStarter.Models);
            currentGame.CreateGameManager();
            currentGame.ThirdInitialize();
            this.GameManager.BeginGameStart(this.CurrentGame);
            currentGame.CreateObjects();
            currentGame.InitializeDefaultGameObjects();
            currentGame.LoadBasicFiles(false);
            this.ObjectManager.LoadXML("Items");
            this.ObjectManager.LoadXML("MPCharacters");
            this.ObjectManager.LoadXML("BasicCultures");
            currentGame.CreateLists();
            this.ObjectManager.LoadXML("MPClassDivisions");
            this.ObjectManager.ClearEmptyObjects();
            MultiplayerClassDivisions.Initialize();
            BadgeManager.LoadFromXml(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/mpbadges.xml");
            this.GameManager.OnCampaignStart(this.CurrentGame, (object)null);
            this.GameManager.OnAfterCampaignStart(this.CurrentGame);
            this.GameManager.OnGameInitializationFinished(this.CurrentGame);
            this.CurrentGame.AddGameHandler <ChatBox>();
            if (!GameNetwork.IsDedicatedServer)
            {
                return;
            }
            this.CurrentGame.AddGameHandler <MultiplayerGameLogger>();
        }
Exemplo n.º 8
0
        private static void LoadMultiplayerSceneInformations()
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(ModuleHelper.GetModuleFullPath("Native") + "ModuleData/Multiplayer/MultiplayerScenes.xml");
            foreach (XmlNode xmlNode in xmlDocument.FirstChild)
            {
                if (xmlNode.NodeType != XmlNodeType.Comment)
                {
                    string innerText1 = xmlNode.Attributes["name"].InnerText;
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                    {
                        if (childNode.NodeType != XmlNodeType.Comment)
                        {
                            string innerText2 = childNode.Attributes["name"].InnerText;
                            if (MultiplayerGameTypes._multiplayerGameTypeInfos.ContainsKey(innerText2))
                            {
                                MultiplayerGameTypes._multiplayerGameTypeInfos[innerText2].Scenes.Add(innerText1);
                            }
                        }
                    }
                }
            }
        }