Ejemplo n.º 1
0
    public void OpenAddFeaturePanel(Office office)
    {
        var available_features = office.AvailableFeatures().ToList();

        if (available_features.Count <= 0)
        {
            return;
        }

        var features_to_strings = available_features.Select(x => x.Name).ToList();

        FeatureListDropdown.ClearOptions();
        FeatureListDropdown.AddOptions(features_to_strings);
        FeatureListDropdown.value = 0;
        FeatureListDropdown.RefreshShownValue();

        FeatureListDropdown.onValueChanged.RemoveAllListeners();
        FeatureListDropdown.onValueChanged.AddListener(x =>
        {
            FeatureBonusText.text = available_features[x].BonusDescription;
            AddFeatureButton.GetComponentInChildren <Text>().text =
                string.Format("Add Feature ({0:C0} / month)", available_features[x].TotalCost);
        });

        AddFeatureButton.onClick.RemoveAllListeners();
        AddFeatureButton.onClick.AddListener(() =>
        {
            office.AddOfficeFeature(OfficeFeature.AllFeatures.ToList().FindIndex(x => x.Name == FeatureListDropdown.captionText.text));
            RefreshCurrentOfficesList();
            PopulateOfficeDetail(office);
            AddFeaturePanel.alpha          = 0;
            AddFeaturePanel.interactable   = false;
            AddFeaturePanel.blocksRaycasts = false;
        });

        AddFeaturePanel.alpha          = 1;
        AddFeaturePanel.interactable   = true;
        AddFeaturePanel.blocksRaycasts = true;
    }