Exemplo n.º 1
0
        GenerateMission(int difficulty, int Round, ref Map map, Player player)
        {
            string desc = "Welcome to the mission. ";

            #region Player Creation

            List <Player> players = new List <Player>()
            {
                player
            };

            //Find position of player
            players[0].troop.Position = map.DeterminSpawnPoint(1, SpawnType.road)[0];

            //Find position of campsite
            Point camp;
            camp = map.map.Cast <MapTile>().ToList().Where(t => t.neighbours.rawMaptiles.Count(n => n.type.FType == FieldType.land) == 4).OrderByDescending(m => AIUtility.Distance(m.position, player.troop.Position)).First().position;
            //Make camp fire
            Building fireplace = new Building("Fireplace", camp, Resources.firePlace, map);
            map.entities.Add(fireplace);
            map.renderObjects.Add(new EntityRenderObject(fireplace, new TeleportPointAnimation(new Point(0, 0), fireplace.Position)));

            int          enemyNumber = Round / 5 + 2 * difficulty / 3;
            List <Point> startPos    = new List <Point>();
            List <Point> toCheck     = map.map[camp.X, camp.Y].neighbours.rawMaptiles.ToList().ConvertAll(m => m.position);
            //Add a few more than neccessary so ones which are path can be removed
            while (startPos.Count <= enemyNumber + 10 && toCheck.Count != 0)
            {
                Point checking = toCheck[0];
                toCheck.Remove(checking);
                startPos.Add(checking);

                map.map[checking.X, checking.Y].neighbours.rawMaptiles.ToList().ForEach(m => {
                    //Check if it does not exist, if land and is not blocked
                    if (!startPos.Exists(f => f.X == m.position.X && f.Y == m.position.Y) && m.type.FType == FieldType.land && m.free)
                    {
                        toCheck.Add(m.position);
                    }
                });
            }

            enemyNumber = Math.Min(enemyNumber, startPos.Count); //in case there are too few positions

            //If extra, remove path
            Map _map = map;
            while (startPos.Count > enemyNumber)
            {
                if (startPos.Exists(f => _map.map[f.X, f.Y].type.type == MapTileTypeEnum.road))
                {
                    startPos.Remove(startPos.First(f => _map.map[f.X, f.Y].type.type == MapTileTypeEnum.road));
                }
                //If no path left remove random
                else
                {
                    startPos.RemoveAt(World.World.random.Next(startPos.Count));
                }
            }

            //Generate basic bandits and set position
            for (int i = 0; i < enemyNumber; i++)
            {
                string            name = $"Bandit {i + 1}";
                DefensiveBanditAI item = new DefensiveBanditAI(PlayerType.computer, name, map, new Player[] { player }, camp);
                item.troop = new Troop(name, new Weapon(3 + difficulty / 5 + Round / 2, BaseAttackType.melee, BaseDamageType.sharp, 1, "Dagger", 2, false),
                                       Resources.enemyScout, 0, map, item, Dodge: 25)
                {
                    armours = new List <Armour>
                    {
                        new Armour("Cap", 10, new List <BodyParts> {
                            BodyParts.Head
                        }, Material.Materials.First(m => m.name == "Cloth"), Quality.Simple, ArmourLayer.clothing),
                        new Armour("Shirt", 20, new List <BodyParts> {
                            BodyParts.Torso
                        }, Material.Materials.First(m => m.name == "Cloth"), Quality.Poor, ArmourLayer.clothing),
                        new Armour("Hose", 25, new List <BodyParts> {
                            BodyParts.UpperLegs, BodyParts.LeftLowerLeg, BodyParts.RightLowerLeg
                        }, Material.Materials.First(m => m.name == "Cloth"), Quality.Common, ArmourLayer.clothing),
                        new Armour("Cloak", 35, new List <BodyParts> {
                            BodyParts.LeftUpperArm, BodyParts.RightUpperArm, BodyParts.Torso, BodyParts.UpperLegs, BodyParts.LeftLowerLeg, BodyParts.RightLowerLeg
                        }, Material.Materials.First(m => m.name == "Wool"), Quality.Common, ArmourLayer.light)
                    }
                };
                players.Add(item);

                players[i + 1].troop.Position = startPos[i];
            }

            #endregion Player Creation

            #region WinCodition Creation

            //Must kill spider nest to win

            List <WinCheck> wins = new List <WinCheck>
            {
                deathCheck
            };
            desc += "Kill all the bandits to steal their treasure. ";

            #endregion WinCodition Creation

            #region DeathCondition Creation

            List <WinCheck> deaths = new List <WinCheck>
            {
                playerDeath
            };

            desc += "Do not die. ";

            #endregion DeathCondition Creation

            desc += "Good luck! ";
            return(players, wins, deaths, desc);
        }
Exemplo n.º 2
0
        GenerateMission(int difficulty, int Round, ref Map map, Player player)
        {
            string desc = "Raid the caravan! ";

            #region Player Creation

            List <Player> players = new List <Player>()
            {
                player
            };

            //Find position of player
            players[0].troop.Position = map.DeterminSpawnPoint(1, SpawnType.randomLand)[0];

            int enemyNumber = GetEnemyNumber(difficulty);
            //Find position of caravan
            List <Point> caravanPoint = map.DeterminSpawnPoint(1 + enemyNumber, SpawnType.randomRoughRoadCircle);
            //Make caravan
            Building caravanWagon = new Building("Caravan", caravanPoint[0], Resources.CaravanWagon, map);
            map.entities.Add(caravanWagon);
            map.renderObjects.Add(new EntityRenderObject(caravanWagon, new TeleportPointAnimation(new Point(0, 0), caravanWagon.Position)));


            //Generate basic bandits and set position
            for (int i = 0; i < enemyNumber; i++)
            {
                string            name = PlayerDataResource.GetMaleName();
                DefensiveBanditAI item = new DefensiveBanditAI(PlayerType.computer, name, map, new Player[] { player }, caravanPoint[0]);
                item.troop = new Troop(name, new Weapon(3 + difficulty / 5, BaseAttackType.melee, BaseDamageType.sharp, 1, "Dagger", 2, false),
                                       Resources.enemyScout, 0, map, item, Dodge: 25)
                {
                    armours = new List <Armour>
                    {
                        new Armour("Cap", 10, new List <BodyParts> {
                            BodyParts.Head
                        }, Material.Materials.First(m => m.name == "Cloth"), Quality.Simple, ArmourLayer.clothing),
                        new Armour("Shirt", 20, new List <BodyParts> {
                            BodyParts.Torso
                        }, Material.Materials.First(m => m.name == "Cloth"), Quality.Poor, ArmourLayer.clothing),
                        new Armour("Hose", 25, new List <BodyParts> {
                            BodyParts.UpperLegs, BodyParts.LeftLowerLeg, BodyParts.RightLowerLeg
                        }, Material.Materials.First(m => m.name == "Cloth"), Quality.Common, ArmourLayer.clothing),
                        new Armour("Cloak", 35, new List <BodyParts> {
                            BodyParts.LeftUpperArm, BodyParts.RightUpperArm, BodyParts.Torso, BodyParts.UpperLegs, BodyParts.LeftLowerLeg, BodyParts.RightLowerLeg
                        }, Material.Materials.First(m => m.name == "Wool"), Quality.Common, ArmourLayer.light)
                    }
                };
                item.troop.health.RawValue -= 10;
                players.Add(item);

                players[i + 1].troop.Position = caravanPoint[i];
            }

            #endregion Player Creation

            #region WinCodition Creation

            //Must kill spider nest to win

            List <WinCheck> wins = new List <WinCheck>
            {
                deathCheck
            };
            desc += "Kill all the guards to steal their caravan. ";

            #endregion WinCodition Creation

            #region DeathCondition Creation

            List <WinCheck> deaths = new List <WinCheck>
            {
                playerDeath
            };

            desc += "Do not die. ";

            #endregion DeathCondition Creation

            desc += "Good luck! ";
            return(players, wins, deaths, desc);
        }