예제 #1
0
 private void UpdateInteractableStateClimateBuilding()
 {
     if (button != null)
     {
         button.interactable = ClimateBuilding.IsBuildingBuildable(id);
     }
 }
예제 #2
0
        public void Init(int id, BuildingPrefabs prefab, ClimateBuildingsData data, bool isCorrectClimate, BuildModeBase buildMode)
        {
            this.id               = id;
            this.data             = data;
            this.isCorrectClimate = isCorrectClimate;
            img.sprite            = prefab.GetBuildingSprite(id);
            button.onClick.AddListener(() => buildMode.SelectBuilding(id));
            button.interactable = ClimateBuilding.IsBuildingBuildable(id);
            PlayerResources.OnResourceChanged += (x, y) => UpdateInteractableStateClimateBuilding();
            PlayerResources.OnMoneyChanged    += (x) => UpdateInteractableStateClimateBuilding();
            Construction.BuildModeClimateBuildings.OnBuildingPlaced += (x, y) => UpdateInteractableStateClimateBuilding();

            if (!isCorrectClimate)
            {
                button.interactable = false;
                img.color           = incorrectClimateColor;
            }
        }
 protected override void OnMouseClick()
 {
     if (tilesHoveringOver == null || EventSystem.current.IsPointerOverGameObject() || !ClimateBuilding.IsBuildingBuildable(SelectedBuildingData.ID))
     {
         return;
     }
     if (CanBePlacedAtTiles(tilesHoveringOver))
     {
         Build(tilesHoveringOver);
     }
 }