public ScreenPanel ChangePanel(ScreenType nextPanel)
    {
        RemoveCurrentScreenPanel();

        ScreenPanel newScreen = default;

        switch (nextPanel)
        {
        case ScreenType.listForm:
            newScreen = Instantiate(listadoFormPanel_prefab, canvas.transform);
            break;

        case ScreenType.formActivity:
            newScreen = Instantiate(listadoActivityFormPanel_prefab, canvas.transform);
            break;

        case ScreenType.activity:
            newScreen = Instantiate(activityPanel_prefab, canvas.transform);
            break;

        case ScreenType.mainMenu:
            newScreen = Instantiate(mainMenuPanel_prefab, canvas.transform);
            break;

        case ScreenType.logIn:
            newScreen = Instantiate(logInPanel_prefab, canvas.transform);
            break;

        default:
            break;
        }
        newScreen.gameObject.SetActive(true);
        currentPanel = newScreen;
        return(newScreen);
    }
    public void Init()
    {
        canvas = FindObjectOfType <Canvas>();

        RemoveCurrentScreenPanel();
        currentPanel = ChangePanel(ScreenType.logIn);
    }
예제 #3
0
    private static void CreateAndCatalogueScreen(Screens screenType, string prefabLocation)
    {
        GameObject screenPrefab       = Resources.Load <GameObject>(prefabLocation) as GameObject;
        GameObject instantiatedScreen = GameObject.Instantiate(screenPrefab);

        instantiatedScreen.transform.SetParent(_canvasRootObject.transform, false);
        ScreenPanel screenPanel = instantiatedScreen.GetComponent <ScreenPanel>();

        _availableScreens.Add(screenType, screenPanel);
    }
    private void RemoveCurrentScreenPanel()
    {
        if (currentPanel != null)
        {
            currentPanel.UnregisterButtonEvents();
            prevScrenPanel = currentPanel.panelType;
            Destroy(currentPanel.gameObject);
        }


        currentPanel = null;
    }
예제 #5
0
        private void SetupGui()
        {
            var fontSystem = FontSystemFactory.Create(GraphicsDevice, 2048, 2048);

            fontSystem.AddFont(File.ReadAllBytes("Content/Fonts/Goldman-Regular.ttf"));
            GuiHelper.Setup(this, fontSystem);
            _screen = new ScreenPanel {
                Layout = new LayoutVerticalCenter()
            };
            _focus         = new ComponentFocus(_screen, Default.ConditionPrevFocus, Default.ConditionNextFocus);
            _menuGuiModule = new GuiModule(_focus);
            Components.Add(_menuGuiModule);
        }
예제 #6
0
    // Call this whenever the contents of the panel list has changed
    private void InitializeStack()
    {
        // Do not call this from Awake, it is too early to obtain valid data from the canvas
        Debug.Log("InitializeStack:" + System.DateTime.Now.ToString());

        Canvas canvas = GetComponentInParent <Canvas>();

        // TODO: If this fails it should be an error
        if (canvas != null)
        {
            // Check if there is a canvas scaler being used
            CanvasScaler canvasScaler = GetComponentInParent <CanvasScaler>();

            // When there is a canvas scaler we need to extract the post scaled dimensions from it.
            // Otherwise we can just read the dimensions directly from the canvas rect.
            RectTransform canvasRectTransform = (canvasScaler != null) ? canvasScaler.GetComponent <RectTransform>() : canvas.GetComponent <RectTransform>();

            // TODO: If this fails it should be an error
            if (canvasRectTransform != null)
            {
                m_PanelWidth  = canvasRectTransform.rect.width;
                m_PanelHeight = canvasRectTransform.rect.height;

                RectTransform rectTransform;

                int index = 0;
                foreach (ScreenPanel screenPanel in m_PanelList)
                {
                    rectTransform = screenPanel.GetComponent <RectTransform>();
                    if (rectTransform != null)
                    {
                        // Set the anchor info
                        rectTransform.anchorMin        = new Vector2(0, 0);
                        rectTransform.anchorMax        = new Vector2(0, 0);
                        rectTransform.pivot            = new Vector2(0, 0);
                        rectTransform.anchoredPosition = new Vector2(0, m_PanelHeight * index);
                        ++index;

                        // Set the dimensions
                        rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, m_PanelHeight);
                        rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, m_PanelWidth);
                    }

                    // Ensure all child panels begin as disabled
                    ScreenPanel panel = screenPanel.GetComponent <ScreenPanel>();
                    if (panel != null)
                    {
                        panel.Enabled = false;
                    }
                }

                // Set up this parent panel based on the number of children
                rectTransform = GetComponent <RectTransform>();
                if (rectTransform != null)
                {
                    // Set the anchor info
                    rectTransform.anchorMin        = new Vector2(0, 0);
                    rectTransform.anchorMax        = new Vector2(0, 0);
                    rectTransform.pivot            = new Vector2(0, 0);
                    rectTransform.anchoredPosition = new Vector2(0, 0);

                    // Set the dimensions
                    rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, m_PanelHeight * index);
                    rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, m_PanelWidth);
                }


                // Reset the stack to the default position
                m_CurrentIndex    = 0;
                m_TargetIndex     = 0;
                m_TransitionValue = 0.0f;

                // Set the default panel as enabled
                m_PanelList[m_CurrentIndex].Enabled = true;
            }
        }
    }
