Exemple #1
0
    //one attack for each damage type.
    public void Attack(scr_CombatController target)
    {
        print(name + "is attacking.");
        var set = new int[6] {
            0, 0, 1, 1, 2, 3
        };

        Enumerations.AttackDie[] dice;
        //Physical Attack
        if (physicalAttack > 0)
        {
            dice = new Enumerations.AttackDie[physicalAttack];
            for (var i = 0; i < physicalAttack; i++)
            {
                var j = set[Utilities.RollDice(1) - 1];
                dice[i] = (Enumerations.AttackDie)j;
                print("Attack die " + i + ":" + dice[i]);
            }

            target.Defend(dice, Enumerations.DamageType.Physical, this);
        }

        //Magical Attack
        if (magicalAttack > 0)
        {
            dice = new Enumerations.AttackDie[magicalAttack];
            for (var i = 0; i < physicalAttack; i++)
            {
                var j = set[Utilities.RollDice(1) - 1];
                dice[i] = (Enumerations.AttackDie)j;
                print("Attack die " + i + ":" + dice[i]);
            }

            target.Defend(dice, Enumerations.DamageType.Magical, this);
        }

        //Pure Attack
        if (pureAttack > 0)
        {
            dice = new Enumerations.AttackDie[pureAttack];
            for (var i = 0; i < physicalAttack; i++)
            {
                var j = set[Utilities.RollDice(1) - 1];
                dice[i] = (Enumerations.AttackDie)j;
                print("Attack die " + i + ":" + dice[i]);
            }

            target.Defend(dice, Enumerations.DamageType.Pure, this);
        }

        attackedThisTurn = true;
    }
Exemple #2
0
        //TODO this believes that all attacks are of the same type
        public void Attack(ICombatant target, Enumerations.DamageType damageType)
        {
            var dice = new Enumerations.AttackDie[attackDice];
            var set  = new int[6] {
                0, 0, 1, 1, 2, 3
            };

            print("Attacking");
            for (var i = 0; i < attackDice; i++)
            {
                var j = set[Utilities.RollDice(1) - 1];
                dice[i] = (Enumerations.AttackDie)j;
                print("Attack die " + i + ":" + dice[i]);
            }

            target.Defend(dice, damageType, this);

            _attackedThisTurn = true;
        }
    public static void CastAbility(string abilityName, GameObject castingTarget, GameObject caster, bool isTrap = false)
    {
        Ability.AbilityStruct myAbility;
        PrepareAbility(abilityName);
        myAbility = allAbilities[abilityName];

        if (myAbility.durationType == Enumerations.SpellDuration.OverTime && myAbility.duration > 1)
        {
            myAbility.duration--;
            if (caster != null)
            {
                caster.GetComponent <scr_Monster>().activeAbilities.Add(myAbility);
            }
        }

        if (!myAbility.isAOE)
        {
            if (myAbility.damage > 0)
            {
                var attackDice = new Enumerations.AttackDie[myAbility.damage];
                for (var i = 0; i < myAbility.damage; i++)
                {
                    attackDice[i] = (Enumerations.AttackDie)Utilities.RollDice(1);
                }
                if (isTrap)
                {
                    castingTarget.GetComponent <scr_CombatController>().Defend(attackDice, Enumerations.DamageType.Pure, null);
                }
                else
                {
                    castingTarget.GetComponent <scr_CombatController>().Defend(attackDice, myAbility.damageType, null);
                }
            }
            else if (myAbility.damage < 0)
            {
                //Heal
                castingTarget.GetComponent <scr_CombatController>().TakeDamage(myAbility.damage);
            }

            if (castingTarget.GetComponent <scr_AffectedBy>() != null)
            {
                foreach (var bd in myAbility.buffsDebuffs)
                {
                    castingTarget.GetComponent <scr_AffectedBy>().AddEffect(bd);
                }
            }
        }
        else
        {
            var castingPoint = castingTarget;
            var xoff         = myAbility.tilesInAOE.ElementAt(0)[0];
            var yoff         = myAbility.tilesInAOE.ElementAt(0)[1];
            foreach (var coords in myAbility.tilesInAOE)
            {
                castingTarget = script_BoardController.GetTileByCoords((int)castingPoint.transform.position.x + coords[0] - xoff, (int)castingPoint.transform.position.y + coords[1] - yoff);
                if (castingTarget.GetComponent <script_Tile>().occupied)
                {
                    print("Casted on occupied");
                    castingTarget = castingTarget.GetComponent <script_Tile>().occupier;
                    if (myAbility.damage > 0)
                    {
                        var attackDice = new Enumerations.AttackDie[myAbility.damage];
                        for (var i = 0; i < myAbility.damage; i++)
                        {
                            attackDice[i] = (Enumerations.AttackDie)Utilities.RollDice(1);
                        }
                        if (isTrap)
                        {
                            castingTarget.GetComponent <scr_CombatController>().Defend(attackDice, Enumerations.DamageType.Pure, null);
                        }
                        else
                        {
                            castingTarget.GetComponent <scr_CombatController>().Defend(attackDice, myAbility.damageType, null);
                        }
                    }
                    else if (myAbility.damage < 0)
                    {
                        //Heal
                        castingTarget.GetComponent <scr_CombatController>().TakeDamage(myAbility.damage);
                    }

                    if (castingTarget.GetComponent <scr_AffectedBy>() != null)
                    {
                        foreach (var bd in myAbility.buffsDebuffs)
                        {
                            castingTarget.GetComponent <scr_AffectedBy>().AddEffect(bd);
                        }
                    }
                }
                else
                {
                    print("Unoccupied tile");
                }
            }
        }
    }