Advertisement
Guest User

Untitled

a guest
Apr 9th, 2017
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using GrimoireEngine.Framework.Interfaces;
  7.  
  8. namespace GrimoireEngine.Framework.Collections
  9. {
  10. public class BattleAttributes : IEquatable<BattleAttributes>, ICopy<BattleAttributes>
  11. {
  12. private int _accuracy;
  13. private int _evasion;
  14. private int _initiative;
  15. private int _movmement;
  16. private int _acrobatics;
  17.  
  18. public int Accuracy
  19. {
  20. get { return _accuracy; }
  21. set { _accuracy = value; }
  22. }
  23.  
  24. public int Evasion
  25. {
  26. get { return _evasion; }
  27. set { _evasion = value; }
  28. }
  29.  
  30. public int Initiative
  31. {
  32. get { return _initiative; }
  33. set { _initiative = value; }
  34. }
  35.  
  36. public int Movmement
  37. {
  38. get { return _movmement; }
  39. set { _movmement = value; }
  40. }
  41.  
  42. public int Acrobatics
  43. {
  44. get { return _acrobatics; }
  45. set { _acrobatics = value; }
  46. }
  47.  
  48. public BattleAttributes()
  49. {
  50.  
  51. }
  52.  
  53. public BattleAttributes(int accuracy, int evasion, int initiative, int movmement, int acrobatics)
  54. {
  55. Copy(accuracy,evasion,initiative,movmement,acrobatics);
  56. }
  57.  
  58. public void Copy(int accuracy, int evasion, int initiative, int movmement, int acrobatics)
  59. {
  60. this.Accuracy = accuracy;
  61. this.Evasion = evasion;
  62. this.Initiative = initiative;
  63. this.Movmement = movmement;
  64. this.Acrobatics = acrobatics;
  65. }
  66.  
  67.  
  68. public bool Equals(BattleAttributes other)
  69. {
  70. if (ReferenceEquals(null, other)) return false;
  71. if (ReferenceEquals(this, other)) return true;
  72. return _accuracy == other._accuracy && _evasion == other._evasion && _initiative == other._initiative && _movmement == other._movmement && _acrobatics == other._acrobatics;
  73. }
  74.  
  75. public override bool Equals(object obj)
  76. {
  77. if (ReferenceEquals(null, obj)) return false;
  78. if (ReferenceEquals(this, obj)) return true;
  79. if (obj.GetType() != this.GetType()) return false;
  80. return Equals((BattleAttributes) obj);
  81. }
  82.  
  83. public override int GetHashCode()
  84. {
  85. unchecked
  86. {
  87. int hashCode = _accuracy;
  88. hashCode = (hashCode * 397) ^ _evasion;
  89. hashCode = (hashCode * 397) ^ _initiative;
  90. hashCode = (hashCode * 397) ^ _movmement;
  91. hashCode = (hashCode * 397) ^ _acrobatics;
  92. return hashCode;
  93. }
  94. }
  95.  
  96. public void Copy(BattleAttributes other)
  97. {
  98. this._accuracy = other._accuracy;
  99. this._evasion = other._evasion;
  100. this._initiative = other._initiative;
  101. this._movmement = other._movmement;
  102. this._acrobatics = other._acrobatics;
  103. }
  104.  
  105. public BattleAttributes MakeCopy()
  106. {
  107. BattleAttributes copy = new BattleAttributes();
  108. copy.Copy(this);
  109. return copy;
  110. }
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement