Example #1
0
        public void DamageTarget(Character attacker, int damage, Character target, DamageDoneDelegate del)
        {
            // Sometimes bouncy spells and other things can hit a creature two or more times.
            // If the creature is dead and the map agrees, return early, since the poor sob is already dead and gone.
            if (target.CurrentHP <= 0 && !m_map.Monsters.Contains(target))
                return;

            // -1 damage is coded for a miss
            if (damage == -1)
                return;

            target.Damage(damage);
            bool targetKilled = target.IsDead;
            
            if (del != null)
                del(damage, target, targetKilled);

            if (targetKilled)
            {
                if (target is Monster)
                {
                    if (attacker is Player)
                        ((Player)attacker).SkillPoints += 1;
                    m_map.RemoveMonster(target as Monster);
                    TreasureGenerator.Instance.DropTreasureFromMonster(target as Monster);
                }
                else if (target is Player)
                {
                    ((Player)target).EmptyStamina();
                    CoreGameEngine.Instance.PlayerDied();
                }
            }
        }
Example #2
0
 private void AttackRanged(Character attacker, Point attackTarget, object attackingMethod, DamageDoneDelegate del)
 {
     Character targetCharacter = FindTargetAtPosition(attackTarget);
     int damageDone = CalculateWeaponStrike(attacker, targetCharacter);
     RangedBoltToLocation(attacker, attackTarget, damageDone, attackingMethod, del);
 }
Example #3
0
        internal bool RangedBoltToLocation(Character attacker, Point target, int damageDone, object attackingMethod, DamageDoneDelegate del)
        {
            if (attacker.Position == target)
                return false;

            List<Point> attackPath = m_physicsEngine.GenerateRangedAttackListOfPoints(m_map, attacker.Position, target);

            Character targetCharacter = FindTargetAtPosition(target);
            CoreGameEngine.Instance.ShowRangedAttack(attackingMethod, ShowRangedAttackType.RangedBolt, attackPath, targetCharacter != null);

            if (targetCharacter != null)
                DamageTarget(attacker, damageDone, targetCharacter, del);

            if (targetCharacter is Monster)
                ((Monster)targetCharacter).NoticeRangedAttack(attacker.Position);

            return true;
        }