Exemplo n.º 1
0
        private void StartMission_Click(object sender, EventArgs e)
        {
            StartMission startMission1 = (player.availableActions.Find(a => a is StartMission) as StartMission);
            int          difficulty    = startMission1.difficulty;

            Mission.Mission selected = startMission1.mission;
            player.availableActions.Remove(startMission1);
            player.possibleActions.Remove(startMission1);
            RunMission(difficulty, selected, startMission1);
        }
Exemplo n.º 2
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();
        }