コード例 #1
0
    public void ActivateProgressPanel(ProgressPanelMode mode)
    {
        switch (mode)
        {
        case ProgressPanelMode.Powerplant:
            UIWorkbuildingObserver uwb = WorkBuilding.workbuildingObserver;
            if (uwb == null || !uwb.gameObject.activeSelf)
            {
                DeactivateProgressPanel();
                return;
            }
            else
            {
                Powerplant pp = uwb.observingWorkbuilding as Powerplant;
                Transform  t  = progressPanel.transform;
                RawImage   ri = t.GetChild(0).GetComponent <RawImage>();
                ri.texture = resourcesTexture;
                int resourceID = pp.GetFuelResourseID();
                ri.uvRect = ResourceType.GetTextureRect(resourceID);
                ri.transform.GetChild(0).GetComponent <Text>().text = Localization.GetResourceName(resourceID);
                t = t.GetChild(1);
                RectTransform rt = t.GetChild(0).GetComponent <RectTransform>();
                rt.offsetMax = new Vector2((Mathf.Clamp(pp.fuelLeft, 0, 1) - 1) * rt.rect.width, 0);
                t.GetChild(1).GetComponent <Text>().text = string.Format("{0:0.###}", pp.fuelLeft) + '%';

                progressPanel.SetActive(true);
                progressPanelMode = mode;
            }
            break;
        }
    }
コード例 #2
0
    public void SetObservingDock(Dock d)
    {
        if (d == null)
        {
            SelfShutOff();
            return;
        }
        else
        {
            observingDock = d; isObserving = true;
            UIWorkbuildingObserver uwb = WorkBuilding.workbuildingObserver;
            if (uwb == null)
            {
                uwb = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
            }
            else
            {
                uwb.gameObject.SetActive(true);
            }
            uwb.SetObservingWorkBuilding(observingDock);
            if (tradingListPanel.activeSelf)
            {
                PrepareTradingPanel();
            }
            else
            {
                PrepareImmigrationPanel();
            }

            STATUS_UPDATE_TIME = 1.5f; timer = STATUS_UPDATE_TIME;
        }
    }
コード例 #3
0
 public void SetObservingDock(Dock d)
 {
     if (d == null)
     {
         SelfShutOff();
         return;
     }
     else
     {
         if (dockSystem == null)
         {
             dockSystem = DockSystem.GetCurrent();
         }
         observingDock = d; isObserving = true;
         UIWorkbuildingObserver uwb = WorkBuilding.workbuildingObserver;
         if (uwb == null)
         {
             uwb = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
         }
         else
         {
             uwb.gameObject.SetActive(true);
         }
         uwb.SetObservingPlace(observingDock);
         if (tradingListPanel.activeSelf)
         {
             PrepareTradingPanel();
         }
         else
         {
             PrepareImmigrationPanel();
         }
         dockInfoLabel.text = observingDock.UI_GetInfo();
     }
 }
コード例 #4
0
    public void RollingShop_SetActivity(int x)
    {
        UIWorkbuildingObserver wbo = WorkBuilding.workbuildingObserver;

        if (wbo == null | !wbo.gameObject.activeSelf)
        {
            DeactivateRollingShopPanel();
            return;
        }
        else   // уу, костыли!
        {
            RollingShop rs = wbo.observingWorkbuilding as RollingShop;
            if (rs == null)
            {
                DeactivateRollingShopPanel();
                return;
            }
            else
            {
                if (rs.GetModeIndex() != x)
                {
                    rs.SetMode(x);
                    rollingShopPanel.transform.GetChild(x).GetComponent <Toggle>().isOn = true;
                }
            }
        }
    }
コード例 #5
0
    public void SetObservingRCenter(RecruitingCenter rc)
    {
        if (fullProgressBarLength == -1)
        {
            fullProgressBarLength = progressBar.rect.width;
            startOffset           = progressBar.offsetMin.x;
        }
        if (rc == null)
        {
            SelfShutOff();
            return;
        }
        UIWorkbuildingObserver uwb = WorkBuilding.workbuildingObserver;

        if (uwb == null)
        {
            uwb = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
        }
        else
        {
            uwb.gameObject.SetActive(true);
        }
        observingRCenter = rc; isObserving = true;
        uwb.SetObservingWorkBuilding(rc);

        PrepareCrewsWindow();

        STATUS_UPDATE_TIME = 1f; timer = STATUS_UPDATE_TIME;
    }
