Example #1
0
    public void ShowInfo()
    {
        BuildingInfoPanel infoPanel = GameplayController.instance.arController.buildingInfoPanel.GetComponent <BuildingInfoPanel>();

        infoPanel.FillBuildingInfo(field);
        infoPanel.Open();
    }
 void Awake()
 {
     if (instance != null)
     {
         Debug.LogError("More than one BuildingInfoPanel in scene !"); return;
     }
     instance = this;
 }
Example #3
0
    public void Refresh()
    {
        BuildingInfo info = CityManager.Instance.GetBuildingByConfigID(_buildingCfgID);

        _currentInfo = info;

        if (_currentInfo == null)
        {
            // 尚未解锁
            _levelText.transform.parent.gameObject.SetActive(false);
            if (_unlock == null)
            {
                _unlock = Instantiate(_unlockPrefab);
                _unlock.transform.SetParent(transform, false);
                _unlock.transform.localPosition = Vector3.zero;
            }
        }
        else
        {
            if (_unlock != null)
            {
                Destroy(_unlock);
                _unlock = null;
            }

            EntityID = _currentInfo.EntityID;
            _levelText.transform.parent.gameObject.SetActive(true);
            _levelText.text = _currentInfo.Cfg.BuildingName + "Lv " + _currentInfo.Level;
        }

        if (_buildingInfoPanel == null)
        {
            _buildingInfoPanel = Instantiate(_buildingInfoPanelPrefab);
            _buildingInfoPanel.transform.SetParent(transform, false);
            _buildingInfoPanel.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
            IgnoreClick(_buildingInfoPanel.gameObject);
        }

        if (_buildingInfoPanel != null)
        {
            _buildingInfoPanel.SetInfo(_currentInfo);
        }

        // 可收获的建筑有收获按钮
        if (_currentInfo is ProduceBuildingInfo)
        {
            if (_produceInfoPanel == null)
            {
                _produceInfoPanel = Instantiate(_produceInfoPanelPrefab);
                _produceInfoPanel.transform.SetParent(transform, false);
                _produceInfoPanel.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
            }

            if (_produceInfoPanel != null)
            {
                _produceInfoPanel.SetInfo(_currentInfo);
            }
        }

        // 兵营
        if (_currentInfo is TroopBuildingInfo)
        {
            if (_troopInfoPanel == null)
            {
                _troopInfoPanel = Instantiate(_troopInfoPanelPrefab);
                _troopInfoPanel.transform.SetParent(transform, false);
                _troopInfoPanel.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
            }

            if (_troopInfoPanel != null)
            {
                _troopInfoPanel.SetInfo(_currentInfo);
            }
        }
    }