DefendCombatAction.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //-----------------------------------------------------------------------------
  2. // DefendCombatAction.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using Microsoft.Xna.Framework;
  9. using RolePlayingGameData;
  10. using Microsoft.Xna.Framework.Graphics;
  11. namespace RolePlaying
  12. {
  13. /// <summary>
  14. /// A melee-attack combat action, including related data and calculations.
  15. /// </summary>
  16. class DefendCombatAction : CombatAction
  17. {
  18. /// <summary>
  19. /// Returns true if the action is offensive, targeting the opponents.
  20. /// </summary>
  21. public override bool IsOffensive
  22. {
  23. get { return false; }
  24. }
  25. /// <summary>
  26. /// Returns true if this action requires a target.
  27. /// </summary>
  28. public override bool IsTargetNeeded
  29. {
  30. get { return false; }
  31. }
  32. /// <summary>
  33. /// Starts a new combat stage. Called right after the stage changes.
  34. /// </summary>
  35. /// <remarks>The stage never changes into NotStarted.</remarks>
  36. protected override void StartStage()
  37. {
  38. switch (stage)
  39. {
  40. case CombatActionStage.Preparing: // called from Start()
  41. Combatant.CombatSprite.PlayAnimation("Defend");
  42. break;
  43. case CombatActionStage.Executing:
  44. Combatant.CombatEffects.AddStatistics(new StatisticsValue(
  45. 0, 0, 0, Combatant.Character.CharacterStatistics.PhysicalDefense,
  46. 0, Combatant.Character.CharacterStatistics.MagicalDefense), 1);
  47. break;
  48. }
  49. }
  50. /// <summary>
  51. /// The heuristic used to compare actions of this type to similar ones.
  52. /// </summary>
  53. public override int Heuristic
  54. {
  55. get
  56. {
  57. return 0;
  58. }
  59. }
  60. /// <summary>
  61. /// Constructs a new DefendCombatAction object.
  62. /// </summary>
  63. /// <param name="character">The character performing the action.</param>
  64. public DefendCombatAction(Combatant combatant)
  65. : base(combatant) { }
  66. }
  67. }