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; }
public TargetingStrategyButton(ContentControl container, Actor actor, TargetingStrategy strategy, Texture2D texture) { this.container = container; this.Actor = actor; this.TargetingStrategy = strategy; this.texture = texture; }
public EquipmentScreen(Player player, IEnumerable<Actor> actors, Actor actor) { this.player = player; this.actors = new List<Actor>(actors); this.currentActor = actor; player.Inventory.Sort((i1, i2) => i1.ArmorClass.CompareTo(i2.ArmorClass)); }
public ActorModel(Actor actor, Texture2D texture, ContentManager contentManager, GraphicsDevice graphicsDevice, Effect effect) { this.contentManager = contentManager; this.graphicsDevice = graphicsDevice; this.effect = effect; this.texture = texture; this.Actor = actor; }
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; }
public OrderButton(ContentControl container, Actor actor, Order order, Texture2D texture, Texture2D blankTexture, Texture2D targetTexture, SpriteFont font) { this.container = container; this.Actor = actor; this.Order = order; this.texture = texture; this.blankTexture = blankTexture; this.targetTexture = targetTexture; this.font = font; }
public override void Execute(EncounterDefinition encounterDefinition, Battle battle) { var actorDefinition = encounterDefinition.Actors.SingleOrDefault(x => x.Id == ActorId); var actor = new Actor(actorDefinition) { Position = Position, Direction = Vector2.Normalize(new Vector2(-1, -1)), TargettingStrategy = TargettingStrategies.Threat, }; battle.Actors.Add(actor); }
public AdvancedActorModel(Actor actor, Model model, ContentManager contentManager) { this.contentManager = contentManager; this.Actor = actor; this.Model = model; var skinningData = model.Tag as SkinningData; AnimationPlayer = new AnimationPlayer(skinningData); if (skinningData.AnimationClips.ContainsKey("Stand")) AnimationPlayer.StartClip(skinningData.AnimationClips["Stand"], true); else AnimationPlayer.StartClip(skinningData.AnimationClips.First().Value, true); AnimationPlayer.Update(TimeSpan.FromSeconds(0), true, Matrix.Identity); }
public Shadow(GraphicsDevice graphicsDevice, Effect effect, Texture2D texture, Actor actor) { this.graphicsDevice = graphicsDevice; this.effect = effect; this.texture = texture; this.actor = actor; vertices = new VertexPositionTexture[6]; vertices[0] = new VertexPositionTexture(new Vector3(-1, 0, -1), new Vector2(0, 0)); vertices[1] = new VertexPositionTexture(new Vector3(1, 0, -1), new Vector2(1, 0)); vertices[2] = new VertexPositionTexture(new Vector3(-1, 0, 1), new Vector2(0, 1)); vertices[3] = new VertexPositionTexture(new Vector3(1, 0, -1), new Vector2(1, 0)); vertices[4] = new VertexPositionTexture(new Vector3(1, 0, 1), new Vector2(1, 1)); vertices[5] = new VertexPositionTexture(new Vector3(-1, 0, 1), new Vector2(0, 1)); }
public AbilityAnimation(Actor actor, GraphicsDevice graphicsDevice, Effect billboardEffect, Texture2D texture) { this.actor = actor; this.graphicsDevice = graphicsDevice; this.billboardEffect = billboardEffect; this.texture = texture; vertices = new VertexPositionTexture[6]; vertices[0] = new VertexPositionTexture(new Vector3(-1, 0, -1), new Vector2(0, 0)); vertices[1] = new VertexPositionTexture(new Vector3(1, 0, -1), new Vector2(1, 0)); vertices[2] = new VertexPositionTexture(new Vector3(-1, 0, 1), new Vector2(0, 1)); vertices[3] = new VertexPositionTexture(new Vector3(1, 0, -1), new Vector2(1, 0)); vertices[4] = new VertexPositionTexture(new Vector3(1, 0, 1), new Vector2(1, 1)); vertices[5] = new VertexPositionTexture(new Vector3(-1, 0, 1), new Vector2(0, 1)); }
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; }
private void BuyAbility(Actor actor, Ability ability) { if (actor != null && ability != null) { //player.Gold -= actor.Cost; actor.Abilities.Add(ability); availableAbilities.Remove(ability); } }
public static float DistanceFrom(this Vector2 position, Actor actor) { return (actor.Position - position).Length(); }
public static float DistanceFrom(this Actor actor, Actor target) { return (target.Position - actor.Position).Length(); }
public void TargetActor(Actor target) { if (IsAlive && PlayerControlled) { Targets.Clear(); Orders.Clear(); OrderedDestination = null; if (!Targets.Contains(target)) Targets.Enqueue(target); } }
private void FindMouseOverActor(MouseState mouseState, Vector2 mouseWorldLocation) { if (mouseState.X > 0 && mouseState.X < 150 && mouseState.Y > 0 && mouseState.Y < 50 * battle.Actors.Count) mouseOverActor = battle.Actors[mouseState.Y / 50]; else mouseOverActor = null; foreach (var actor in battle.Actors.Where(x => x.IsAlive)) { if ((actor.Position - mouseWorldLocation).Length() < actor.Diameter) mouseOverActor = actor; } }
private void UpdateAbilityList(Actor actor) { //var index = abilitiesListBox.SelectedIndex; //abilitiesListBox.Items.Clear(); //if (actor != null) //{ // actor.Abilities.ForEach(ability => // { // abilitiesListBox.Items.Add( // ability, // new AbilityTooltip(actor, ability), // Color.Yellow); // }); //} //abilitiesListBox.SelectedIndex = index; }
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; }
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 }); }
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; }
private Color GetRangeColor(Actor actor) { if (actor.CurrentOrder == null) return Color.LightGray; var target = actor.CurrentOrder.GetTargetLocation(); if (target.DistanceFrom(actor).In(ability.Range + actor.Radius + actor.CurrentOrder.GetTargetRadius())) return Color.LightGray; return Color.Tomato; }
private void IssueOrder(Actor actor, Order order) { if (isPaused) actor.Orders.Add(order); else actor.Orders.Insert(0, order); }
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); } }
private bool UseOrder(Turn turn, Actor actor, Order order) { var ability = order.Ability; if (!ability.Cooldown.IsReady) return false; if (ability.DamageType == DamageTypes.SingleTarget) { var abilityTarget = order.TargetActor; if (abilityTarget != null && abilityTarget.IsAlive) { if (ability.TargettingType == TargettingTypes.Hostile && actor.Faction == abilityTarget.Faction) return false; if (ability.TargettingType == TargettingTypes.Friendly && actor.Faction != abilityTarget.Faction) return false; if (order.GetTargetLocation().DistanceFrom(actor).In(ability.Range + actor.Radius + abilityTarget.Radius)) { actor.CurrentOrder = order; actor.CastingProgress = new Cooldown(ability.Duration); actor.CastingProgress.Incur(); if (ability.IsChanneled) { actor.ChannelProgress = new Cooldown(1.0f); actor.ChannelProgress.Incur(); } return true; } } } else if (ability.DamageType == DamageTypes.PointBlankArea) { actor.CurrentOrder = order; actor.CastingProgress = new Cooldown(ability.Duration); actor.CastingProgress.Incur(); if (ability.IsChanneled) { actor.ChannelProgress = new Cooldown(1.0f); actor.ChannelProgress.Incur(); } return true; } else if (ability.DamageType == DamageTypes.Cleave) { var primaryTarget = order.TargetActor; if (primaryTarget != null && primaryTarget.IsAlive) { if (ability.TargettingType == TargettingTypes.Hostile && actor.Faction == primaryTarget.Faction) return false; if (ability.TargettingType == TargettingTypes.Friendly && actor.Faction != primaryTarget.Faction) return false; if (order.GetTargetLocation().DistanceFrom(actor).In(ability.Range + actor.Radius + order.GetTargetRadius())) { actor.CurrentOrder = order; actor.CastingProgress = new Cooldown(ability.Duration); actor.CastingProgress.Incur(); if (ability.IsChanneled) { actor.ChannelProgress = new Cooldown(1.0f); actor.ChannelProgress.Incur(); } return true; } } } else if (ability.DamageType == DamageTypes.Location) { if (order.GetTargetLocation().DistanceFrom(actor).In(ability.Range + actor.Radius)) { actor.CurrentOrder = order; actor.CastingProgress = new Cooldown(ability.Duration); actor.CastingProgress.Incur(); if (ability.IsChanneled) { actor.ChannelProgress = new Cooldown(1.0f); actor.ChannelProgress.Incur(); } return true; } } return false; }
private void SellHero(Actor hero) { if (hero != null) { player.Gold += hero.Cost / 4; foreach (var item in hero.Equipment.ToArray()) hero.Unequip(player, item); player.Heroes.Remove(hero); //availableHeroes.Add(hero); } }
public void QueueTargetActor(Actor target) { if (IsAlive && PlayerControlled) { if (!Targets.Contains(target)) Targets.Enqueue(target); } }
private void UpdateEquipmentList(Actor actor) { //var index = equipmentListBox.SelectedIndex; //equipmentListBox.Items.Clear(); //if (actor != null) //{ // actor.Equipment.ForEach(item => // { // equipmentListBox.Items.Add( // item, // new ItemTooltip(item) { ShowZeroValues = false }, // ItemTooltip.GetItemColor(item.Rarity)); // }); //} //equipmentListBox.SelectedIndex = index; }
public float CalculateHealing(Actor actor, Actor target) { var value = (actor.CurrentStatistics.For<AttackPower>().Value * AttackPowerScale + actor.CurrentStatistics.For<SpellPower>().Value * SpellPowerScale + Value); value = random.Between(value * actor.CurrentStatistics.For<Precision>().Chance, value); value = value * actor.CurrentStatistics.For<HealingDone>().Value; value = value * target.CurrentStatistics.For<HealingTaken>().Value; return value; }
private void prevActorButton_Click() { var index = actors.IndexOf(currentActor); index = (index - 1 + actors.Count) % actors.Count; currentActor = actors[index]; UpdateEquipmentList(); UpdateInventoryList(); }
private void RunActorAuras(float deltaTime, Turn turn, Actor actor) { var damageDone = 0f; foreach (var aura in actor.Auras) { aura.Cooldown.Cool(deltaTime); aura.Duration -= deltaTime; if (aura.Cooldown.IsReady) { var combatTable = new CombatTable(new Random(), aura.Owner.CurrentStatistics, actor.CurrentStatistics); var roll = combatTable.Roll(); var damage = aura.Damage.CalculateDamage(aura.Owner, actor); var healing = aura.Healing.CalculateHealing(aura.Owner, actor); if (roll.IsCrit) { damage *= 2; healing *= 2; } if (damage > 0) { damageDone += damage; Event.Raise(new ActorTookDamage { Source = aura.Owner, Target = actor, Damage = damage, IsCrit = roll.IsCrit }); turn.Events.Add(new OldEvent(EventTypes.AuraDamage) { Actor = aura.Owner, Target = actor, Damage = damage }); actor.CurrentHealth -= damage; } if (healing > 0) { Event.Raise(new ActorWasHealed { Source = aura.Owner, Target = actor, Healing = healing, IsCrit = roll.IsCrit }); turn.Events.Add(new OldEvent(EventTypes.AuraHealing) { Actor = aura.Owner, Target = actor, Healing = healing }); actor.CurrentHealth += healing; } aura.Cooldown.Incur(); } } if (damageDone > 0) actor.Auras.RemoveAll(x => x.BreaksOnDamage); actor.Auras.ForEach(aura => { if (aura.Duration <= 0f) { turn.Events.Add(new OldEvent(EventTypes.AuraExpired) { Actor = actor, Target = actor }); } }); actor.Auras.RemoveAll(aura => aura.Duration <= 0f); }