Example #1
0
 public DamageReport(Creature attacker, Creature defender, Power power, int damage, float multiplier)
 {
     this.Attacker = attacker;
     this.Defender = defender;
     this.Power = power;
     this.Damage = damage;
     this.Multiplier = multiplier;
 }
Example #2
0
 /// <summary>
 /// Creates a creature state from the attributes of a creature.
 /// </summary>
 /// <param name="creature"></param>
 public CreatureState(Creature creature)
 {
     this.Name = creature.Name;
     this.Health = creature.Health;
     this.Element = creature.Prototype.Element;
     this.IsHostile = creature.Hostile;
     this.Powers = creature.Prototype.AtWillPowers;
 }
Example #3
0
        /// <summary>
        /// Uses a random power on another creature.
        /// </summary>
        /// <param name="other">The target creature.</param>
        /// <returns>The power's damage report.</returns>
        public DamageReport UseRandomPower(Creature other)
        {
            //Nothing to do if no powers.
            if (this.Prototype.AtWillPowers.Count == 0) return new DamageReport(this, other, null, 0, 1);

            int index = Creature.RNG.Next(this.Prototype.AtWillPowers.Count);
            return this.Prototype.AtWillPowers[index].Use(this, other);
        }
Example #4
0
        /// <summary>
        /// Uses the power on the given target, calculating the modified damage
        /// based on the results of Element comparisons.
        /// </summary>
        /// <param name="attacker">The attacking creature.</param>
        /// <param name="target">The target creature.</param>
        /// <returns>The damage report for the power usage.</returns>
        public DamageReport Use(Creature attacker, Creature target)
        {
            float baseDamage = this.MinDamage + (this.MaxDamage - this.MinDamage) * (float)Power.RNG.NextDouble();
            float multiplier = this.Resolve(target.Prototype.Element);
            int damage = (int)(baseDamage * multiplier);

            target.AlterHealth(-damage);

            return new DamageReport(attacker, target, this, damage, multiplier);
        }
Example #5
0
        /// <summary>
        /// Gets a random target for a given creature.
        /// </summary>
        /// <param name="attacker">The creature requesting a target.</param>
        /// <returns>A random, valid target.</returns>
        public Creature GetRandomTarget(Creature attacker)
        {
            //Snag all the valid targets.
            List<Creature> otherTeam = (this.FriendlyTeam.Contains(attacker)) ? this.HostileTeam : this.FriendlyTeam;
            List<Creature> validTargets = new List<Creature>();

            foreach (Creature c in otherTeam) {
                if (c.Health > 0) validTargets.Add(c);
            }

            //Pick a random one.
            return validTargets[Battle.RNG.Next(validTargets.Count)];
        }