- using System;
- using CIGEnums;
-
- namespace SUISSEngine
- {
- public class ActivatableBuilding : UpgradableBuilding
- {
- public virtual bool CanActivate
- {
- get
- {
- return this.activatable && !this.Activated;
- }
- }
-
- public override bool CanUpgrade
- {
- get
- {
- if (!this.activatable)
- {
- return base.CanUpgrade;
- }
- return !this.Activated || base.CanUpgrade;
- }
- }
-
- public override Currencies UpgradeCost
- {
- get
- {
- if (!this.activatable)
- {
- return base.UpgradeCost;
- }
- return (!this.Activated) ? this.activationCost : base.UpgradeCost;
- }
- }
-
- public override int UpgradeTime
- {
- get
- {
- if (!this.activatable)
- {
- return base.UpgradeTime;
- }
- return (!this.Activated) ? this.activationTime : base.UpgradeTime;
- }
- }
-
- public virtual bool Activated
- {
- get
- {
- return !this.activatable || base.CurrentLevel > 0;
- }
- }
-
- public override int DisplayLevel
- {
- get
- {
- return base.CurrentLevel - ((!this.activatable) ? 0 : 1);
- }
- }
-
- protected void UpdateActivateHintIcon()
- {
- if (!this.Activated && !base.IsUpgrading)
- {
- this.ShowActivateHintIcon();
- }
- else
- {
- this.RemoveActivateHintIcon();
- }
- }
-
- private void ShowActivateHintIcon()
- {
- ButtonGridTileIcon buttonGridTileIcon = this._gridTileIconManager.SetIcon<ButtonGridTileIcon>(GridTileIconType.Activate);
- buttonGridTileIcon.Init(delegate
- {
- this.ClickHandler(base.gameObject);
- });
- }
-
- private void RemoveActivateHintIcon()
- {
- this._gridTileIconManager.RemoveIcon(GridTileIconType.Activate);
- }
-
- protected override void UpdateLevelIcon(int level)
- {
- if (!this.activatable || this.Activated)
- {
- base.UpdateLevelIcon((!this.activatable) ? level : (level - 1));
- }
- }
-
- protected override void OnDeserialized()
- {
- base.OnDeserialized();
- if (!this.activatable)
- {
- return;
- }
- this.UpdateActivateHintIcon();
- }
-
- protected override void OnUpgradeCompleted(double upgradedTime)
- {
- base.OnUpgradeCompleted(upgradedTime);
- if (!this.activatable)
- {
- return;
- }
- this.UpdateActivateHintIcon();
- }
-
- public bool activatable;
-
- public int activationTime;
-
- public Currencies activationCost;
-
- public int gridPositionU;
-
- public int gridPositionV;
- }
- }
|