Exemplo n.º 1
0
        public override void Run()
        {
            var numBandits = Random.Range(MinBandits, MaxBandits + 1);

            Description = $"{numBandits} bandits have blocked the trail. Their leader steps forward and demands that you turn over all your supplies.";

            var bandits = new List <Entity>();

            for (var i = 0; i < numBandits; i++)
            {
                var banditIndex = Dice.Roll("1d2");

                Entity bandit;

                if (banditIndex == 1)
                {
                    bandit = new ManAtArms(Race.RaceType.Human, false);
                }
                else
                {
                    bandit = new Crossbowman(Race.RaceType.Human, false);
                }

                bandits.Add(bandit);
            }

            Options = new Dictionary <string, Option>();

            var optionTitle = "Give up the supplies.";

            string optionResultText = "The group stands aside and watches as the bandits make off with their supplies.";

            var optionOnePenalty = new Penalty();

            var travelManager = Object.FindObjectOfType <TravelManager>();

            optionOnePenalty.AddPartyLoss(PartySupplyTypes.Gold, travelManager.Party.Gold);
            optionOnePenalty.AddPartyLoss(PartySupplyTypes.HealthPotions, travelManager.Party.HealthPotions);
            optionOnePenalty.AddPartyLoss(PartySupplyTypes.Food, travelManager.Party.Food);

            var optionOne = new Option(optionTitle, optionResultText, null, optionOnePenalty, EncounterType.Normal);

            Options.Add(optionTitle, optionOne);

            optionTitle = "Fight!";

            optionResultText = "Those supplies are essential to the group's survival. They must fight!";

            var fightOption = new FightCombatOption(optionTitle, optionResultText, bandits);

            Options.Add(optionTitle, fightOption);

            SubscribeToOptionSelectedEvent();

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.FourOptionEncounter, this);
        }
Exemplo n.º 2
0
        public override void Run()
        {
            var numBandits = Random.Range(MinBandits, MaxBandits + 1);

            Description = $"{numBandits} bandits have blocked the trail with their weapons drawn!";

            var bandits = new List <Entity>();

            for (var i = 0; i < numBandits; i++)
            {
                var banditIndex = Dice.Roll("1d2");

                Entity bandit;

                if (banditIndex == 1)
                {
                    bandit = new ManAtArms(Race.RaceType.Human, false);
                }
                else
                {
                    bandit = new Crossbowman(Race.RaceType.Human, false);
                }

                bandits.Add(bandit);
            }

            Options = new Dictionary <string, Option>();

            var optionTitle = "Retreat";

            string optionResultText;

            const int retreatSuccessValue = 47;

            var retreatCheck = Dice.Roll("1d100");

            var retreatSuccess = retreatCheck <= retreatSuccessValue;

            Debug.Log($"Value Needed: {retreatSuccessValue}");
            Debug.Log($"Rolled: {retreatCheck}");

            if (retreatSuccess)
            {
                optionResultText = "They manage to evade the attackers and escape safely.";
            }
            else
            {
                optionResultText = "They try to get away, but the attackers are too fast! Prepare for battle!";
            }

            var retreatOption = new RetreatCombatOption(optionTitle, optionResultText, bandits, retreatSuccess);

            Options.Add(optionTitle, retreatOption);

            optionTitle = "To arms!";

            optionResultText = "Prepare for battle...";

            var fightOption = new FightCombatOption(optionTitle, optionResultText, bandits);

            Options.Add(optionTitle, fightOption);

            SubscribeToOptionSelectedEvent();

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.FourOptionEncounter, this);
        }
