コード例 #1
0
    public void PageDataSet()
    {
        StageIconDataManager.Ins.MaxStageReset();

        List <StageIconData> currentPageDataList = StageIconDataManager.Ins.GetPageData(currenPage);

        foreach (var stageIconObj in stageIconObjList)
        {
            stageIconObj.gameObject.SetActive(false);
        }

        if (stageIconObjList.Count < currentPageDataList.Count)
        {
            for (int i = stageIconObjList.Count; i < currentPageDataList.Count; i++)
            {
                StageIcon stageIcon = Instantiate(Resources.Load <StageIcon>("SelectStage/StageIcon"), this.transform);
                stageIcon.transform.localPosition = currentPageDataList[i].posData;
                stageIconObjList.Add(stageIcon);
                stageIcon.clickEvent += StageStartOn;
            }
        }

        for (int i = 0; i < currentPageDataList.Count; i++)
        {
            stageIconObjList[i].gameObject.SetActive(true);
            stageIconObjList[i].DataSet(currentPageDataList[i]);
            stageIconObjList[i].transform.localPosition = currentPageDataList[i].posData;
        }
    }
コード例 #2
0
 public static RawImage getStageTexture(StageIcon stageIcon)
 {
     if (stageIcon.GetType().GetField("iconImage", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) == null)
     {
         PluginLogger.logDebug("field null!");
     }
     return((RawImage)stageIcon.GetType().GetField("iconImage", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(stageIcon));
 }
コード例 #3
0
    public void DeselectStageIcon()
    {
        // if there is nothing to deselect, return
        if (selectedStageIcon == null)
        {
            return;
        }

        selectedStageIcon.SetActive(true);
        StageIcon stageIcon = selectedStageIcon.GetComponent <StageIcon>();

        stageIcon.CollapseHighlightMenu();
        selectedStageIcon.transform.SetSiblingIndex(stageIcon.stageIndex);
        selectedStageIcon = null;
    }
コード例 #4
0
    public void SelectStageIcon(GameObject stageIconObj)
    {
        DeselectStageIcon();              // If there is already a selected stage icon, deselect it first
        selectedStageIcon = stageIconObj; // store a reference to this object so that the Deselect method has a reference to it later
        StageIcon stageIcon = stageIconObj.GetComponent <StageIcon>();
        // Do the actual selection in the GameManager
        GameManager gm = GameManager.instance;

        gm.selectedSeriesIndex = stageIcon.seriesIndex;
        gm.selectedStageIndex  = stageIcon.stageIndex;
        // UI Stuff
        highlightMenu.SetActive(true);
        selectedStageIcon.SetActive(false);
        highlightMenu.transform.SetParent(stageIconFolder, false);
        stageIcon.highlightMenu = highlightMenu;
        stageIcon.ExpandHighlightMenu();
        int siblingIndex = stageIcon.stageIndex;

        highlightMenu.transform.SetSiblingIndex(siblingIndex);
    }
コード例 #5
0
    public void InitStageSelectionView(StageSeriesData stageSeriesData)
    {
        stageSelectionView.gameObject.SetActive(true);
        foreach (GameObject o in stageIcons)
        {
            o.SetActive(false);
        }
        UnityEngine.Assertions.Assert.IsTrue(gm.IsSeriesUnlocked(stageSeriesData.seriesName));
        int numStagesUnlocked = gm.NumStagesUnlocked(stageSeriesData.seriesName);
        int iconIndex         = 0;                                                              // Used to track the number of icons in the scene, and add more if needed

        for (int i = 0; i < numStagesUnlocked; i++)
        {
            GameObject o;
            if (iconIndex >= stageIcons.Count)
            {
                // Instantiate and initialize a new stage icon prefab
                o = Instantiate(stageIconPrefab);
                stageIcons.Add(o);
                StageIcon icon = o.GetComponent <StageIcon>();
                //icon.highlightMenu.GetComponent<Button>().onClick.AddListener(() => DeselectStageIcon());
            }
            else
            {
                o = stageIcons[iconIndex];
            }
            o.transform.SetParent(stageIconFolder, false);
            o.SetActive(true);

            StageData stageData = stageSeriesData.stages[i];
            StageIcon stageIcon = o.GetComponent <StageIcon>();
            stageIcon.seriesIndex = stageSeriesData.index;
            stageIcon.stageIndex  = i;
            stageIcon.onClicked   = SelectStageIcon;
            stageIcon.Init(stageData);
            iconIndex++;
        }
    }
コード例 #6
0
        public void Start()
        {
            if (!(HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)) return;

            //Debug.Log("EditorCrashFix.Start(): v00.01");

            if (part != null && part.stackIcon != null && part.stackIcon.StageIcon != null && part.stackIcon.StageIcon.gameObject != null)
                stageIcon = part.stackIcon.StageIcon;
        }
コード例 #7
0
        public void UpdatePanels()
        {
            for (int i = panels.Count - 1; i >= 0; i--)
            {
                StageGroup group = panels.KeyAt(i);

                if (group == null)
                {
                    continue;
                }

                BasicDeltaV_StagePanel panel = panels.At(i);

                if (panel == null)
                {
                    continue;
                }

                panel.Index = group.inverseStageIndex;

                panel.Stage = BasicDeltaV.Instance.GetStage(panel.Index);

                if (panel.Stage == null)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (!BasicDeltaV.Instance.DisplayActive)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (group.Icons.Count <= 0)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (HighLogic.LoadedSceneIsFlight && BasicDeltaV_Settings.Instance.ShowCurrentStageOnly)
                {
                    if (group.inverseStageIndex == StageManager.LastStage)
                    {
                        if (panel.Stage.deltaV <= 0)
                        {
                            panel.ToggleNoDVModules(true);
                        }
                        else
                        {
                            panel.ToggleNoDVModules(false);
                        }
                    }
                    //if (group.inverseStageIndex != StageManager.LastStage)
                    //{
                    //    panel.SetVisible(false);
                    //    continue;
                    //}
                    //else if (panel.Stage.deltaV <= 0)
                    //{
                    //    panel.ToggleNoDVModules(true);
                    //}
                    //else
                    //{
                    //    panel.ToggleNoDVModules(false);
                    //}
                }
                else if (panel.Stage.deltaV <= 0)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (HighLogic.LoadedSceneIsFlight)
                {
                    bool info = false;

                    int checks = 0;

                    for (int j = group.Icons.Count - 1; j >= 0; j--)
                    {
                        if (checks >= 2)
                        {
                            break;
                        }

                        StageIcon icon = group.Icons[j];

                        if (icon.grouped)
                        {
                            if (icon.expanded)
                            {
                                if (checks >= 1)
                                {
                                    if (icon.groupedIcons[icon.groupedIcons.Count - 1].isDisplayingInfo)
                                    {
                                        info = true;
                                        break;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    checks += 2;
                                }
                            }
                            else
                            {
                                checks++;
                            }

                            if (!icon.isDisplayingInfoInGroup)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            checks++;

                            if (!icon.isDisplayingInfo)
                            {
                                continue;
                            }
                        }

                        info = true;
                        break;
                    }

                    if (info)
                    {
                        if (!panel.PanelRight)
                        {
                            panel.MovePanel(true);
                        }
                    }
                    else if (panel.PanelRight)
                    {
                        panel.MovePanel(false);
                    }
                }

                panel.SetVisible(true);
            }
        }
コード例 #8
0
        private void AddStagePanel(StageGroup group, bool display)
        {
            bool iconInfo = false;

            StageIconInfoBox dvInfo = null;

            if (HighLogic.LoadedSceneIsFlight)
            {
                int checks = 0;

                for (int i = group.Icons.Count - 1; i >= 0; i--)
                {
                    StageIcon icon = group.Icons[i];

                    if (icon.grouped)
                    {
                        if (icon.expanded)
                        {
                            if (checks >= 1)
                            {
                                if (icon.groupedIcons[icon.groupedIcons.Count - 1].isDisplayingInfo)
                                {
                                    iconInfo = true;
                                    break;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                checks += 2;
                            }
                        }
                        else
                        {
                            checks++;
                        }

                        if (!icon.isDisplayingInfoInGroup)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        checks++;

                        if (!icon.isDisplayingInfo)
                        {
                            continue;
                        }
                    }

                    iconInfo = true;
                    break;
                }

                //BasicDeltaV.BasicLogging("Info Box: {0}", BasicDeltaV_Loader.PanelInfoBarPrefab == null ? "Null" : "Valid");

                dvInfo = Instantiate(BasicDeltaV_Loader.PanelInfoBarPrefab, group.transform);
                dvInfo.transform.SetAsFirstSibling();
            }

            BasicDeltaV_StagePanel panel = new BasicDeltaV_StagePanel(group.RectTransform, group.inverseStageIndex, iconInfo, display, dvInfo);

            panels.Add(group, panel);
        }