Inheritance: MonoBehaviour
示例#1
0
    public void DeleteButtonById(string Id)
    {
        Button2D Panel = _Buttons.Find(x => x.gameObject.name == Id);

        Panel.Delete();
        _Buttons.Remove(Panel);
    }
示例#2
0
    public void DeleteButtonByIndex(int Idx)
    {
        Button2D ButtonObj = _Buttons[Idx];

        ButtonObj.Delete();
        _Buttons.Remove(ButtonObj);
    }
示例#3
0
    void Update()
    {
        // search for an activated button
        if (active==null) {
            for (int i=0; i<buttons.Length; ++i) {
                if (buttons[i].state!=0) {
                    // record active button, turn off all buttons
                    active = buttons[i];
                    for (int j=0; j<buttons.Length; ++j) {
                        if (buttons[j].gameObject!=active.gameObject) {
                            buttons[j].state = 0;
                            wasActive[buttons[j]] = buttons[j].enabled;
                            buttons[j].enabled = false;
                        }
                    }
                    break;
                }
            }
        }

        // if active button is no longer activated
        if (active!=null && active.state==0) {
            // clear active button, turn on all buttons
            active = null;
            for (int i=0; i<buttons.Length; ++i) {
                if (wasActive.ContainsKey(buttons[i]) && wasActive[buttons[i]])
                    buttons[i].enabled = true;
            }
            wasActive.Clear();
        }
    }
