コード例 #1
0
 /// <summary>
 /// Ejects the content of the MysterBlock
 /// </summary>
 /// <param name="mario">Used to check if the mysteryBlock is being hit from below</param>
 public void Eject(Mario mario)
 {
     if (mario.VelocityY < 0 && !HasBeenUsed && mario.Hitbox.Y >= Hitbox.Bottom)
     {
         if (MysteryObject == typeof(Coin))
         {
             Coin c = (Coin)Activator.CreateInstance(MysteryObject, (int)Position.X / Global.Instance.GridSize, ((int)Position.Y - Hitbox.Height) / Global.Instance.GridSize, CurrentLevel, _contentManager, true);
             c.AddCoin(mario);
             CurrentLevel.ToAddGameObject(c);
         }
         if (MysteryObject == typeof(Mushroom))
         {
             Mushroom m = (Mushroom)Activator.CreateInstance(MysteryObject, (int)Position.X / Global.Instance.GridSize, ((int)Position.Y - Hitbox.Height) / Global.Instance.GridSize, CurrentLevel, _contentManager);
             CurrentLevel.ToAddGameObject(m);
         }
         if (MysteryObject == typeof(LevelReader))
         {
             if (_levelNumber == 0)
             {
                 if (_courseClearSound != null)
                 {
                     MediaPlayer.Pause();
                     _courseClearSound.Play();
                     new Timer(Global.Instance.MainGame.sound.ResumeMusic).Change(8000, Timeout.Infinite);
                 }
             }
             LevelReader _lr = (LevelReader)Activator.CreateInstance(MysteryObject, _contentManager);
             Global.Instance.MainGame.ChangeCurrentLevel(_lr.ReadLevel(_levelNumber));
         }
         HasBeenUsed = true;
         _animator.GetTextures(64, 0, 16, 16, 1, 1);
         _animator.SetAnimationSpeed(0);
     }
 }
コード例 #2
0
ファイル: Mario.cs プロジェクト: RubenBrocke/SuperMarioClone
        /// <summary>
        /// Loads the menu after Mario dies
        /// </summary>
        /// <param name="state"></param>
        private void LoadMenu(object state)
        {
            MediaPlayer.Resume();
            LevelReader lr = new LevelReader(_contentManager);

            Global.Instance.MainGame.ChangeCurrentLevel(lr.ReadLevel(0));
        }
コード例 #3
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()
 {
     gameOver = false;
     sound    = new Sound(Content);
     Global.Instance.MainGame = this;
     _levelReader             = new LevelReader(Content);
     currentLevel             = _levelReader.ReadLevel(0);
     mario = new Mario(0, 32, currentLevel, Content);
     currentLevel.ToAddGameObject(mario);
     camera = new Camera(GraphicsDevice.Viewport);
     _graphicalUserInterface = new GraphicalUserInterface(mario, Content);
     System.Windows.Forms.Form form = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(this.Window.Handle);
     form.Location = new System.Drawing.Point(Screen.PrimaryScreen.Bounds.Width / 2 - GraphicsDevice.Viewport.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2 - GraphicsDevice.Viewport.Height / 2);
     base.Initialize();
 }