コード例 #6
0
#pragma warning restore 0649

    public static UIWorkbuildingObserver InitializeWorkbuildingObserverScript()
    {
        UIWorkbuildingObserver uwb = Instantiate(Resources.Load <GameObject>("UIPrefs/workBuildingObserver"), UIController.current.rightPanel.transform).GetComponent <UIWorkbuildingObserver>();

        WorkBuilding.workbuildingObserver = uwb;
        Worksite.observer = uwb;
        return(uwb);
    }
コード例 #7
0
    public void SetObservingFactory(Factory f)
    {
        if (f == null)
        {
            SelfShutOff();
            return;
        }
        UIWorkbuildingObserver uwb = WorkBuilding.workbuildingObserver;

        if (uwb == null)
        {
            uwb = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
        }
        else
        {
            uwb.gameObject.SetActive(true);
        }
        observingFactory = f; isObserving = true;
        uwb.SetObservingWorkBuilding(observingFactory);

        Recipe[] recipes = observingFactory.GetFactoryRecipes();
        recipesDropdown.enabled = true;
        Recipe r = observingFactory.recipe;
        int    positionInDropdown = -1;

        if (recipes.Length == 1)
        {
            recipesDropdown.interactable = false;
        }
        else
        {
            recipesDropdown.interactable = true;
            List <Dropdown.OptionData> recipeButtons = new List <Dropdown.OptionData>();
            for (int i = 0; i < recipes.Length; i++)
            {
                recipeButtons.Add(new Dropdown.OptionData(Localization.GetResourceName(recipes[i].input.ID) + " -> " + Localization.GetResourceName(recipes[i].output.ID)));
                if (recipes[i].ID == r.ID)
                {
                    positionInDropdown = i;
                }
            }
            recipesDropdown.options = recipeButtons;
        }

        inputIcon.uvRect       = ResourceType.GetTextureRect(r.input.ID);
        inputValueString.text  = r.inputValue.ToString();
        outputIcon.uvRect      = ResourceType.GetTextureRect(r.output.ID);
        outputValueString.text = r.outputValue.ToString();
        recipesDropdown.value  = positionInDropdown;

        STATUS_UPDATE_TIME = 0.1f; timer = STATUS_UPDATE_TIME;
    }
コード例 #8
0
 public override UIObserver ShowOnGUI()
 {
     if (workbuildingObserver == null)
     {
         workbuildingObserver = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
     }
     else
     {
         workbuildingObserver.gameObject.SetActive(true);
     }
     workbuildingObserver.SetObservingWorkBuilding(this);
     showOnGUI = true;
     return(workbuildingObserver);
 }
コード例 #9
0
 public UIObserver ShowOnGUI()
 {
     if (observer == null)
     {
         observer = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
     }
     else
     {
         observer.gameObject.SetActive(true);
     }
     observer.SetObservingPlace(this);
     showOnGUI = true;
     return(observer);
 }
コード例 #10
0
ファイル: Powerplant.cs プロジェクト: Alan-Baylis/VoxelGame-1
 public override UIObserver ShowOnGUI()
 {
     if (workbuildingObserver == null)
     {
         workbuildingObserver = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
     }
     else
     {
         workbuildingObserver.gameObject.SetActive(true);
     }
     workbuildingObserver.SetObservingWorkBuilding(this);
     UIController.current.ActivateProgressPanel(ProgressPanelMode.Powerplant);
     showOnGUI = true;
     return(workbuildingObserver);
 }
コード例 #11
0
 public override UIObserver ShowOnGUI()
 {
     if (workbuildingObserver == null)
     {
         UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
     }
     else
     {
         workbuildingObserver.gameObject.SetActive(true);
     }
     workbuildingObserver.SetObservingWorkBuilding(this);
     showOnGUI = true;
     UIController.current.ActivateRollingShopPanel();
     return(workbuildingObserver);
 }
