private void SetAttackParameters() { foreach (var defenderInstructions in this.DefenderAttackInstructions) { if (defenderInstructions.DefenderHitByAttack) { if (!defenderInstructions.HasMultipleAttackers) { this.CurrentAttackInstructions.AttackHit = true; defenderInstructions.AttackerHitInfo[0].AttackInstructionsForAttacker.AttackHit = true; } } if (defenderInstructions.DefenderKnockbackDistance > 0) { var obstacle = this.CurrentAttackInstructions.Obstacles.FirstOrDefault(o => o.Defender == defenderInstructions.Defender && o.ObstacleType == ObstacleType.Knockback); AttackerHitInfo instructionToSetKnockback = null; if (obstacle != null) { instructionToSetKnockback = defenderInstructions.AttackerHitInfo.LastOrDefault(hi => hi.AttackInstructionsForAttacker.AttackHit && hi.AttackInstructionsForAttacker.Attacker == obstacle.Attacker); } if (instructionToSetKnockback == null) { instructionToSetKnockback = defenderInstructions.AttackerHitInfo.LastOrDefault(hi => hi.AttackInstructionsForAttacker.AttackHit); } if (instructionToSetKnockback != null) { instructionToSetKnockback.AttackInstructionsForAttacker.KnockbackDistance = defenderInstructions.DefenderKnockbackDistance; ChangeImpact(instructionToSetKnockback.AttackInstructionsForAttacker, DefaultAbilities.KNOCKEDBACK, true); } else { this.CurrentAttackInstructions.KnockbackDistance = defenderInstructions.DefenderKnockbackDistance; ChangeImpact(this.CurrentAttackInstructions, DefaultAbilities.KNOCKEDBACK, true); } } } if (this.CurrentAttackInstructions is GangAreaAttackInstructions) { GangAreaAttackInstructions gangAreaInstructions = this.CurrentAttackInstructions as GangAreaAttackInstructions; foreach (var attacker in this.Attackers) { AreaAttackInstructions areaInstructions = gangAreaInstructions.AttackInstructionsMap[attacker]; areaInstructions.AttackHit = this.DefenderAttackInstructions.Any(d => d.AttackerHitInfo.Any(h => h.Attacker == attacker && d.DefenderHitByAttack)); } } }
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(); }