You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

133 lines
2.4 KiB

  1. using System;
  2. using CIGEnums;
  3. namespace SUISSEngine
  4. {
  5. public class ActivatableBuilding : UpgradableBuilding
  6. {
  7. public virtual bool CanActivate
  8. {
  9. get
  10. {
  11. return this.activatable && !this.Activated;
  12. }
  13. }
  14. public override bool CanUpgrade
  15. {
  16. get
  17. {
  18. if (!this.activatable)
  19. {
  20. return base.CanUpgrade;
  21. }
  22. return !this.Activated || base.CanUpgrade;
  23. }
  24. }
  25. public override Currencies UpgradeCost
  26. {
  27. get
  28. {
  29. if (!this.activatable)
  30. {
  31. return base.UpgradeCost;
  32. }
  33. return (!this.Activated) ? this.activationCost : base.UpgradeCost;
  34. }
  35. }
  36. public override int UpgradeTime
  37. {
  38. get
  39. {
  40. if (!this.activatable)
  41. {
  42. return base.UpgradeTime;
  43. }
  44. return (!this.Activated) ? this.activationTime : base.UpgradeTime;
  45. }
  46. }
  47. public virtual bool Activated
  48. {
  49. get
  50. {
  51. return !this.activatable || base.CurrentLevel > 0;
  52. }
  53. }
  54. public override int DisplayLevel
  55. {
  56. get
  57. {
  58. return base.CurrentLevel - ((!this.activatable) ? 0 : 1);
  59. }
  60. }
  61. protected void UpdateActivateHintIcon()
  62. {
  63. if (!this.Activated && !base.IsUpgrading)
  64. {
  65. this.ShowActivateHintIcon();
  66. }
  67. else
  68. {
  69. this.RemoveActivateHintIcon();
  70. }
  71. }
  72. private void ShowActivateHintIcon()
  73. {
  74. ButtonGridTileIcon buttonGridTileIcon = this._gridTileIconManager.SetIcon<ButtonGridTileIcon>(GridTileIconType.Activate);
  75. buttonGridTileIcon.Init(delegate
  76. {
  77. this.ClickHandler(base.gameObject);
  78. });
  79. }
  80. private void RemoveActivateHintIcon()
  81. {
  82. this._gridTileIconManager.RemoveIcon(GridTileIconType.Activate);
  83. }
  84. protected override void UpdateLevelIcon(int level)
  85. {
  86. if (!this.activatable || this.Activated)
  87. {
  88. base.UpdateLevelIcon((!this.activatable) ? level : (level - 1));
  89. }
  90. }
  91. protected override void OnDeserialized()
  92. {
  93. base.OnDeserialized();
  94. if (!this.activatable)
  95. {
  96. return;
  97. }
  98. this.UpdateActivateHintIcon();
  99. }
  100. protected override void OnUpgradeCompleted(double upgradedTime)
  101. {
  102. base.OnUpgradeCompleted(upgradedTime);
  103. if (!this.activatable)
  104. {
  105. return;
  106. }
  107. this.UpdateActivateHintIcon();
  108. }
  109. public bool activatable;
  110. public int activationTime;
  111. public Currencies activationCost;
  112. public int gridPositionU;
  113. public int gridPositionV;
  114. }
  115. }