コード例 #12
0
 public override UIObserver ShowOnGUI()
 {
     if (workbuildingObserver == null)
     {
         workbuildingObserver = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
     }
     else
     {
         workbuildingObserver.gameObject.SetActive(true);
     }
     workbuildingObserver.SetObservingPlace(this);
     colony.observer?.ActivateHospitalPanel();
     showOnGUI = true;
     return(workbuildingObserver);
 }
コード例 #13
0
 public override UIObserver ShowOnGUI()
 {
     if (workbuildingObserver == null)
     {
         workbuildingObserver = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
     }
     else
     {
         workbuildingObserver.gameObject.SetActive(true);
     }
     workbuildingObserver.SetObservingWorkBuilding(this);
     showOnGUI = true;
     colony.observer?.ChangeActiveWindow(ActiveWindowMode.ExpeditionPanel);
     return(workbuildingObserver);
 }
コード例 #14
0
    public void ActivateRollingShopPanel()
    {
        UIWorkbuildingObserver wbo = WorkBuilding.workbuildingObserver;

        if (wbo != null && wbo.gameObject.activeSelf)
        { // уу, костыли!
            // и вообще надо переделать на dropdown
            RollingShop rs = wbo.observingWorkbuilding as RollingShop;
            if (rs != null)
            {
                rollingShopPanel.SetActive(true);
                rollingShopPanel.transform.GetChild(rs.GetModeIndex()).GetComponent <Toggle>().isOn = true;
            }
        }
        rollingShopPanel.SetActive(true);
    }
コード例 #15
0
    public override UIObserver ShowOnGUI()
    {
        if (workbuildingObserver == null)
        {
            workbuildingObserver = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
        }
        else
        {
            workbuildingObserver.gameObject.SetActive(true);
        }
        workbuildingObserver.SetObservingWorkBuilding(this);
        showOnGUI = true;

        UIController.current.EnableTextfield(ID);

        return(workbuildingObserver);
    }
コード例 #16
0
    public void SetObservingHangar(Hangar h)
    {
        if (h == null)
        {
            SelfShutOff();
            return;
        }
        UIWorkbuildingObserver uwb = WorkBuilding.workbuildingObserver;

        if (uwb == null)
        {
            uwb = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
        }
        else
        {
            uwb.gameObject.SetActive(true);
        }
        observingHangar = h; isObserving = true;
        uwb.SetObservingPlace(h);
        PrepareHangarWindow();
    }
コード例 #17
0
    public void SetObservingRCenter(RecruitingCenter rc)
    {
        if (rc == null)
        {
            SelfShutOff();
            return;
        }
        UIWorkbuildingObserver uwb = WorkBuilding.workbuildingObserver;

        if (uwb == null)
        {
            uwb = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
        }
        else
        {
            uwb.gameObject.SetActive(true);
        }
        observingRCenter = rc; isObserving = true;
        uwb.SetObservingPlace(rc);
        PrepareWindow();
    }
コード例 #18
0
ファイル: UIDockObserver.cs プロジェクト: Hengle/VoxelGame
 public void SetObservingDock(Dock d)
 {
     if (d == null)
     {
         SelfShutOff();
         return;
     }
     else
     {
         if (dockSystem == null)
         {
             dockSystem = DockSystem.GetCurrent();
         }
         observingDock = d; isObserving = true;
         UIWorkbuildingObserver uwb = WorkBuilding.workbuildingObserver;
         if (uwb == null)
         {
             uwb = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
         }
         else
         {
             uwb.gameObject.SetActive(true);
         }
         uwb.SetObservingWorkBuilding(observingDock);
         if (tradingListPanel.activeSelf)
         {
             PrepareTradingPanel();
         }
         else
         {
             PrepareImmigrationPanel();
         }
         if (observingDock.correctLocation)
         {
             nextShipTimer.text = observingDock.shipArrivingTimer.ToString();
         }
     }
 }