示例#4
0
        private void prepareResource(ContentManager contentManager)
        {
            texBackground = contentManager.Load <Texture2D>("Images/whiteScreen");

            try
            {
                texForeground.Add(UIDialogType.Confirm, contentManager.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/confirmDialog"));
            }
            catch { }
            try
            {
                texForeground.Add(UIDialogType.Message, contentManager.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/messageDialog"));
            }
            catch { }

            btnYes = new Button2D(contentManager.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/btnYesLight"));
            btnYes.FadeAtActive = true;

            btnNo = new Button2D(contentManager.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/btnNoLight"));
            btnNo.FadeAtActive = true;

            btnOk = new Button2D(contentManager.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/btnOkLight"));
            btnOk.FadeAtActive = true;

            fadeIn = Visible = false;
            alpha  = 0f;
        }
示例#5
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            Button2D targetButton = (Button2D)target;

            SerializedProperty property = serializedObject.FindProperty("onEnter");

            EditorGUILayout.PropertyField(property, new GUILayoutOption[0]);

            property = serializedObject.FindProperty("onDown");
            EditorGUILayout.PropertyField(property, new GUILayoutOption[0]);

            property = serializedObject.FindProperty("onUp");
            EditorGUILayout.PropertyField(property, new GUILayoutOption[0]);

            property = serializedObject.FindProperty("onExit");
            EditorGUILayout.PropertyField(property, new GUILayoutOption[0]);

            property = serializedObject.FindProperty("onBeginDrag");
            EditorGUILayout.PropertyField(property, new GUILayoutOption[0]);

            property = serializedObject.FindProperty("onDrag");
            EditorGUILayout.PropertyField(property, new GUILayoutOption[0]);

            property = serializedObject.FindProperty("onEndDrag");
            EditorGUILayout.PropertyField(property, new GUILayoutOption[0]);

            serializedObject.ApplyModifiedProperties();
        }
示例#6
0
        public ImageGrid(string id, Screen menu, Vector2 position)
            : base(id, menu)
        {
            size = new Vector2(256, 256);

            loadBtn = new Button2D(ID + "btn", menu, new Rectangle(1132, (int)position.Y, 80, 30),
                                   "Eon/Textures/Pixel", "Eon/Fonts/Arial23", "Load", 4, true);

            loadBtn.HoveredOverColour = Color.Green;
            loadBtn.FontColour        = Color.Black;
            loadBtn.Colour            = Color.DarkGray;
            loadBtn.OnClicked        += new OnClickedEvent(Load);

            openDia        = new System.Windows.Forms.OpenFileDialog();
            openDia.Filter = ".xnb File (*.xnb)|*.xnb";

            bg = new Sprite(ID + "BG", Color.DarkGray, true, position, size);
            AttachComponent(bg);

            grid = new Grid(ID + "Grid", position, 1, 1,
                            (int)size.X, (int)size.Y, 3, true);

            grid.Colour        = Color.White;
            grid.LineThickness = 1;

            AttachComponent(grid);

            tileSheet = new Sprite(ID + "Sheet", 2,
                                   "Eon/Textures/Pixel", Color.White, true,
                                   new Rectangle((int)grid.Position.X,
                                                 (int)grid.Position.Y, grid.Width,
                                                 grid.Height));

            AttachComponent(tileSheet);

            bounds = new Rectangle((int)position.X,
                                   (int)position.Y, (int)size.X, (int)size.Y);

            this.size = new Vector2()
            {
                X = size.X / cols,
                Y = size.Y / rows
            };

            hovered = new Sprite(ID + "Hovered", 2, "Eon/Textures/Pixel",
                                 new Color(0, 0, 255, 255), true, position, this.size);

            AttachComponent(hovered);

            selected = new Sprite(ID + "Selected", 2, "Eon/Textures/Pixel",
                                  new Color(0, 255, 0, 200), true, position, this.size);

            AttachComponent(selected);

            CreateCells();
            ShowLoadingTools();
        }
        protected override void prepareContent(ContentManager content)
        {
            texLeaderboardBackground = content.Load <Texture2D>("Images/leaderboardBackground");
            texLeaderboardForeground = content.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/leaderboardForeground");
            texLeaderboardSubmit     = content.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/leaderboardSubmit");
            texWhiteScreen           = content.Load <Texture2D>("Images/whiteScreen");
            btnSubmit = new Button2D(content.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/btnSubmitLight"), null, null, new Vector2(450, 380));
            btnSubmit.FadeAtActive = true;
            btnSubmit.Visible      = true;
            sprLoading             = new Sprite2D(content.Load <Texture2D>("Images/loading"), 60, 60);
            sprLoading.SetPosition(274, 210);
            uiDialog = new UIDialog(content);

            strRank      = Localize.Instance.FetchingRank;
            vtRank       = new Vector2(400 - Main.FontSmall.MeasureString(strRank).X / 2, 70);
            strView7     = new StringBuilder(Localize.Instance.FetchingData);
            vTargetLeft  = 134;
            vtView7      = new Vector2(26, vTargetLeft);
            strViewAll   = new StringBuilder(Localize.Instance.FetchingData);
            vTargetRight = 134;
            vtViewAll    = new Vector2(422, vTargetRight);
        }
示例#8
0
        public QuickMenu(PlayScene parent)
        {
            _parent = parent;
            ContentManager content = Main.Instance.Content;

            texMenu       = content.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/quickMenu");
            texBackground = content.Load <Texture2D>("Images/whiteScreen");
            vtMenu        = new Vector2(0, 480);

            //nut reset maze
            btnReset = new Button2D(
                content.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/qmnuResetMazeLight")
                );
            btnReset.Position = (Localize.Instance.Language == Language.English) ? new Vector2(157, 347) : new Vector2(172, 343);
            //nut get solution
            btnSolution = new Button2D(
                content.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/qmnuGetSolutionLight")
                );
            btnSolution.Position = (Localize.Instance.Language == Language.English) ? new Vector2(427, 347) : new Vector2(458, 343);
            //nut abandon
            btnAbandon = new Button2D(
                content.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/qmnuAbandonLight")
                );
            btnAbandon.Position = (Localize.Instance.Language == Language.English) ? new Vector2(179, 422) : new Vector2(177, 417);
            //nut main menu
            btnMain = new Button2D(
                content.Load <Texture2D>("Images/" + Localize.Instance.LanguageCode + "/qmnuMainMenuLight")
                );
            btnMain.Position = (Localize.Instance.Language == Language.English) ? new Vector2(436, 422) : new Vector2(440, 417);

            _backgroundAlpha = 0;
            _state           = QuickMenuState.Hide;
            confirmDialog    = new UIDialog(content);

            recMusic = new Rectangle(531, 132 + 480, 60, 60);
            recSound = new Rectangle(624, 132 + 480, 60, 60);
        }
示例#9
0
 public MenuItem(Button2D button)
 {
     this.button         = button;
     IsActive            = false;
     button.OnMouseOver += Button_OnMouseOver;
 }
示例#10
0
 public DynValue CallButton2D(string FuncName, Button2D Obj, DynValue[] Params)
 {
     return(Obj._Instance.Call(FuncName, Params));
 }
示例#11
0
    public IEnumerator WaitForCallButton2DCoroute(float TimeToWait, string FuncName, Button2D Obj, DynValue[] Params)
    {
        yield return(new WaitForSeconds(TimeToWait));

        Obj._Instance.Call(FuncName, Params);
    }
示例#12
0
 public void WaitForCallButton2D(float TimeToWait, string FuncName, Button2D Obj, DynValue[] Params)
 {
     StartCoroutine(WaitForCallButton2DCoroute(TimeToWait, FuncName, Obj, Params));
 }
示例#13
0
        protected override void Initialize()
        {
            #region Tile map

            tileMap            = new TileMapDeffination();
            tileMap.PostRender = false;

            mapCreator = new MapCreator(this, ref tileMap);

            #endregion
            #region Misc

            new Cursor("Cursor", "GUI/Cursors/Cursor", 16);

            float initX = 966;

            AttachComponent(new Sprite(ID + "BG0", 0, "Eon/Textures/Pixel", new Color(46, 46, 46, 255),
                                       true, new Vector2(initX, 0), new Vector2(Common.TextureQuality.X - initX, Common.TextureQuality.Y)));

            AttachComponent(new Sprite(ID + "BG1", 0, "Eon/Textures/Pixel", new Color(96, 96, 96, 255),
                                       true, new Vector2(initX - 140, 0), new Vector2(140, Common.TextureQuality.Y)));

            grid = new ImageGrid("ImgGrid", this, new Vector2(1056, 120));

            grid.OnSourceChanged += new SourceTileChangedEvent(SourceTileChanged);
            grid.OnLoadedTilemap += new LoadedTilemapEvent(AddLayer);

            CheckBox chk = new CheckBox(ID + "chkSwapImg", this,
                                        new Rectangle(1322, 120, 32, 32), 2, true);

            chk.CheckedImage   = "GUI/NormalMapIcon";
            chk.UnCheckedImage = "GUI/PictureIcon";
            chk.OnChecked     += new OnCheckToogledEvent(SwapImages);

            chkLayers = new CheckBox(ID + "chkLayers", this,
                                     new Rectangle(1322, 160, 32, 32), 2, true);

            chkLayers.Checked        = true;
            chkLayers.CheckedImage   = "GUI/SingleLayerIcon";
            chkLayers.UnCheckedImage = "GUI/AllLayersIcon";
            chkLayers.OnChecked     += new OnCheckToogledEvent(ChangeRendered);

            chkGrid = new CheckBox(ID + "chkGrid", this,
                                   new Rectangle(1322, 200, 32, 32), 2, true);

            chkGrid.Checked        = true;
            chkGrid.CheckedImage   = "GUI/GridOnIcon";
            chkGrid.UnCheckedImage = "GUI/GridOffIcon";
            chkGrid.OnChecked     += new OnCheckToogledEvent(ToogleGrids);

            Button2D btnDelete = new Button2D(ID + "btnDelete", this,
                                              new Rectangle(1322, 345, 32, 32), "GUI/BinIcon", "", "", 2, true);

            btnDelete.HoveredOverColour = new Color(0, 200, 0, 255);
            btnDelete.Colour            = Color.White;
            btnDelete.OnClicked        += new OnClickedEvent(DeleteCurrentLayer);

            #endregion
            #region IO

            initX -= 110;

            btnSave = new Button2D("btnSave", this, new Rectangle((int)initX, 120, 80, 35),
                                   "Eon/Textures/Pixel", "Eon/Fonts/Arial23", "Save", 1, true);

            btnSave.FontColour        = Color.White;
            btnSave.Colour            = new Color(46, 46, 46, 255);
            btnSave.HoveredOverColour = new Color(0, 200, 0, 255);
            btnSave.OnClicked        += new OnClickedEvent(Save);

            btnLoad = new Button2D("btnLoad", this, new Rectangle((int)initX, 170, 80, 35),
                                   "Eon/Textures/Pixel", "Eon/Fonts/Arial23", "Load", 1, true);

            btnLoad.FontColour        = Color.White;
            btnLoad.Colour            = new Color(46, 46, 46, 255);
            btnLoad.HoveredOverColour = new Color(0, 200, 0, 255);
            btnLoad.OnClicked        += new OnClickedEvent(Load);

            AttachComponent(new TextItem(ID + "lblLayers", 1, "Layers",
                                         "Eon/Fonts/Arial23", new Vector2(initX, 260), Color.White, true));

            initX += 24;
            int initY = 306;

            for (int i = 0; i < 10; i++)
            {
                CheckBox chkLayerBtn = new CheckBox(i + "", this,
                                                    new Rectangle((int)initX, initY, 34, 40), 1, true);

                chkLayerBtn.UnCheckedImage = "GUI/TileMap/" + i;
                chkLayerBtn.CheckedImage   = "GUI/TileMap/" + i + "Select";

                if (i == 0)
                {
                    chkLayerBtn.Checked = true;
                }

                chkLayerBtn.OnChecked += new OnCheckToogledEvent(ChangeTileLayer);

                initY += 40;
            }

            #endregion
            #region Rows/ Columns

            lblRows = new TextItem(ID + "lblRows", 3, "Rows",
                                   "GUI/Verdana12pt", new Vector2(1056, 403), Color.White, true);

            AttachComponent(lblRows);

            txtRows = new TextBox("txtRows", this,
                                  new Vector2(1181, 403), new Vector2(130, 25));

            txtRows.Text           = "1";
            txtRows.OnTextChanged += new OnTextChangedEvent(TextChanged);

            lblCols = new TextItem(ID + "lblCols", 3, "Columns",
                                   "GUI/Verdana12pt", new Vector2(1056, 446), Color.White, true);

            AttachComponent(lblCols);

            txtCols = new TextBox("txtCols", this,
                                  new Vector2(1181, 446), new Vector2(130, 25));

            txtCols.Text           = "1";
            txtCols.OnTextChanged += new OnTextChangedEvent(TextChanged);

            #endregion
            #region Tiles

            lblTilesX = new TextItem(ID + "lblTilesX", 3, "Tiles X",
                                     "GUI/Verdana12pt", new Vector2(1056, 533), Color.White, true);

            AttachComponent(lblTilesX);

            txtTilesX = new TextBox("txtTilesX", this,
                                    new Vector2(1181, 533), new Vector2(130, 25));

            txtTilesX.Text           = "1";
            txtTilesX.OnTextChanged += new OnTextChangedEvent(TextChanged);

            #region Plus / Minus Buttons

            Button2D btnTilesXMinus = new Button2D("btnTilesXMinus", this,
                                                   new Rectangle(1148, 533, 25, 25), "GUI/MinusIcon", "", "", 3, true);

            btnTilesXMinus.HoveredOverColour = Color.Green;
            btnTilesXMinus.OnClicked        += new OnClickedEvent(TilesChangeClicked);

            Button2D btnTilesXPlus = new Button2D("btnTilesXPlus", this,
                                                  new Rectangle(1320, 533, 25, 25), "GUI/PlusIcon", "", "", 3, true);

            btnTilesXPlus.HoveredOverColour = Color.Green;
            btnTilesXPlus.OnClicked        += new OnClickedEvent(TilesChangeClicked);

            #endregion

            lblTilesY = new TextItem(ID + "lblTilesY", 3, "Tiles Y",
                                     "GUI/Verdana12pt", new Vector2(1056, 576), Color.White, true);

            AttachComponent(lblTilesY);

            txtTilesY = new TextBox("txtTilesY", this,
                                    new Vector2(1181, 576), new Vector2(130, 25));

            txtTilesY.Text           = "1";
            txtTilesY.OnTextChanged += new OnTextChangedEvent(TextChanged);

            #region Plus / Minus Buttons

            Button2D btnTilesYMinus = new Button2D("btnTilesYMinus", this,
                                                   new Rectangle(1148, 576, 25, 25), "GUI/MinusIcon", "", "", 3, true);

            btnTilesYMinus.HoveredOverColour = Color.Green;
            btnTilesYMinus.OnClicked        += new OnClickedEvent(TilesChangeClicked);

            Button2D btnTilesYPlus = new Button2D("btnTilesYPlus", this,
                                                  new Rectangle(1320, 576, 25, 25), "GUI/PlusIcon", "", "", 3, true);

            btnTilesYPlus.HoveredOverColour = Color.Green;
            btnTilesYPlus.OnClicked        += new OnClickedEvent(TilesChangeClicked);

            #endregion

            #endregion
            #region Tile Size

            lblSizeX = new TextItem(ID + "lblSizeX", 3, "Tile Size X",
                                    "GUI/Verdana12pt", new Vector2(1056, 663), Color.White, true);

            AttachComponent(lblSizeX);

            txtSizeX = new TextBox("txtSizeX", this,
                                   new Vector2(1181, 663), new Vector2(130, 25));

            txtSizeX.Text           = "128";
            txtSizeX.OnTextChanged += new OnTextChangedEvent(TextChanged);

            lblSizeY = new TextItem(ID + "lblSizeY", 3, "Tile Size Y",
                                    "GUI/Verdana12pt", new Vector2(1056, 706), Color.White, true);

            AttachComponent(lblSizeY);

            txtSizeY = new TextBox("txtSizeY", this,
                                   new Vector2(1181, 706), new Vector2(130, 25));

            txtSizeY.Text           = "128";
            txtSizeY.OnTextChanged += new OnTextChangedEvent(TextChanged);

            #endregion

            base.Initialize();
        }