Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
    private void initializeGame()
    {
        MoveTowardsTarget movement_script_current;
        MeleeCombatAI melee_combat_script;

        Unit unit;

        GameObject[] preset_units_man_at_arms = GameObject.FindGameObjectsWithTag("PlayerUnit_MAA");
        GameObject[] preset_units_archer = GameObject.FindGameObjectsWithTag("PlayerUnit_ARCHER");
        GameObject unit_faction_leader = GameObject.FindGameObjectWithTag("PlayerUnit_FL");

        foreach(GameObject elem in preset_units_man_at_arms)
        {
            unit = new ManAtArms();
            unit.setGameObject(elem);
            ObjectBank.instance().addPlayerUnit(ref unit);

            unit.setCombatFocus(Unit.OFFENSIVE_FOCUS);

            movement_script_current = elem.GetComponent<MoveTowardsTarget>();
            movement_script_current.setUnitAgility(unit.getAgility());
        }

        foreach (GameObject elem in preset_units_archer)
        {
            unit = new Archer();
            unit.setGameObject(elem);
            ObjectBank.instance().addPlayerUnit(ref unit);

            unit.setCombatFocus(Unit.OFFENSIVE_FOCUS);

            movement_script_current = elem.GetComponent<MoveTowardsTarget>();
            movement_script_current.setUnitAgility(unit.getAgility());
        }

        if (unit_faction_leader != null)
        {
            unit = new FactionLeader();
            unit.setGameObject(unit_faction_leader);
            ObjectBank.instance().addPlayerUnit(ref unit);

            unit.setCombatFocus(Unit.OFFENSIVE_FOCUS);

            movement_script_current = unit_faction_leader.GetComponent<MoveTowardsTarget>();
            movement_script_current.setUnitAgility(unit.getAgility());
        }

        //Enemy units.
        preset_units_man_at_arms = GameObject.FindGameObjectsWithTag("EnemyUnit_MAA");
        preset_units_archer = GameObject.FindGameObjectsWithTag("EnemyUnit_ARCHER");

        foreach (GameObject elem in preset_units_man_at_arms)
        {
            unit = new ManAtArms();
            unit.setGameObject(elem);
            ObjectBank.instance().addEnemyUnit(ref unit);

            unit.setCombatFocus(Unit.DEFENSIVE_FOCUS);

            melee_combat_script = elem.GetComponent<MeleeCombatAI>();
            melee_combat_script.initialize(Unit.MAX_HIT_POINTS,
                                           unit.getDefaultMorale(),
                                           unit.getArmor().getDamageReductionFactor());

            movement_script_current = elem.GetComponent<MoveTowardsTarget>();
            movement_script_current.setUnitAgility(unit.getAgility());
        }

        foreach (GameObject elem in preset_units_archer)
        {
            unit = new Archer();
            unit.setGameObject(elem);
            ObjectBank.instance().addEnemyUnit(ref unit);

            unit.setCombatFocus(Unit.DEFENSIVE_FOCUS);

            movement_script_current = elem.GetComponent<MoveTowardsTarget>();
            movement_script_current.setUnitAgility(unit.getAgility());
        }

        Debug.Log("Number player units: " + ObjectBank.instance().getUnitList().Length );
        Debug.Log("Number enemy units: " + ObjectBank.instance().getEnemyUnitList().Length );
    }