Exemplo n.º 1
0
        private void Move(AvailablePart aPart, int qty, KASModuleContainer destContainer)
        {
            KASModuleGrab moduleGrab = aPart.partPrefab.GetComponent <KASModuleGrab>();

            if (!moduleGrab)
            {
                fxSndBipWrong.audio.Play();
                KAS_Shared.DebugError("Cannot grab the part taken, no grab module found !");
                return;
            }
            if (destContainer.MaxSizeReached(aPart, 1))
            {
                fxSndBipWrong.audio.Play();
                ScreenMessages.PostScreenMessage("Max size of the destination container reached !", 5, ScreenMessageStyle.UPPER_CENTER);
                return;
            }
            Remove(aPart, qty);
            destContainer.Add(aPart, qty);
        }
Exemplo n.º 2
0
        private Vector2 GuiContentList(Dictionary <string, PartContent> contentsList, ShowButton showButton, KASModuleContainer actionContainer, Vector2 scrollPos, bool showTotal = true, KASModuleContainer destContainer = null, float scrollHeight = 300f)
        {
            scrollPos = GUILayout.BeginScrollView(scrollPos, guiDataboxStyle, GUILayout.Width(600f), GUILayout.Height(scrollHeight));

            foreach (PartContent item in contentsList.Values)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("  " + item.part.title, "Name"), guiCenterStyle, GUILayout.Width(300f));
                GUILayout.Label(new GUIContent("  " + item.storedSize.ToString("0.0"), "Size"), guiCenterStyle, GUILayout.Width(50f));
                GUILayout.Label(new GUIContent("  " + item.averageMass.ToString("0.000"), "Mass"), guiCenterStyle, GUILayout.Width(50f));
                GUILayout.Label(new GUIContent("  " + item.totalCount, "Quantity"), guiCenterStyle, GUILayout.Width(50f));
                if (showButton == ShowButton.Add)
                {
                    if (GUILayout.Button(new GUIContent("Add", "Add part to container"), guiButtonStyle, GUILayout.Width(50f)))
                    {
                        if (actionContainer.MaxSizeReached(item.grabModule, 1))
                        {
                            fxSndBipWrong.audio.Play();
                            ScreenMessages.PostScreenMessage("Max size of the container reached !", 5, ScreenMessageStyle.UPPER_CENTER);
                            return(scrollPos);
                        }
                        else
                        {
                            actionContainer.Add(item.part, 1);
                        }
                    }
                }
                if (showButton == ShowButton.Remove)
                {
                    if (GUILayout.Button(new GUIContent("Remove", "Remove part from container"), guiButtonStyle, GUILayout.Width(60f)))
                    {
                        actionContainer.Remove(item.part, 1);
                    }
                }
                if (showButton == ShowButton.Take)
                {
                    if (GUILayout.Button(new GUIContent("Take", "Take part from container"), guiButtonStyle, GUILayout.Width(60f)))
                    {
                        actionContainer.Take(item);
                    }

                    /*
                     * if (GUILayout.Button(new GUIContent("Attach", "Attach part"), guiButtonStyle, GUILayout.Width(60f)))
                     * {
                     *  KASModuleGrab moduleGrab = ct.Key.partPrefab.GetComponent<KASModuleGrab>();
                     *  KASAddonPointer.StartPointer(ct.Key.partPrefab, KASAddonPointer.PointerMode.CopyAndAttach, true, true, true, 2, this.part.transform, false);
                     * }*/
                }
                if (showButton == ShowButton.Move)
                {
                    if (GUILayout.Button(new GUIContent("Move", "Move part to the destination container"), guiButtonStyle, GUILayout.Width(60f)))
                    {
                        actionContainer.Move(item, 1, destContainer);
                    }
                }
                GUILayout.EndHorizontal();
            }
            if (showTotal)
            {
                GUILayout.Space(5);
                GUILayout.BeginVertical(guiCenterStyle);
                GUILayout.BeginHorizontal();

                GUIStyle guiLeftWhiteStyle = new GUIStyle(GUI.skin.label);
                guiLeftWhiteStyle.wordWrap         = false;
                guiLeftWhiteStyle.normal.textColor = Color.white;
                guiLeftWhiteStyle.alignment        = TextAnchor.MiddleLeft;

                GUIStyle guiRightWhiteStyle = new GUIStyle(GUI.skin.label);
                guiRightWhiteStyle.wordWrap         = false;
                guiRightWhiteStyle.normal.textColor = Color.white;
                guiRightWhiteStyle.alignment        = TextAnchor.MiddleRight;

                GUILayout.Label(new GUIContent("Weight : " + actionContainer.part.mass.ToString("0.000"), "Total weight of the container with contents"), guiRightWhiteStyle);
                GUILayout.Label(new GUIContent(" | Space : " + actionContainer.totalSize.ToString("0.0") + " / " + actionContainer.maxSize.ToString("0.0"), "Space used / Max space"), guiRightWhiteStyle);
                GUILayout.Label(new GUIContent(" | Cost : √" + actionContainer.GetModuleCost().ToString("0.00"), "Total cost of the container's contents"), guiRightWhiteStyle);
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }
            GUILayout.EndScrollView();
            return(scrollPos);
        }
