Example #1
0
    public Attack PerformMainHandAttack(int targetArmorClass)
    {
        //Отметим, что действие в этот ход уже совершалось
        actionAvailable = false;

        DamageDieRoll   damageDice                = null;
        DamageType      damageType                = DamageType.Bludgeoning; // Если оружия в руках нет - тип урона рукопашной атаки по умолчанию дробящий
        List <DieRoll>  additionalDamageRolls     = null;
        List <Modifier> additionalDamageModifiers = null;

        if (onMainHand != null)
        {
            damageDice = new DamageDieRoll(onMainHand.DamageDice, onMainHand.DamageType);
        }
        else
        {
            //Рукопашная атака наносит 1 повреждение + бонус Силы
            damageDice = new DamageDieRoll(DiceSet.GetByName("none"), damageType);

            additionalDamageModifiers = new List <Modifier>
            {
                new DamageModifier("Unarmed strike", 1, damageType),
                new DamageModifier(Ability.Strenght.Shortcut, Ability.GetAbilityModifier(currentStrenght), damageType)
            };
        }

        AttackCheckBuilder attackBuilder = new AttackCheckBuilder(
            Ability.Strenght,
            currentStrenght,
            targetArmorClass,
            masteryBonus,
            new RollWithCriticals());

        ValueDefinitionDirector.ConstructValueDefinition(attackBuilder);
        AttackCheck attackCheck = attackBuilder.GetResult() as AttackCheck;

        DamageValueBuilder damageValueBuilder = new DamageValueBuilder(
            damageDice,
            Ability.Strenght,
            currentStrenght,
            false,
            additionalDamageRolls,
            additionalDamageModifiers);

        ValueDefinitionDirector.ConstructValueDefinition(damageValueBuilder);
        DamageValueDefinition damageValueDefinition = damageValueBuilder.GetResult() as DamageValueDefinition;

        return(new Attack(attackCheck, damageValueDefinition));
    }
Example #2
0
    void Awake()
    {
        logEvent = new StringEvent();

        LogWindow logWindow = GameObject.Find("LogWindow").GetComponent <LogWindow>();

        logEvent.AddListener(logWindow.DisplayIntoLogWindow);

        //Для тестирования установим персонажам некоторую экипировку
        if (name == "Warrior")
        {
            onMainHand = new Weapon("Longsword", 3, 15, EquipmentType.FindByShortcut("M"), DiceSet.GetByName("1d8"), DamageType.Slashing, 5);
            armor      = new Armor("Chain Mail", 55, 75, EquipmentType.FindByShortcut("HA"), 16);
        }
        else if (name == "Wizard")
        {
            //onMainHand = new Weapon("Quarterstaff", 2, 4, EquipmentType.FindByShortcut("M"), DiceSet.GetDiceSet("1d6"), DamageType.FindByShortcut("B"), 5);
            onMainHand = new Weapon("Fire bolt", 0, 0, EquipmentType.FindByShortcut("R"), DiceSet.GetByName("1d10"), DamageType.Fire, 30);
        }
        //Если зомби - установим оружие "когти зомби"
        else if (name.Contains("Zombie"))
        {
            onMainHand = new Weapon("Zombie's claws", 0, 0, EquipmentType.FindByShortcut("M"), DiceSet.GetByName("1d6"), DamageType.Bludgeoning, 5);
        }

        InitializeParameters();
        CalculateArmorClass();
        CalculateInitiative();
        DefineAttackRange();
    }