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; }
private void IssueOrder(Actor actor, Order order) { if (isPaused) actor.Orders.Add(order); else actor.Orders.Insert(0, order); }
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 ApplyChannelAbility(Turn turn, Actor actor, Order order) { if (order.Ability.DamageType == DamageTypes.SingleTarget) { var abilityTarget = order.TargetActor; if (abilityTarget != null && abilityTarget.IsAlive) { if (abilityTarget.DistanceFrom(actor).In(order.Ability.Range + actor.Radius + abilityTarget.Radius)) ApplySingleTargetAbility(turn, actor, order.Ability, abilityTarget); } } else if (order.Ability.DamageType == DamageTypes.PointBlankArea) { ApplyPointBlankAreaAbility(turn, actor, order.Ability); } else if (order.Ability.DamageType == DamageTypes.Cleave) { var primaryTarget = order.TargetActor; if (primaryTarget != null && primaryTarget.IsAlive) { if (primaryTarget.DistanceFrom(actor).In(order.Ability.Range + actor.Radius + primaryTarget.Radius)) ApplyCleaveAbility(turn, actor, order.Ability, primaryTarget); } } else if (order.Ability.DamageType == DamageTypes.Location) { ApplyLocationAbility(turn, actor, order.Ability, order.TargetLocation.Value); } if (actor.CastingProgress.IsReady) { actor.CurrentOrder = null; actor.CastingProgress = null; actor.ChannelProgress = null; } else { actor.ChannelProgress.Incur(); } }