コード例 #19
0
    void Update()
    {
        updateTimer -= Time.deltaTime;
        if (updateTimer <= 0)
        {
            updateTimer = DATA_UPDATE_TIME;
            ColonyController colony = GameMaster.colonyController;
            if (showColonyInfo)
            {
                if (colony != null)
                {
                    if (showingGearsCf != colony.gears_coefficient)
                    {
                        showingGearsCf = colony.gears_coefficient;
                        gearsText.text = string.Format("{0:0.###}", showingGearsCf);
                    }
                    if (showingHappinessCf != colony.happiness_coefficient)
                    {
                        showingHappinessCf = colony.happiness_coefficient;
                        happinessText.text = string.Format("{0:0.##}", showingHappinessCf * 100) + '%';
                    }
                    if (showingBirthrate != colony.realBirthrate)
                    {
                        showingBirthrate   = (int)(colony.realBirthrate * 100) / 100f;;
                        birthrateText.text = showingBirthrate > 0 ? '+' + string.Format("{0:0.#####}", showingBirthrate) : string.Format("{0:0.#####}", showingBirthrate);
                    }
                    if (showingHospitalCf != colony.hospitals_coefficient)
                    {
                        showingHospitalCf = colony.hospitals_coefficient;
                        hospitalText.text = string.Format("{0:0.##}", showingHospitalCf * 100) + '%';
                    }
                    if (showingHealthCf != colony.health_coefficient)
                    {
                        showingHealthCf = colony.health_coefficient;
                        healthText.text = string.Format("{0:0.##}", showingHealthCf * 100) + '%';
                    }
                }
            }
            else
            {
                if (showStorageInfo)
                {
                    if (lastStorageOperationNumber != colony.storage.operationsDone)
                    {
                        RecalculateStoragePanel();
                    }
                }
            }

            if (progressPanel.activeSelf)
            {
                switch (progressPanelMode)
                {
                case ProgressPanelMode.Powerplant:
                    UIWorkbuildingObserver uwb = WorkBuilding.workbuildingObserver;
                    if (uwb == null || (!uwb.gameObject.activeSelf | uwb.observingWorkbuilding.id != Structure.MINERAL_POWERPLANT_2_ID))
                    {
                        DeactivateProgressPanel();
                        return;
                    }
                    else
                    {
                        Powerplant pp = uwb.observingWorkbuilding as Powerplant;
                        RawImage   ri = progressPanel.transform.GetChild(0).GetComponent <RawImage>();
                        ri.texture = resourcesTexture;
                        ri.uvRect  = ResourceType.GetTextureRect(pp.GetFuelResourseID());
                        Transform     t  = progressPanel.transform.GetChild(1);
                        RectTransform rt = t.GetChild(0).GetComponent <RectTransform>();
                        rt.offsetMax = new Vector2((pp.fuelLeft - 1) * rt.rect.width, 0);
                        t.GetChild(1).GetComponent <Text>().text = string.Format("{0:0.###}", pp.fuelLeft * 100) + '%';
                    }
                    break;
                }
            }
            else
            {
                if (hospitalPanel.activeSelf)
                {
                    int nhm = Hospital.GetBirthrateModeIndex();
                    if (nhm != hospitalPanel_savedMode)
                    {
                        switch (nhm)
                        {
                        case 0: hospitalPanel.transform.GetChild(1).GetComponent <Toggle>().isOn = true; break;    // normal

                        case 1: hospitalPanel.transform.GetChild(2).GetComponent <Toggle>().isOn = true; break;    // improved

                        case 2: hospitalPanel.transform.GetChild(3).GetComponent <Toggle>().isOn = true; break;    // lowered
                        }
                        hospitalPanel_savedMode = nhm;
                    }
                }
                else
                {
                    if (expeditionCorpusPanel.activeSelf)
                    {
                        int x = Shuttle.shuttlesList.Count;
                        if (exCorpus_savedShuttlesCount != x)
                        {
                            exCorpus_savedShuttlesCount = x;
                            expeditionCorpusPanel.transform.GetChild(0).GetComponent <Text>().text = Localization.GetPhrase(LocalizedPhrase.ShuttlesAvailable) + " : " + exCorpus_savedShuttlesCount.ToString();
                        }
                        x = Crew.crewsList.Count;
                        if (x != exCorpus_savedCrewsCount)
                        {
                            exCorpus_savedCrewsCount = x;
                            expeditionCorpusPanel.transform.GetChild(1).GetComponent <Text>().text = Localization.GetPhrase(LocalizedPhrase.CrewsAvailable) + " : " + exCorpus_savedCrewsCount.ToString();
                        }
                        x = QuantumTransmitter.transmittersList.Count;
                        if (x != exCorpus_savedTransmittersCount)
                        {
                            exCorpus_savedTransmittersCount = x;
                            expeditionCorpusPanel.transform.GetChild(2).GetComponent <Text>().text = Localization.GetPhrase(LocalizedPhrase.TransmittersAvailable) + " : " + exCorpus_savedTransmittersCount.ToString();
                        }
                    }
                }
            }

            //up panel values:
            {
                bool valuesChanged = false;
                if (saved_freeWorkersCount != colony.freeWorkers)
                {
                    saved_freeWorkersCount = colony.freeWorkers;
                    valuesChanged          = true;
                }
                if (saved_citizenCount != colony.citizenCount)
                {
                    saved_citizenCount = colony.citizenCount;
                    valuesChanged      = true;
                }
                if (saved_livespaceCount != colony.totalLivespace)
                {
                    saved_livespaceCount = colony.totalLivespace;
                    valuesChanged        = true;
                }
                if (valuesChanged)
                {
                    citizenString.text = saved_freeWorkersCount.ToString() + " / " + saved_citizenCount.ToString() + " / " + saved_livespaceCount.ToString();
                }

                valuesChanged = false;
                if (saved_energyCount != colony.energyStored)
                {
                    saved_energyCount = (int)colony.energyStored;
                    valuesChanged     = true;
                }
                if (saved_energyMax != colony.totalEnergyCapacity)
                {
                    saved_energyMax = (int)colony.totalEnergyCapacity;
                    valuesChanged   = true;
                }
                float es = (int)(colony.energySurplus * 10) / 10;
                if (saved_energySurplus != es)
                {
                    saved_energySurplus = es;
                    valuesChanged       = true;
                }
                if (valuesChanged)
                {
                    string surplus = es.ToString();
                    if (es > 0)
                    {
                        surplus = '+' + surplus;
                    }
                    energyString.text = saved_energyCount.ToString() + " / " + saved_energyMax.ToString() + " (" + surplus + ')';
                }

                if (saved_energyCrystalsCount != (int)colony.energyCrystalsCount)
                {
                    saved_energyCrystalsCount = (int)colony.energyCrystalsCount;
                    energyCrystalsString.text = saved_energyCrystalsCount.ToString();
                }
            }
        }
        if (activeAnnouncements)
        {
            Text  t = announcementStrings[0];
            Color c = t.color;
            c.a = Mathf.Lerp(c.a, 0, DISSAPPEAR_SPEED * Time.deltaTime * GameMaster.gameSpeed * (2 - c.a) * (2 - c.a));
            if (c.a > 0.05f)
            {
                t.color = c;
            }
            else
            {
                if (announcementStrings[1].enabled)
                {
                    int lastIndex = 1;
                    t.color = Color.black;
                    int i = 1;
                    while (i < announcementStrings.Length)
                    {
                        if (!announcementStrings[i].enabled)
                        {
                            break;
                        }
                        else
                        {
                            lastIndex = i;
                        }
                        announcementStrings[i - 1].text = announcementStrings[i].text;
                        i++;
                    }
                    announcementStrings[lastIndex].enabled = false;
                }
                else
                {
                    t.enabled           = false;
                    activeAnnouncements = false;
                }
            }
        }
        if (moneyFlySpeed != 0)
        {
            Vector3 pos = moneyFlyingText.rectTransform.position;
            if (moneyFlySpeed > 0)
            {
                moneyFlySpeed -= Time.deltaTime / 5f;
                if (moneyFlySpeed < 0)
                {
                    moneyFlySpeed           = 0;
                    moneyFlyingText.enabled = false;
                }
                else
                {
                    moneyFlyingText.rectTransform.position = Vector3.Lerp(flyingMoneyOriginalPoint + 2 * Vector3.up, flyingMoneyOriginalPoint, moneyFlySpeed);
                    moneyFlyingText.color = Color.Lerp(Color.green, new Color(0, 1, 0, 0), moneyFlySpeed);
                }
            }
            else
            {
                moneyFlySpeed += Time.deltaTime / 5f;
                if (moneyFlySpeed < 1)
                {
                    moneyFlyingText.rectTransform.position = Vector3.Lerp(flyingMoneyOriginalPoint, flyingMoneyOriginalPoint + 2 * Vector3.up, moneyFlySpeed);
                    moneyFlyingText.color = Color.Lerp(new Color(1, 0, 0, 0), Color.red, moneyFlySpeed);
                }
                else
                {
                    moneyFlySpeed           = 0;
                    moneyFlyingText.enabled = false;
                }
            }
        }
    }
