Example #1
0
        private static Map LoadLevelFile(GamePlayLogic gamePlay, string fileName, bool config)
        {
            if (!File.Exists(fileName))
                return null;

            XmlSerializer serializer = new XmlSerializer(typeof(Map));
            XmlReader reader = new XmlTextReader(fileName);

            Map map = (Map)serializer.Deserialize(reader);

            reader.Close();

            if (!config)
                gamePlay.LoadLibrary(map.LibraryName, map);
            else
                map.Cells.Clear();

            //---
            foreach (Cell cell in map.Cells)
            {
                cell.Map = map;
                cell.InitialLocation = cell.Location;

                if (cell.Channel != null)
                {
                    cell.Channel = map.Channels.Find(c => c.Name == cell.Channel.Name);
                }

                if (cell.Clip != null && cell.Clip.Instrument != null && cell.Clip.Instrument is InstrumentSample)
                {
                    InstrumentSample instrument = cell.Clip.Instrument as InstrumentSample;

                    instrument.Sample = cell.Channel.ListSample.Find(s => s.Name == instrument.Sample.Name);
                }

                if (cell.Channel != null && cell.Clip != null && cell.Clip.Instrument is InstrumentStart)
                    cell.Channel.CellStart = cell;
            }
            //---

            if (map.SpeedFactor == 0f)
                map.SpeedFactor = 1f;

            map.SpeedFactor = map.SpeedFactor;

            if (map.PartitionDuration == TimeSpan.Zero)
                map.PartitionDuration = new TimeSpan(0, 1, 0);

            if (map.TimeDuration == 0f)
                map.TimeDuration = 500f;

            foreach (Channel channel in map.Channels)
            {
                if (channel.Name != "Empty")
                {
                    channel.InitChannelEffect();
                }
            }

            map.CalcNeighborough();

            return map;
        }
Example #2
0
        public static Map LoadLevel(GamePlayLogic gamePlay, string levelName)
        {
            string fileName = Path.Combine(Path.GetFullPath(Application.ExecutablePath), @"..\Files\Level", levelName + ".xml");

            return LoadLevelFile(gamePlay, fileName, false);
        }
Example #3
0
        public static Map LoadLevelConfig(GamePlayLogic gamePlay, string libraryName)
        {
            string fileName = Path.Combine(Directory.GetParent(Application.ExecutablePath).FullName, @"Files\Sound\Library", libraryName, libraryName + "_Config.xml");

            return LoadLevelFile(gamePlay, fileName, true);
        }
Example #4
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            if (Mini)
            {
                Control window = Control.FromHandle(this.Window.Handle);
                window.Location = new System.Drawing.Point(1950, 350);
                window.Location = new System.Drawing.Point(1950, 350);
            }

            base.Initialize();

            Context.GameEngine = this;
            //VisualStyle.OpenVisualStyle("LightGray");
            VisualStyle.OpenVisualStyle("AlmostDarkGrayBlue");

            Render = new RenderLogic(this);
            Render.InitRender();
            UI = new UILogic(this);
            Sound = new SoundLogic(this);
            GamePlay = new GamePlayLogic(this);
            Controller = new ControllerLogic(this);
        }