Exemplo n.º 3
0
        public override void Run()
        {
            var numBandits = Random.Range(MinBandits, MaxBandits + 1);

            Description = $"{numBandits} bandits have blocked the trail. ";

            const int foodThreshold = 6;

            Description += "Their leader steps forward and shakily demands that you turn over ";

            Penalty = new Penalty();

            if (Party.Food > foodThreshold && Party.Gold > 4 && Party.HealthPotions > 4)
            {
                var numGold = Party.Gold / 4;

                Description += $"{numGold} gold, ";

                var numPotions = Party.HealthPotions / 4;

                Description += $"{numPotions} potion";

                if (numPotions > 1)
                {
                    Description += $"s";
                }

                Description += ", ";

                Description += "and the rest of your food!";

                Penalty.AddPartyLoss(PartySupplyTypes.Gold, Party.Gold / 4);
                Penalty.AddPartyLoss(PartySupplyTypes.HealthPotions, Party.HealthPotions / 4);
                Penalty.AddPartyLoss(PartySupplyTypes.Food, Party.Food);
            }
            else
            {
                Description += "half of all your supplies!";

                if (Party.Gold > 1)
                {
                    Penalty.AddPartyLoss(PartySupplyTypes.Gold, Party.Gold / 2);
                }

                if (Party.HealthPotions > 1)
                {
                    Penalty.AddPartyLoss(PartySupplyTypes.HealthPotions, Party.HealthPotions / 2);
                }

                if (Party.Food > 1)
                {
                    Penalty.AddPartyLoss(PartySupplyTypes.Food, Party.Food / 2);
                }
            }

            var bandits = new List <Entity>();

            for (var i = 0; i < numBandits; i++)
            {
                var banditIndex = Dice.Roll("1d2");

                Entity bandit;

                if (banditIndex == 1)
                {
                    bandit = new ManAtArms(Race.RaceType.Human, false);
                }
                else
                {
                    bandit = new Crossbowman(Race.RaceType.Human, false);
                }

                bandits.Add(bandit);
            }

            Options = new Dictionary <string, Option>();

            var optionTitle = "Give up the supplies.";

            string optionResultText = "The group stands aside and watches as the bandits make off with their supplies.";

            var optionOnePenalty = Penalty;

            Penalty = null;

            var optionOne = new Option(optionTitle, optionResultText, null, optionOnePenalty, EncounterType.Normal);

            Options.Add(optionTitle, optionOne);

            optionTitle = "Fight!";

            optionResultText = "Those supplies are essential to the group's survival. They must fight!";

            var fightOption = new FightCombatOption(optionTitle, optionResultText, bandits);

            Options.Add(optionTitle, fightOption);

            SubscribeToOptionSelectedEvent();

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.FourOptionEncounter, this);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Knight knight = new Knight(100f, 15f, 15f);
            Archer archer = new Archer(80f, 30f, 10f);
            Wizard wizard = new Wizard(50f, 40f, 5f);

            Barbarian   barbarian   = new Barbarian(150f, 20f, 5f);
            Crossbowman crossbowman = new Crossbowman(100f, 30f, 15f);
            Necromancer necromancer = new Necromancer(80f, 20f, 10f);

            Platoon platoon1 = new Platoon(1);
            Platoon platoon2 = new Platoon(2);

            platoon1.AddSoldier(knight);
            platoon1.AddSoldier(archer);
            platoon1.AddSoldier(wizard);

            platoon2.AddSoldier(barbarian);
            platoon2.AddSoldier(crossbowman);
            platoon2.AddSoldier(necromancer);

            Soldier soldier1;
            Soldier soldier2;
            bool    checkSoldiersInPlatoon = true;
            Random  rand = new Random();

            while (checkSoldiersInPlatoon != false)
            {
                for (int i = 0; i < platoon1.Count; i++)
                {
                    for (int y = 0; y < platoon2.Count; y++)
                    {
                        soldier1 = platoon2.GetSoldier(y);
                        soldier2 = platoon1.GetSoldier(i);
                        int index = rand.Next(0, 2);
                        if (index == 0)
                        {
                            platoon2.Atack(soldier1, soldier2.Damage);
                        }
                        else
                        {
                            soldier1.DoSpeciallSkill();
                        }
                        Atack(platoon1, platoon2, y, soldier1, soldier2);
                    }
                }

                for (int i = 0; i < platoon2.Count; i++)
                {
                    for (int y = 0; y < platoon1.Count; y++)
                    {
                        soldier1 = platoon1.GetSoldier(y);
                        soldier2 = platoon2.GetSoldier(i);
                        platoon1.Atack(soldier1, soldier2.Damage);
                        int index = rand.Next(0, 2);
                        if (index == 0)
                        {
                            Atack(platoon1, platoon2, y, soldier1, soldier2);
                        }
                        else
                        {
                            soldier1.DoSpeciallSkill();
                        }
                    }
                }
                checkSoldiersInPlatoon = platoon1.CheckSoldiersInPlatoon();
                checkSoldiersInPlatoon = platoon1.CheckSoldiersInPlatoon();
                Console.ReadKey();
            }
            bool checkPlatoon1 = platoon1.CheckSoldiersInPlatoon();
            bool checkPlatoon2 = platoon2.CheckSoldiersInPlatoon();

            if (checkPlatoon1 == false)
            {
                Console.WriteLine("Взвод № 1 уничтожен");
            }
            if (checkPlatoon2 == false)
            {
                Console.WriteLine("Взвод № 2 уничтожен");
            }
            Console.ReadKey();
        }