Exemplo n.º 1
0
    //RectTransform trans;
    private void Start()
    {
        var picObj = myPanel.AddImage(currentHood.thumbnail, new Vector2(transform.position.x, transform.position.y));

        picObj.transform.localScale = new Vector3(0.5f, 0.5f, 1f);
        var frameObj = myPanel.AddButton(MainMenu.hoodFrame, new Vector2(transform.position.x, transform.position.y), true);

        hoodName           = myPanel.AddText(currentHood.name, new Vector2(transform.localPosition.x, transform.localPosition.y - 115f), 16);
        hoodName.alignment = TextAnchor.UpperCenter;
        children           = new GameObject();
        children.transform.SetParent(transform);
        children.transform.localPosition = Vector3.zero;
        picObj.transform.SetParent(children.transform);
        frameObj.transform.SetParent(children.transform);
        picObj.transform.localPosition   = Vector3.zero;
        frameObj.transform.localPosition = Vector3.zero;
        picture = picObj.GetComponent <RawImage>();
        hoodName.transform.SetParent(children.transform);
        frameObj.onPress = GoToHood;
    }
Exemplo n.º 2
0
        public void Init()
        {
            dots = new AnimatedGameObject(new Vector2(100, 100), dots_texture, 2, 3);

            // Init UI
            panel1 = ui_manager.GetRootPanel.AddPanel(new Vector4(0.0f, 0.00f, 1f, 1f));
            //panel2 = new Panel(ui_manager.GetRootPanel, new Vector4(0.2f, 0.1f, 0.6875f, 0.5083333f));
            //panel2 = new Panel(ui_manager.GetRootPanel, new Vector4(0.40f, 0.00f, 0.6f, 0.6f));
            //panel2.Enable = true;
            button1 = panel1.AddButton(new Vector4(0.0f, 0.0f, 0.2f, 0.2f), Print);

            panel1.Texture = UI_overlay;
            //panel2.Texture = UI_overlay;
            m_stagemanager = new StageManager(m_road_textures, m_scenery_textures, m_bike_tex, m_camera, pinky);
            //panel1.AddSlider(new Vector2(0.1f, 0.1f), 50, false);

            /*
             * Table table1 = panel1.AddTable(new Vector2(0.15f, 0.2f), (Texture2D)m_gui_object_textures["TableContainer"], (Texture2D)m_gui_object_textures["TableRow"]);
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             * table1.AddRow();
             */
            m_game_started = true;
        }
Exemplo n.º 3
0
        private void HandleRightClick()
        {
            if (ActiveTool == ActiveToolType.Select)
            {
                RevertDrag();
                return;
            }

            RightClickOptions options = ~RightClickOptions.Remove;

            rightClickMousePosition = mousePosition;

            if (HasCollision(rightClickMousePosition))
            {
                Element e = FindCollisionUnder(rightClickMousePosition);
                if (e != null)
                {
                    options = RightClickOptions.Remove;
                }
            }

            if (rightClickPanel == null)
            {
                rightClickPanel = new Panel();
                plDraw.Controls.Add(rightClickPanel);

                rightClickPanel.Width  = 100;
                rightClickPanel.Height = 140;

                rightClickPanel.AddButton("Remove", 0, (x, y) =>
                {
                    Element e = FindCollisionUnder(rightClickMousePosition);
                    if (e == null)
                    {
                        return;
                    }
                    else
                    {
                        RemoveElement(e);
                    }
                }).Name = "remove";
                rightClickPanel.AddButton("Add Pump", 20, (x, y) => { AddElement <Pump>(rightClickMousePosition); });
                rightClickPanel.AddButton("Add Sink", 40, (x, y) => { AddElement <Sink>(rightClickMousePosition); });
                rightClickPanel.AddButton("Add Splitter", 60, (x, y) => { AddElement <Splitter>(rightClickMousePosition); });
                rightClickPanel.AddButton("Add Adjustable", 80, (x, y) => { AddElement <AdjustableSplitter>(rightClickMousePosition); });
                rightClickPanel.AddButton("Add Merger", 100, (x, y) => { AddElement <Merger>(rightClickMousePosition); });
                rightClickPanel.AddButton("Cancel", 120).Name = "cancel";

                foreach (var item in rightClickPanel.Controls)
                {
                    if (item is Button)
                    {
                        (item as Button).Click += (x, y) => rightClickPanel.Visible = false;
                    }
                }
            }
            foreach (var item in rightClickPanel.Controls)
            {
                if (item is Button)
                {
                    (item as Button).Enabled = true;
                }
            }
            if (!options.HasFlag(RightClickOptions.Remove))
            {
                rightClickPanel.Controls.Find("remove", false)[0].Enabled = false;
            }
            else
            {
                foreach (var item in rightClickPanel.Controls)
                {
                    if (item is Button)
                    {
                        (item as Button).Enabled = false;
                    }
                }
                rightClickPanel.Controls.Find("remove", false)[0].Enabled = true;
            }

            rightClickPanel.Controls.Find("cancel", false)[0].Enabled = true;

            rightClickPanel.Location = rightClickMousePosition;
            rightClickPanel.Visible  = true;
            rightClickPanel.BringToFront();
            rightClickPanel.BackColor = Color.FromArgb(255, 157, 157, 157);
        }