예제 #7
0
        private void ScreenPanel_Paint(object sender, PaintEventArgs e)
        {
            float    centerX    = ScreenPanel.Width / 2;
            float    centerY    = ScreenPanel.Height / 2;
            Pen      linepen    = new Pen(Color.White);
            Brush    Backfiller = new SolidBrush(Color.Blue);
            Brush    Sidefiller = new SolidBrush(Color.White);
            Graphics draw       = ScreenPanel.CreateGraphics();

            //first point
            float x1 = 0.0f;
            float y1 = 0.4f;
            float z1 = 0.1f;
            //second point
            float x2 = 0.3f;
            float y2 = -0.4f;
            float z2 = 0.1f;
            //third point
            float x3 = -0.3f;
            float y3 = -0.4f;
            float z3 = 0.1f;

            //fourth point
            float x4 = 0.1f;
            float y4 = -0.4f;
            float z4 = 0.98f;


            {
                //rotation and transformation Z
                float pointz1 = 0.5f * (float)((z1 * Math.Cos(Xrot / 200) + 2 - x1 * Math.Sin(Xrot / 200)));
                float pointz2 = 0.5f * (float)((z2 * Math.Cos(Xrot / 200) + 2 - x2 * Math.Sin(Xrot / 200)));
                float pointz3 = 0.5f * (float)((z3 * Math.Cos(Xrot / 200) + 2 - x3 * Math.Sin(Xrot / 200)));
                float pointz4 = 0.5f * (float)((z4 * Math.Cos(Xrot / 200) + 2 - x4 * Math.Sin(Xrot / 200)));
                //rotation and transformation X
                float pointx1 = centerX + (160 * (float)(x1 * Math.Cos(Xrot / 200) + z1 * Math.Sin(Xrot / 200)) / pointz1) - Xrot * 2;
                float pointx2 = centerX + (160 * (float)(x2 * Math.Cos(Xrot / 200) + z2 * Math.Sin(Xrot / 200)) / pointz2) - Xrot * 2;
                float pointx3 = centerX + (160 * (float)(x3 * Math.Cos(Xrot / 200) + z3 * Math.Sin(Xrot / 200)) / pointz3) - Xrot * 2;
                float pointx4 = centerX + (160 * (float)(x4 * Math.Cos(Xrot / 200) + z4 * Math.Sin(Xrot / 200)) / pointz4) - Xrot * 2;
                //rotation and transform Y
                float pointy1 = centerY + -(90 * (float)(y1 * Math.Cos(yrot / 200) + z1 * Math.Sin(yrot / 200)) / pointz1) + yrot * 2;
                float pointy2 = centerY + -(90 * (float)(y2 * Math.Cos(yrot / 200) + z2 * Math.Sin(yrot / 200)) / pointz2) + yrot * 2;
                float pointy3 = centerY + -(90 * (float)(y3 * Math.Cos(yrot / 200) + z3 * Math.Sin(yrot / 200)) / pointz3) + yrot * 2;
                float pointy4 = centerY + -(90 * (float)(y4 * Math.Cos(yrot / 200) + z4 * Math.Sin(yrot / 200)) / pointz4) + yrot * 2;
                //storing floating point values in a Points bank
                PointF[] points1 = new PointF[3];
                points1[0] = floatToPoint(pointx1, pointy1);
                points1[1] = floatToPoint(pointx2, pointy2);
                points1[2] = floatToPoint(pointx3, pointy3);
                PointF[] points2 = new PointF[3];
                points2[0] = floatToPoint(pointx1, pointy1);
                points2[1] = floatToPoint(pointx2, pointy2);
                points2[2] = floatToPoint(pointx4, pointy4);
                PointF[] points3 = new PointF[3];
                points3[0] = floatToPoint(pointx1, pointy1);
                points3[1] = floatToPoint(pointx3, pointy3);
                points3[2] = floatToPoint(pointx4, pointy4);
                //drawing routine
                draw.Clear(Color.Black);
                //"for" loop used so there is enough time to draw all lines(not necessary)
                //for (int frame = 0; frame < frametime; frame++)

                {
                    DrawTriangle(draw, linepen, pointx1, pointy1, pointx4, pointy4, pointx2, pointy2);
                    DrawTriangle(draw, linepen, pointx1, pointy1, pointx4, pointy4, pointx3, pointy3);
                    if (pointz4 > pointz1)
                    {
                        draw.FillPolygon(Backfiller, points1);
                        DrawTriangle(draw, linepen, pointx1, pointy1, pointx2, pointy2, pointx3, pointy3);
                    }

                    if (pointx4 > pointx2 - 2)
                    {
                        draw.FillPolygon(Sidefiller, points2);
                    }
                    if (pointx4 < pointx3 + 2)
                    {
                        draw.FillPolygon(Sidefiller, points3);
                    }
                }
            }
        }