示例#1
0
        private void KillAllEnemies_Click(object sender, EventArgs e)
        {
            main.actionOccuring = true;
            List <Player> players = new List <Player>(main.players);

            players.ForEach(p => {
                if (p.Name != main.humanPlayer.Name)
                {
                    main.DamagePlayer(100, DamageType.unblockable, p);
                }
            });
            main.actionOccuring = false;
            main.RenderMap();
        }
示例#2
0
        private void StartGame_Click(object sender, EventArgs e)
        {
            MapBiome biome = new DesertMapBiome();

            //Long term: allow map selection
            if (map == null)
            {
                if (MessageBox.Show("You have no map selected! \n Starting now will mean using a random map!", "Alert", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    //Start game with random map
                    map = new Map {
                        mapBiome = biome
                    };
                    Thread mapThread;
                    do
                    {
                        mapThread = new Thread(() => map.SetupMap(0.1, World.World.random.Next(), -0.2, biome))
                        {
                            Priority = ThreadPriority.Highest
                        };
                        mapThread.Start();
                    } while (!mapThread.Join(TimeSpan.FromSeconds(Map.creationTime)));
                }
                else
                {
                    //Allow user to create a map
                    return;
                }
            }
            //Load player
            HumanPlayer player = new HumanPlayer(PlayerType.localHuman, Settings.Default.Name, null, null, null, 0);

            if (playerTroop is null)
            {
                MessageBox.Show("Please create your troop before starting the game!");
                playerTroop = new Troop(Settings.Default.Name, new Weapon(5, BaseAttackType.melee, BaseDamageType.blunt, 1, "Punch", 2, false), Resources.playerTroop, 0, map, player)
                {
                    armours = new List <Armour>
                    {
                        new Armour("Woolen Tunic", 50, new List <BodyParts> {
                            BodyParts.LeftUpperArm, BodyParts.RightUpperArm, BodyParts.Torso
                        }, Material.Materials.First(m => m.name == "Wool"), Quality.Common, ArmourLayer.clothing),
                        new Armour("Old Pants", 40, new List <BodyParts> {
                            BodyParts.UpperLegs, BodyParts.LeftLowerLeg, BodyParts.RightLowerLeg, BodyParts.LeftShin, BodyParts.RightShin
                        }, Material.Materials.First(m => m.name == "Cloth"), Quality.Poor, ArmourLayer.clothing),
                        new Armour("Wooden Shoes", 32, new List <BodyParts> {
                            BodyParts.LeftFoot, BodyParts.RightFoot
                        }, Material.Materials.First(m => m.name == "Wood"), Quality.Poor, ArmourLayer.light)
                    }
                };
                playerTroop.weapons.Add(new Weapon(50, BaseAttackType.magic, BaseDamageType.magic, 40, "GOD", 10, true));
            }
            player.troop = playerTroop;
            player.troop.armours.ForEach(a => a.active = true);

            player.agility.RawValue      = 5;
            player.strength.RawValue     = 5;
            player.vitality.RawValue     = 20;
            player.intelligence.RawValue = 5;
            player.wisdom.RawValue       = 5;
            player.endurance.RawValue    = 5;

            Hide();
            //Long term: Make form to allow use to choose mission and difficulty

            Mission.Mission mission = new BearMission();

            List <Tree> trees = Tree.GenerateTrees();

            MainGameWindow mainGameWindow = new MainGameWindow(map, player, mission, trees, 5, 1);

            biome.ManipulateMission(mainGameWindow, mission);
            mainGameWindow.RenderMap(true, true, true);
            //try
            //{
            mainGameWindow.ShowDialog();
            //}
            //catch (Exception f)
            //{
            //    Trace.TraceError(f.ToString());
            //    MessageBox.Show(f.ToString());
            //}
            Show();

            //Reset all variables
            map    = null;
            player = null;
        }