コード例 #1
0
ファイル: MainScene.cs プロジェクト: BlayeeR/BoulderDash
        private void Map_MapCompleted(object sender, EventArgs e)
        {
            int id = map.ID, oldScore = map.Score;

            id++;
            Camera.Focus = new Actor()
            {
                Position = Vector2.Zero
            };
            map.UnloadContent();
            map.MapCompleted -= Map_MapCompleted;
            map.PlayerKilled -= Map_PlayerKilled;
            try
            {
                using (ContentManager c = new ContentManager(content.ServiceProvider, content.RootDirectory))
                    map = c.Load <ActorMap>($"Maps/{id}");
            }
            catch
            {
                if (SceneManager.Instance.CurrentScene == this)
                {
                    SceneManager.Instance.ChangeScene(new EndingScene(game, oldScore));
                }
            }
            map.LoadContent(content);
            map.Score         = oldScore;
            Camera.Focus      = map.Player;
            map.MapCompleted += Map_MapCompleted;
            map.PlayerKilled += Map_PlayerKilled;
        }
コード例 #2
0
ファイル: MainScene.cs プロジェクト: BlayeeR/BoulderDash
 public void LoadContent(ContentManager content)
 {
     this.content = content;
     InputManager.Instance.OnBackButtonClicked += InputManager_OnBackButtonClicked;
     using (ContentManager c = new ContentManager(content.ServiceProvider, content.RootDirectory))
         try
         {
             map = c.Load <ActorMap>($"Maps/{firstMap}");
         }
         catch
         {
             map = c.Load <ActorMap>($"Maps/1");
         }
     map.LoadContent(content);
     map.PlayerKilled += Map_PlayerKilled;
     map.MapCompleted += Map_MapCompleted;
     Camera            = new Camera2D(game, new Vector2(game.GetScaledResolution().X, game.GetScaledResolution().Y *(1 - guiSize)));
     Camera.Initialize();
     Camera.CalculateDeadZone(map.Size, map.TileDimensions);
     Camera.Focus = map.Player;
     guiText      = new Text(new Vector2(game.GetScaledResolution().X *0.06f, game.GetScaledResolution().Y *guiSize / 4), $"[{map.DiamondsRequired}]/{map.DiamondValue} [{map.DiamondsCollected}] {map.Time} {map.Score}", Color.White);
     guiText.LoadContent(content);
 }