Exemple #1
0
        private void StartGame_Click(object sender, EventArgs e)
        {
            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
                    Random rnd = new Random();
                    map = new Map(31, 31); //TODO set global constant for the size
                    map.SetupMap(0.1, rnd.NextDouble() * 100, ((double)rnd.Next(8) - 4) / 20, 1);
                }
                else
                {
                    //Allow user to create a map
                    return;
                }
            }
            //Load player
            Player player = new Player(PlayerType.localHuman, Settings.Default.Name)
            {
                troop = playerTroop
            };

            Hide();
            MainGameWindow mainGameWindow = new MainGameWindow(map, player);

            mainGameWindow.ShowDialog();
            Show();
        }
Exemple #2
0
 public override void Initialise(MainGameWindow mainGame)
 {
     this.mainGame = mainGame;
     if (!mainGame.humanPlayer.trees.Exists(t => t.name == name))
     {
         mainGame.Combat += Update;
     }
 }
Exemple #3
0
        public void Activate(Player player, MainGameWindow main, bool AllowAction)
        {
            allowAction = AllowAction;
            Point spawnPoint = new Point(0, 20);

            playerProfile = new PlayerBaseStats
            {
                Location = spawnPoint
            };
            playerProfile.Activate(player);
            Controls.Add(playerProfile);

            itemView = new PlayerItemView()
            {
                Location = spawnPoint
            };
            itemView.Activate(player, main);
            itemView.Visible = false;
            Controls.Add(itemView);

            playerStatus = new PlayerStatusView
            {
                Location = spawnPoint
            };
            playerStatus.Activate(player);
            playerStatus.Visible = false;
            Controls.Add(playerStatus);

            playerSpell = new PlayerSpellView
            {
                Location = spawnPoint
            };
            playerSpell.Activate(player, main, allowAction);
            playerSpell.Visible = false;
            Controls.Add(playerSpell);

            playerWeapon = new PlayerWeaponView
            {
                Location = spawnPoint
            };
            playerWeapon.Visible = false;
            playerWeapon.Activate(player, allowAction);
            Controls.Add(playerWeapon);

            playerTree = new PlayerTreeView
            {
                Location = spawnPoint
            };
            playerTree.Visible = false;
            playerTree.Activate(player);
            Controls.Add(playerTree);

            active = playerProfile;
            tab    = PlayerTab.stats;
            Render();
        }
Exemple #4
0
        /// <summary>
        /// Initialises campaign and generates map and enemies for first mission
        /// </summary>
        public void Start()
        {
            //Setup map
            mission = DecideMission(Round);
            Map map = GenerateMap();

            player.map       = map;
            player.troop.Map = map;

            //Finish initialisation
            activeGame = new MainGameWindow(map, player, mission, trees, difficulty, Round);
        }
Exemple #5
0
        public static MissionResult GenerateRewardAndHeal(HumanPlayer player, MainGameWindow mainWindow, Mission.Mission mission, int healthRegen, double progression, string closeButtonText)
        {
            //Reset troop stats
            foreach (Weapon weapon in player.troop.weapons)
            {
                if (weapon.type != BaseAttackType.range)
                {
                    weapon.SetAttacks(weapon.MaxAttacks());
                }
            }

            player.mana.RawValue          = player.mana.MaxValue().Value;
            player.troop.health.RawValue += healthRegen;
            player.troop.health.RawValue  = player.troop.health.Value > player.troop.health.MaxValue().Value ? player.troop.health.MaxValue().Value : player.troop.health.Value;

            List <Armour> loot = new List <Armour>();

            if (mission.lootDead)
            {
                //Generate loot from dead players
                List <Armour> lootableArmour = new List <Armour>();
                foreach (var deadPlayer in mainWindow.killedPlayers)
                {
                    lootableArmour.AddRange(deadPlayer.troop.armours);
                }

                lootableArmour = lootableArmour.OrderBy(a => World.World.random.Next()).ToList(); // I know it is not the most effiecent but that does not matter here

                int chosen = 0;
                foreach (var lootpiece in lootableArmour)
                {
                    if (World.World.random.NextDouble() < 1d / (chosen + 1d))
                    {
                        lootpiece.active = false;
                        loot.Add(lootpiece);
                        chosen++;
                    }
                }
            }
            //Show world map
            MissionResult worldView = new MissionResult(player, progression, mission, loot, closeButtonText);

            return(worldView);
        }
Exemple #6
0
        /// <summary>
        /// Initialises next mission in the campaign. Returns true if there is a next mission, false if the campaign is over
        /// </summary>
        public bool Next()
        {
            if (playedGames.Count + 1 == numberOfGames)
            {
                return(false);
            }
            if (activeGame is null)
            {
                throw new Exception();
            }
            playedGames.Add(activeGame);

            mission = DecideMission(Round);

            //Setup map
            Map    map = new Map();
            Thread mapCreator;

            do
            {
                mapCreator = new Thread(() => map.SetupMap(0.1, World.World.random.Next(), 0))
                {
                    Priority = ThreadPriority.Highest
                };
                mapCreator.Start();
            } while (!mapCreator.Join(Map.creationTime) && !mission.MapValidity(map));

            player.map       = map;
            player.troop.Map = map;

            //Finish initialisation
            player.active = false;
            activeGame    = new MainGameWindow(map, player, mission, trees, difficulty, Round);

            return(true);
        }
Exemple #7
0
        private void EnterDungeon_Click(object sender, EventArgs e)
        {
            Hide();
            DungeonChooser chooser = new DungeonChooser();

            chooser.ShowDialog();
            if (chooser.selected != null)
            {
                List <Tree> trees  = Tree.GenerateTrees();
                HumanPlayer player = new HumanPlayer(PlayerType.localHuman, Settings.Default.Name, null, null, null, 0);
                if (playerTroop is null)
                {
                    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);
                MainGameWindow mainGame = new MainGameWindow(chooser.selected.start.room.map, player, chooser.selected, trees, 1, 1);
                mainGame.ShowDialog();
            }
            Show();
        }
Exemple #8
0
 public override void Initialise(MainGameWindow mainGame)
 {
     main         = mainGame;
     main.Combat += Combat;
 }
Exemple #9
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;
        }
Exemple #10
0
 public void ActionButtonPressed(MainGameWindow mainGameWindow)
 {
     mainGameWindow.NextTurn();
 }
Exemple #11
0
 public DebugEditor(MainGameWindow main)
 {
     InitializeComponent();
     this.main = main;
 }
Exemple #12
0
 public abstract void Initialise(MainGameWindow mainGame);