Ejemplo n.º 1
0
        public Order(Ability ability, Actor actor, Actor targetActor = null, Vector2? targetLocation = null)
        {
            if (ability == null)
                throw new ArgumentNullException("ability");

            if (targetActor == null && targetLocation == null)
                throw new ArgumentNullException("targetActor OR targetLocation");

            if (targetActor != null && targetLocation != null)
                throw new ArgumentException("Cannot specify both target actor and target location");

            if (ability.TargettingType == TargettingTypes.Hostile && targetActor.Faction == actor.Faction)
                throw new ArgumentException("Ability " + ability.Name + " must target hostile actors.");

            if (ability.TargettingType == TargettingTypes.Friendly && targetActor.Faction != actor.Faction)
                throw new ArgumentException("Ability " + ability.Name + " must target friendly actors.");

            if (ability.TargettingType == TargettingTypes.Self && targetActor != actor)
                throw new ArgumentException("Ability " + ability.Name + " must target self.");

            if (ability.TargettingType == TargettingTypes.Location && targetLocation == null)
                throw new ArgumentException("Ability " + ability.Name + " must target a location.");

            this.Ability = ability;
            this.TargetActor = targetActor;
            this.TargetLocation = targetLocation;
        }
Ejemplo n.º 2
0
        public CombatTable(Random random, Statistics actorStatistics, Statistics targetStatistics, Ability ability)
        {
            this.random = random;

            dodgeChance = ability.CanBeDodged ? targetStatistics.For<Dodge>().Chance : 0;
            hitChance = ability.CanMiss ? actorStatistics.For<Hit>().Chance : 1;
            critChance = ability.CanCrit ? actorStatistics.For<CriticalStrike>().Chance : 0;
            blockChance = ability.CanBeBlocked ? targetStatistics.For<Block>().Chance : 0;
        }
Ejemplo n.º 3
0
 public AbilityButton(ContentControl container, Actor actor, Ability ability, Texture2D texture, Texture2D blankTexture, SpriteFont font)
 {
     this.container = container;
     this.Actor = actor;
     this.Ability = ability;
     this.texture = texture;
     this.blankTexture = blankTexture;
     this.font = font;
 }
Ejemplo n.º 4
0
 private void SellAbility(Actor actor, Ability ability)
 {
     if (actor != null && ability != null && actor.Abilities.Contains(ability))
     {
         //player.Gold += actor.Cost / 4;
         actor.Abilities.Remove(ability);
         availableAbilities.Add(ability);
     }
 }
Ejemplo n.º 5
0
        private Color GetAbilityColor(Actor actor, Ability ability)
        {
            if (actor != null)
            {
                if (ability.ManaCost != 0 && actor.ResourceType != ActorResourceTypes.Mana)
                    return Color.Salmon;

                if (ability.EnergyCost != 0 && actor.ResourceType != ActorResourceTypes.Energy)
                    return Color.Salmon;
            }

            return Color.LightGray;
        }
Ejemplo n.º 6
0
 private void BuyAbility(Actor actor, Ability ability)
 {
     if (actor != null && ability != null)
     {
         //player.Gold -= actor.Cost;
         actor.Abilities.Add(ability);
         availableAbilities.Remove(ability);
     }
 }
Ejemplo n.º 7
0
 private void addAbilityButton_Click(object sender, EventArgs e)
 {
     var ability = new Ability();
     abilitiesListBox.Items.Add(ability);
     actor.Abilities.Add(ability);
 }
Ejemplo n.º 8
0
 public AbilityTooltip(Binding<Actor> actor, Ability ability)
 {
     this.actorBinding = actor;
     this.ability = ability;
     lines = new List<Line>();
 }
Ejemplo n.º 9
0
        private bool ValidLocationAreaTarget(Actor actor, Actor target, Ability ability, Vector2 location)
        {
            if (target.Faction == actor.Faction && ability.TargettingType == TargettingTypes.Hostile)
                return false;

            if (target.Faction != actor.Faction && ability.TargettingType == TargettingTypes.Friendly)
                return false;

            if (target.Faction == actor.Faction && ability.TargettingType == TargettingTypes.Location)
                return false;

            if (target.DistanceFrom(location) <= ability.Area + target.Radius)
                return true;

            return false;
        }
Ejemplo n.º 10
0
        private bool ValidPointBlankAreaTarget(Actor actor, Actor target, Ability ability)
        {
            if (target.Faction == actor.Faction && ability.TargettingType == TargettingTypes.Hostile)
                return false;

            if (target.Faction != actor.Faction && ability.TargettingType == TargettingTypes.Friendly)
                return false;

            if (target.DistanceFrom(actor) <= ability.Area + target.Radius)
                return true;

            return false;
        }
Ejemplo n.º 11
0
 private void SpawnProjectile(Actor actor, Actor target, Ability ability)
 {
     Projectiles.Add(new Projectile
     {
         Ability = ability,
         Owner = actor,
         Target = target,
         Position = new Vector3(actor.Position, actor.Radius),
         Speed = ability.SpawnsProjectile.Speed,
         ModelName = ability.SpawnsProjectile.ModelName,
         TextureName = ability.SpawnsProjectile.TextureName
     });
 }
