public void UpdateAttackImpacts(DefenderAttackInstructions defenderInstructions, string impactName, bool isEffectEnabled) { if (this.CurrentAttackInstructions is MultiAttackInstructions) { MultiAttackInstructions multiInstructions = this.CurrentAttackInstructions as MultiAttackInstructions; if (multiInstructions.Defenders.Contains(defenderInstructions.Defender)) { foreach (var ins in multiInstructions.IndividualTargetInstructions.Where(i => i.Defender == defenderInstructions.Defender)) { ChangeImpact(ins, impactName, isEffectEnabled); } } else if (multiInstructions.Obstacles.Any(o => o.ObstacleTarget == defenderInstructions.Defender)) { var obstacle = multiInstructions.Obstacles.First(o => o.ObstacleTarget == defenderInstructions.Defender); ChangeImpact(obstacle.ObstacleInstructions, impactName, isEffectEnabled); } } else { var instructions = defenderInstructions.AttackerHitInfo.Where(ahi => ahi.AttackInstructionsForAttacker.Defender == defenderInstructions.Defender)?.Select(ahi => ahi.AttackInstructionsForAttacker)?.FirstOrDefault(); ChangeImpact(instructions, impactName, isEffectEnabled); } this.SetAttackSummaryText(); }
public void ChangeCenterTarget(object state) { DefenderAttackInstructions dins = state as DefenderAttackInstructions; if (dins.IsAttackCenter) { AttackInstructions ins = this.AttackInstructionsCollection.FirstOrDefault(ai => ai.Defender == dins.Defender); ins.IsCenterOfAreaEffectAttack = true; foreach (AttackInstructions ai in this.AttackInstructionsCollection.Where(instr => instr != ins)) { ai.IsCenterOfAreaEffectAttack = false; } } }
public void ChangeAttackHit(AttackerHitInfo attackHitInfo) { DefenderAttackInstructions defenderInstructions = this.DefenderAttackInstructions.FirstOrDefault(d => d.Defender == attackHitInfo.AttackInstructionsForAttacker.Defender); if (attackHitInfo.AttackInstructionsForAttacker.AttackHit) { defenderInstructions.DefenderHitByAttack = attackHitInfo.AttackInstructionsForAttacker.AttackHit; } else { if (!defenderInstructions.AttackerHitInfo.Any(ah => ah != attackHitInfo && ah.AttackInstructionsForAttacker.AttackHit)) { defenderInstructions.DefenderHitByAttack = attackHitInfo.AttackInstructionsForAttacker.AttackHit; } } this.SetAttackSummaryText(); }
private void SetDefenderInstructions() { this.DefenderAttackInstructions = new ObservableCollection <DefenderAttackInstructions>(); if (CurrentAttackInstructions is MultiAttackInstructions) { MultiAttackInstructions multiAttackInstructions = CurrentAttackInstructions as MultiAttackInstructions; this.AttackInstructionsCollection = multiAttackInstructions.IndividualTargetInstructions; foreach (var defender in multiAttackInstructions.Defenders) { DefenderAttackInstructions defenderAttackInstructions = new DefenderAttackInstructions(); defenderAttackInstructions.Defender = defender; defenderAttackInstructions.AttackerHitInfo = new ObservableCollection <AttackerHitInfo>(); if (this.Attackers.Count > 1) { defenderAttackInstructions.HasMultipleAttackers = true; } foreach (var attacker in this.Attackers) { AttackInstructions instructionForAttacker = multiAttackInstructions.IndividualTargetInstructions.FirstOrDefault(i => i.Defender == defender && i.Attacker == attacker); defenderAttackInstructions.AttackerHitInfo.Add(new AttackerHitInfo { Attacker = attacker, AttackInstructionsForAttacker = instructionForAttacker }); } this.DefenderAttackInstructions.Add(defenderAttackInstructions); } } else { this.AttackInstructionsCollection = new ObservableCollection <AttackInstructions> { CurrentAttackInstructions }; DefenderAttackInstructions defenderAttackInstructions = new DefenderAttackInstructions(); defenderAttackInstructions.Defender = CurrentAttackInstructions.Defender; defenderAttackInstructions.AttackerHitInfo = new ObservableCollection <AttackerHitInfo>(); defenderAttackInstructions.AttackerHitInfo.Add(new AttackerHitInfo { AttackInstructionsForAttacker = CurrentAttackInstructions }); this.DefenderAttackInstructions.Add(defenderAttackInstructions); } foreach (var obst in CurrentAttackInstructions.Obstacles.Where(o => o.ObstacleTarget is AnimatedCharacter)) { DefenderAttackInstructions defenderAttackInstructions = new DefenderAttackInstructions(); defenderAttackInstructions.Defender = obst.ObstacleTarget as AnimatedCharacter; defenderAttackInstructions.AttackerHitInfo = new ObservableCollection <AttackerHitInfo>(); defenderAttackInstructions.AttackerHitInfo.Add(new AttackerHitInfo { AttackInstructionsForAttacker = obst.ObstacleInstructions }); this.DefenderAttackInstructions.Add(defenderAttackInstructions); } foreach (var dai in this.DefenderAttackInstructions) { dai.PropertyChanged += DefenderAttackInstructions_PropertyChanged; } }