DefendCombatAction.cs 2.7 KB

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