예제 #1
0
        private void RunMission(int difficulty, Mission.Mission selected, StartMission action = null)
        {
            World.Instance.campaign.mission = selected;
            MapBiome biome = new GrasslandMapBiome();

            if (mapBiomes.ContainsKey(World.Instance.worldMap[player.WorldPosition.X, player.WorldPosition.Y].type))
            {
                biome = mapBiomes[World.Instance.worldMap[player.WorldPosition.X, player.WorldPosition.Y].type];
            }
            Map map = World.Instance.campaign.GenerateMap(biome);

            player.map       = map;
            player.troop.Map = map;
            MainGameWindow mainGame = new MainGameWindow(map, player, selected, World.Instance.trees, difficulty, World.WORLD_DIFFICULTY);

            biome.ManipulateMission(mainGame, selected);
            mainGame.RenderMap(true, true, true);
            controller.Stop();
            mainGame.ShowDialog();
            if (action != null)
            {
                action.MissionEnded(mainGame.giveReward);
            }
            if (mainGame.dead)
            {
                //as player is dead campaign is over
                Close();
                return;
            }
            if (mainGame.giveReward)
            {
                //Now give reward
                MissionResult r = CampaignController.GenerateRewardAndHeal(player, mainGame, selected, player.vitality.Value, (player.level / 25d).Cut(0, 1), "Close");
                r.ShowDialog();
            }
            if (running)
            {
                controller.Start();
            }
            World.Instance.missionsCompleted++;
            World.Instance.actors.RemoveAll(p => (p is MissionWorldPlayer wp) && wp.WorldPosition == player.WorldPosition);
            World.Instance.GenerateNewMission();
            Render();
        }