コード例 #1
0
        private void cmdLoadLevel_Click(object sender, RoutedEventArgs e)
        {
            string filepath = Helper.OpenFile();

            if (filepath == null)
            {
                return;
            }
            ThisLevel.ClearLevel(MainGFX);
            try
            {
                ThisLevel = LevelSet.LoadLevel(filepath);
                ThisLevel.BuildLevel(MainGFX);
                lstSprites.ItemsSource = ThisLevel.Sprites;
                lstSprites.Items.Refresh();
                GUIAni = new GUIAnimator(gfx: MainGFX,
                                         lvl: ThisLevel,
                                         timingSrc: TimingSource.Sources.CompositionTargetRendering,
                                         pgJumpRes: pgJumpResource);
            }
            catch (Exception ex)
            {
                MessageBox_Dispatched("Failed loading level description", ex.Message);
            }
        }
コード例 #2
0
ファイル: LevelScript.cs プロジェクト: apmKrauser/ProjectGame
        /// <summary>
        /// Load Level and start animators
        /// </summary>
        /// <param name="gWin">Main game window object</param>
        /// <param name="levelFileName">Name of XML-File with level layout</param>
        /// <returns></returns>
        public static LevelSet StartLevel(GameWindow gWin, string levelFileName)
        {
            LevelSet Level = null;

            SpriteObject.AnimatedByDefault = false;

            string LevelPath = Helper.DataLocalPath + @"\" + levelFileName;

            //GC.Collect();
            //GC.WaitForPendingFinalizers();

            ThisLevel.ClearLevel(gWin.MainGFX);
            ThisLevel = LevelSet.LoadLevel(LevelPath);
            ThisLevel.BuildLevel(gWin.MainGFX);

            GWin = gWin;

            GUIAni = new GUIAnimator(gfx: gWin.MainGFX,
                                     lvl: ThisLevel,
                                     timingSrc: TimingSource.Sources.CompositionTargetRendering,
                                     pgJumpRes: gWin.pgJumpResource);

            Player = gWin.MainGFX.FindObject("Player") as CarObject;
            if (Player == null)
            {
                ErrorMsg("No 'Player' object defined!");
                return(Level);
            }

            // Particle Systems do not start by AnimatedByDefault = true
            // therefore call property setter
            ThisLevel.AnimatedAllSprites = true;
            Scroller = new SmoothGameScroller(Player, gWin.MainGFX, gWin.GameWrapper);

            return(Level);
        }