コード例 #20
0
    public void SetObservingFactory(Factory f)
    {
        if (f == null)
        {
            SelfShutOff();
            return;
        }
        UIWorkbuildingObserver uwb = WorkBuilding.workbuildingObserver;

        if (uwb == null)
        {
            uwb = UIWorkbuildingObserver.InitializeWorkbuildingObserverScript();
        }
        else
        {
            uwb.gameObject.SetActive(true);
        }
        observingFactory    = f; isObserving = true;
        ignoreSetRecipeCall = true;
        advancedFactoryMode = f is AdvancedFactory;
        uwb.SetObservingPlace(observingFactory);

        Recipe[] recipes = observingFactory.GetFactoryRecipes();
        recipesDropdown.enabled = false;

        int positionInDropdown = 0;

        if (recipes.Length == 1 && recipes[0] == Recipe.NoRecipe)
        {
            recipesDropdown.interactable = false;
        }
        else
        {
            List <Dropdown.OptionData> recipeButtons = new List <Dropdown.OptionData>();
            Recipe r;
            if (advancedFactoryMode)
            {
                AdvancedRecipe ar = (observingFactory as AdvancedFactory).GetRecipe(), arf;
                for (int i = 0; i < recipes.Length; i++)
                {
                    r   = recipes[i];
                    arf = r as AdvancedRecipe;
                    if (arf == null)
                    {
                        recipeButtons.Add(new Dropdown.OptionData(Localization.GetResourceName(r.input.ID) + " -> " + Localization.GetResourceName(r.output.ID)));
                    }
                    else
                    {
                        recipeButtons.Add(new Dropdown.OptionData(
                                              Localization.GetResourceName(arf.input.ID) + " + " + Localization.GetResourceName(arf.input2.ID) + " -> " + Localization.GetResourceName(arf.output.ID)
                                              ));
                    }
                    if (r.ID == ar.ID)
                    {
                        positionInDropdown = i;
                    }
                }
            }
            else
            {
                Recipe rx = observingFactory.GetRecipe();
                for (int i = 0; i < recipes.Length; i++)
                {
                    r = recipes[i];
                    recipeButtons.Add(new Dropdown.OptionData(Localization.GetResourceName(r.input.ID) + " -> " + Localization.GetResourceName(r.output.ID)));
                    if (r.ID == rx.ID)
                    {
                        positionInDropdown = i;
                    }
                }
            }
            recipesDropdown.options      = recipeButtons;
            recipesDropdown.interactable = true;
        }
        recipesDropdown.value = positionInDropdown;
        RedrawRecipeData();
        recipesDropdown.enabled = true;
        //
        modesDropdown.value = (int)observingFactory.productionMode;
        if (observingFactory.productionMode == FactoryProductionMode.NoLimit)
        {
            limitPanel.SetActive(false);
        }
        else
        {
            showingProductionValue = observingFactory.productionModeValue;
            limitInputField.text   = showingProductionValue.ToString();
            limitPanel.SetActive(true);
        }
        //
        ignoreSetRecipeCall = false;
    }