Exemple #1
0
        public Sounds()
        {
            if (_mainSound != null) { throw new NullReferenceException("Sounds object created twice"); }
            _mainSound = this;

            soundTable = new Hashtable();
            if (!System.IO.File.Exists(DCSG.Contents.RootDirectory + "\\Sounds\\soundloader.xml"))
                throw new System.IO.FileNotFoundException("Soundloader file does not exist!");
            if (SoundDocument == null)
                SoundDocument = new XmlDocument();
            SoundDocument.Load(DCSG.Contents.RootDirectory + "\\Sounds\\soundloader.xml");
            foreach (XmlElement soundNode in SoundDocument.ChildNodes)
            {
                if (soundNode.Name == "sounds")
                {
                    foreach (XmlElement soundEffect in soundNode)
                    {
                        FileStream fs;
                        try
                        {
                            fs = new FileStream(DCSG.Contents.RootDirectory + "\\Sounds\\" + soundEffect.GetAttribute("path") + "\\" + soundEffect.GetAttribute("filename") + "." + soundEffect.GetAttribute("type"), FileMode.Open);
                            SoundEffect se = SoundEffect.FromStream(fs);
                            soundTable.Add(soundEffect.GetAttribute("id").ToLowerInvariant(), se);
                            fs.Close();
                        }
                        catch
                        {
                            Console.WriteLine("Soundeffect not found to load: " + soundEffect.GetAttribute("id"));
                        }
                    }
                }
            }
        }
Exemple #2
0
        public static void Initialize()
        {
            if (_init) { return; }
            //***********************
            //Initialize Stuff here:
            Fonts.LoadFont("std_small");
            _debugger = new Debug();

            _ihObject = new Inputhandler();
            _textureHandlerObject = new Textures();
            _timeHandlerObject = new Time();
            _sounds = new Sounds();
            Fonts.LoadFont("mainfont");
            Fonts.LoadFont("std");

            _firstScreen = new Game.Aleks.Mainmenu();

            //Don't initialize stuff here:
            //***********************

            BindKeys();
            _init = true;
        }