Ejemplo n.º 12
0
        private void ApplySingleTargetAbility(Turn turn, Actor actor, Ability ability, Actor abilityTarget)
        {
            if (ability.SpawnsProjectile != null)
            {
                SpawnProjectile(actor, abilityTarget, ability);
            }
            else
            {
                ApplyAbilityOutcome(turn, actor, ability, abilityTarget);
            }

            ability.Cooldown.Incur();
        }
Ejemplo n.º 13
0
        private void ApplyPointBlankAreaAbility(Turn turn, Actor actor, Ability ability)
        {
            foreach (var target in Actors.Where(x => x.IsAlive))
            {
                if (ValidPointBlankAreaTarget(actor, target, ability))
                {
                    ApplyAbilityOutcome(turn, actor, ability, target);
                }
            }

            foreach (var animation in ability.Animations)
            {
                // TODO: This wont work if the same animation triggers on the same frame
                animation.Position = actor.Position;
                animation.Scale = ability.Area;
                GraphicEffects.Enqueue(animation);
            }

            ability.Cooldown.Incur();
        }
Ejemplo n.º 14
0
        private void ApplyCleaveAbility(Turn turn, Actor actor, Ability ability, Actor primaryTarget)
        {
            foreach (var secondaryTarget in Actors.Where(x => x.IsAlive))
            {
                if ((secondaryTarget.DistanceFrom(primaryTarget) - primaryTarget.Radius - secondaryTarget.Radius) > ability.Area)
                    continue;

                if (secondaryTarget.Faction == actor.Faction && ability.TargettingType == TargettingTypes.Hostile)
                    continue;

                if (secondaryTarget.Faction != actor.Faction && ability.TargettingType == TargettingTypes.Friendly)
                    continue;

                if (ability.SpawnsProjectile != null)
                {
                    SpawnProjectile(actor, secondaryTarget, ability);
                }
                else
                {
                    ApplyAbilityOutcome(turn, actor, ability, secondaryTarget);
                }

                ability.Cooldown.Incur();
            }
        }
Ejemplo n.º 15
0
        private void ApplyAbilityOutcome(Turn turn, Actor actor, Ability ability, Actor target)
        {
            var combatTable = new CombatTable(random, actor.CurrentStatistics, target.CurrentStatistics, ability);
            var combatOutcome = combatTable.Roll();

            var abilityDamage = ability.Damage.CalculateDamage(actor, target);
            var abilityHealing = ability.Healing.CalculateHealing(actor, target);

            var damage = 0f;
            var damage2 = 0f;
            var healing = 0f;
            var blocked = 0f;

            if (combatOutcome.IsMiss)
                Event.Raise(new ActorMissed { Source = actor, Target = target });

            if (combatOutcome.IsDodge)
                Event.Raise(new ActorDodged { Source = actor, Target = target });

            if (combatOutcome.IsHit)
            {
                damage = abilityDamage;
                healing = abilityHealing;
            }

            if (combatOutcome.IsCrit)
            {
                damage = damage * 2f;
                healing = healing * 2f;
            }

            if (combatOutcome.IsBlock)
            {
                blocked = Math.Min(damage, actor.CurrentStatistics.For<Armor>().Rating * 0.1f);
                damage -= blocked;
                Event.Raise(new ActorBlocked { Source = actor, Target = target });
            }

            actor.CurrentMana -= ability.ManaCost;
            actor.CurrentEnergy -= ability.EnergyCost;

            if (damage > 0)
            {
                target.CurrentHealth -= (damage);
                Event.Raise(new ActorTookDamage { Source = actor, Target = target, Damage = damage, IsCrit = combatOutcome.IsCrit });

                actor.Auras.RemoveAll(x => x.BreaksOnDamage);
            }

            if (healing > 0)
            {
                target.CurrentHealth += (healing);
                Event.Raise(new ActorWasHealed { Source = actor, Target = target, Healing = healing, IsCrit = combatOutcome.IsCrit });
            }

            // Calculate damage threat
            target.ThreatList.Increase(actor, (int)(damage * ability.ThreatModifier));

            // Calculate healing threat for all enemies who knows the healer exists
            foreach (var enemyActor in Actors.Where(a => a.Faction != actor.Faction && a.ThreatList.Exists(healedActor => healedActor.Actor == target)))
            {
                enemyActor.ThreatList.Increase(actor, (int)(healing * 0.05f));
            }

            // Apply auras
            foreach (var aura in ability.AurasApplied)
            {
                target.Auras.Add(new Aura { Owner = actor, Cooldown = aura.Cooldown, Damage = aura.Damage, Healing = aura.Healing, Duration = aura.Duration, Name = aura.Name, Statistics = aura.Statistics, BreaksOnDamage = aura.BreaksOnDamage });
            }

            turn.Events.Add(new OldEvent(EventTypes.Ability)
            {
                Actor = actor,
                Target = target,
                Damage = damage,
                Damage2 = damage2,
                Healing = healing,
                Blocked = blocked,
                Ability = ability,
                CombatOutcome = combatOutcome
            });
        }