Exemplo n.º 3
0
 private void Move(AvailablePart aPart, int qty, KASModuleContainer destContainer)
 {
     KASModuleGrab moduleGrab = aPart.partPrefab.GetComponent<KASModuleGrab>();
     if (!moduleGrab)
     {
         fxSndBipWrong.audio.Play();
         KAS_Shared.DebugError("Cannot grab the part taken, no grab module found !");
         return;
     }
     if (destContainer.MaxSizeReached(aPart, 1))
     {
         fxSndBipWrong.audio.Play();
         ScreenMessages.PostScreenMessage("Max size of the destination container reached !", 5, ScreenMessageStyle.UPPER_CENTER);
         return;
     }
     Remove(aPart, qty);
     destContainer.Add(aPart, qty);
 }
Exemplo n.º 4
0
        private Vector2 GuiContentList(Dictionary<AvailablePart, int> contentsList, ShowButton showButton, KASModuleContainer actionContainer, Vector2 scrollPos, bool showTotal = true, KASModuleContainer destContainer = null, float scrollHeight = 300f)
        {
            scrollPos = GUILayout.BeginScrollView(scrollPos, guiDataboxStyle, GUILayout.Width(600f), GUILayout.Height(scrollHeight));

            foreach (KeyValuePair<AvailablePart, int> ct in contentsList)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("  " + ct.Key.title, "Name"), guiCenterStyle, GUILayout.Width(300f));
                GUILayout.Label(new GUIContent("  " + GetPartSize(ct.Key).ToString("0.0"), "Size"), guiCenterStyle, GUILayout.Width(50f));
                GUILayout.Label(new GUIContent("  " + ct.Key.partPrefab.mass.ToString("0.000"), "Mass"), guiCenterStyle, GUILayout.Width(50f));
                GUILayout.Label(new GUIContent("  " + ct.Value, "Quantity"), guiCenterStyle, GUILayout.Width(50f));
                if (showButton == ShowButton.Add)
                {
                    if (GUILayout.Button(new GUIContent("Add", "Add part to container"), guiButtonStyle, GUILayout.Width(50f)))
                    {
                        if (actionContainer.MaxSizeReached(ct.Key, 1))
                        {
                            fxSndBipWrong.audio.Play();
                            ScreenMessages.PostScreenMessage("Max size of the container reached !", 5, ScreenMessageStyle.UPPER_CENTER);
                            return scrollPos;
                        }
                        else
                        {
                            actionContainer.Add(ct.Key, 1);
                        }
                    }
                }
                if (showButton == ShowButton.Remove)
                {
                    if (GUILayout.Button(new GUIContent("Remove", "Remove part from container"), guiButtonStyle, GUILayout.Width(60f)))
                    {
                        actionContainer.Remove(ct.Key, 1);
                    }
                }
                if (showButton == ShowButton.Take)
                {
                    if (GUILayout.Button(new GUIContent("Take", "Take part from container"), guiButtonStyle, GUILayout.Width(60f)))
                    {
                        actionContainer.Take(ct.Key);
                    }
                    /*
                    if (GUILayout.Button(new GUIContent("Attach", "Attach part"), guiButtonStyle, GUILayout.Width(60f)))
                    {
                        KASModuleGrab moduleGrab = ct.Key.partPrefab.GetComponent<KASModuleGrab>();
                        KASAddonPointer.StartPointer(ct.Key.partPrefab, KASAddonPointer.PointerMode.CopyAndAttach, true, true, true, 2, this.part.transform, false);
                    }*/
                }
                if (showButton == ShowButton.Move)
                {
                    if (GUILayout.Button(new GUIContent("Move", "Move part to the destination container"), guiButtonStyle, GUILayout.Width(60f)))
                    {
                        actionContainer.Move(ct.Key, 1, destContainer);
                    }
                }
                GUILayout.EndHorizontal();

            }
            if (showTotal)
            {
                GUILayout.Space(5);
                GUILayout.BeginVertical(guiCenterStyle);
                GUILayout.BeginHorizontal();

                GUIStyle guiLeftWhiteStyle = new GUIStyle(GUI.skin.label);
                guiLeftWhiteStyle.wordWrap = false;
                guiLeftWhiteStyle.normal.textColor = Color.white;
                guiLeftWhiteStyle.alignment = TextAnchor.MiddleLeft;

                GUIStyle guiRightWhiteStyle = new GUIStyle(GUI.skin.label);
                guiRightWhiteStyle.wordWrap = false;
                guiRightWhiteStyle.normal.textColor = Color.white;
                guiRightWhiteStyle.alignment = TextAnchor.MiddleRight;

                GUILayout.Label(new GUIContent("Weight : " + actionContainer.part.mass.ToString("0.000"), "Total weight of the container with contents"), guiRightWhiteStyle);
                GUILayout.Label(new GUIContent(" | Space : " + actionContainer.totalSize.ToString("0.0") + " / " + actionContainer.maxSize.ToString("0.0"), "Space used / Max space"), guiRightWhiteStyle);
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }
            GUILayout.EndScrollView();
            return scrollPos;
        }