Example #1
0
        private void initRecipeTable()
        {
            recipeTable = new Table();

            var back = new SubtextureDrawable(new Nez.Textures.Subtexture(windowFrame));

            back.setPadding(0, 620, 0, 540);
            recipeTable.setBackground(back);
            recipeTable.setSize(540, 620);
            allContain.add(recipeTable).top().left().pad(25);

            recipeTable.add(new Label("配方"));

            recipeContentTable = new Table();
            ButtonGroup buttonGroup = new ButtonGroup();

            foreach (var recipe in player.recipes)
            {
                var button = new TextButton(recipe.name, Skin.createDefaultSkin());
                buttonGroup.add(button);
                recipeContentTable.add(button).width(50).height(20);
                button.onClicked += obj =>
                {
                    allContain.clear();
                    initRecipeTable();
                    //allContain.removeElement(recipeDetailTable);
                    initRecipeDetailTable(recipe);
                };
            }

            recipeScrollPane = new ScrollPane(recipeContentTable, Skin.createDefaultSkin());
            recipeTable.addElement(recipeScrollPane).setPosition(30, 30);
            recipeScrollPane.setSize(500, 540);
        }
Example #2
0
        private void initializeItemTable()
        {
            itemTable = new Table();

            var windowFrame = Core.content.Load <Texture2D>("UI/window_frame_grey");
            var buttonFrame = Core.content.Load <Texture2D>("UI/frame_grey");

            var back = new SubtextureDrawable(new Nez.Textures.Subtexture(windowFrame));

            back.setPadding(0, 620, 0, 540);
            itemTable.setBackground(back);

            allContain.add(itemTable).right().top().pad(25);


            itemDetailTable = new Table();
            itemDetailTable.setFillParent(true).top().left();
            itemScrollPane = new ScrollPane(itemDetailTable, Skin.createDefaultSkin());

            itemTable.addElement(itemScrollPane).setPosition(30, 30);
            itemScrollPane.setSize(500, 540);

            ButtonGroup buttonGroup = new ButtonGroup();

            int counts = 0;

            var itemlist = player.items.Keys.Where(m => m.types == ItemComponent.ItemTypes.Equitment).ToList();

            foreach (var item in itemlist)
            {
                var imageUp   = new SubtextureDrawable(item.itemIcon);
                var imageDown = new SubtextureDrawable(item.itemIcon);
                imageDown.tintColor = Color.DarkGray;
                var imageChecked = new SubtextureDrawable(item.itemIcon);
                imageChecked.tintColor = Color.DarkKhaki;
                var button = new ItemIconButton(imageUp, imageDown, imageChecked);
                button.setBackground(new SubtextureDrawable(buttonFrame));
                button.item          = item;
                button.OnMouseEntry += Button_OnMouseEntry;
                button.OnMouseExit  += Button_OnMouseExit;
                button.onClicked    += Button_onClicked;
                buttonGroup.add(button);
                counts++;

                itemDetailTable.add(button).minSize(64);
                if (counts > rowcount)
                {
                    counts = 0;
                    itemDetailTable.row();
                }
            }


            allContain.addElement(new Label("摁Q:关闭")).setPosition(1200, 710);
        }
Example #3
0
        private void initializeEquitTable()
        {
            equitTable  = new Table();
            windowFrame = Core.content.Load <Texture2D>("UI/window_frame_grey");
            buttonFrame = Core.content.Load <Texture2D>("UI/frame_grey");

            var back = new SubtextureDrawable(new Nez.Textures.Subtexture(windowFrame));

            back.setPadding(0, 620, 0, 540);
            equitTable.setBackground(back);
            equitTable.setSize(540, 620);
            allContain.add(equitTable).top().left().pad(25);

            var helmet = createItembutton(player.helmet);

            var armor = createItembutton(player.armor);

            var shoes = createItembutton(player.shoes);

            var necklace = createItembutton(player.necklace);

            var wristbands = createItembutton(player.wristbands);

            var ring = createItembutton(player.ring);

            var weapon = createItembutton(player.weapon);

            var shield   = createItembutton(player.shield);
            int addition = 80;

            var playerTexture = Core.content.Load <Texture2D>("Images/Players/player");
            var subtexture    = Subtexture.subtexturesFromAtlas(playerTexture, 24, 32);

            equitTable.addElement(new Image(subtexture[0])).setPosition(198, 80).setScale(6f);

            equitTable.addElement(helmet).setPosition(30, 30).setSize(64, 64);
            equitTable.addElement(armor).setPosition(30, 30 + addition).setSize(64, 64);
            equitTable.addElement(shoes).setPosition(30, 30 + addition * 2).setSize(64, 64);


            equitTable.addElement(necklace).setPosition(446, 30).setSize(64, 64);
            equitTable.addElement(wristbands).setPosition(446, 30 + addition).setSize(64, 64);
            equitTable.addElement(ring).setPosition(446, 30 + addition * 2).setSize(64, 64);

            equitTable.addElement(weapon).setPosition(150, 320).setSize(64, 64);
            equitTable.addElement(shield).setPosition(326, 320).setSize(64, 64);

            InitPropertiesTable();
        }
Example #4
0
        private void initializaDetailTable()
        {
            recipeTable = new Table();
            recipeTable.debugAll();
            var windowFrame = Core.content.Load <Texture2D>("UI/window_frame_grey");

            var back = new SubtextureDrawable(new Nez.Textures.Subtexture(windowFrame));

            back.setPadding(0, 620, 0, 540);
            recipeTable.setBackground(back);

            allContain.add(recipeTable).top().right().pad(25);


            detailScrollPane = new ScrollPane(null, Skin.createDefaultSkin());
            recipeTable.addElement(detailScrollPane).setPosition(30, 30).fillParent = true;

            detailMessageTable = new Table();
            detailScrollPane.setWidget(detailMessageTable);
        }
Example #5
0
        private void playerPropsButton_OnMouseEntry(Button obj)
        {
            var windowFrame = Core.content.Load <Texture2D>("UI/frame_opaque");
            var btn         = obj as ItemIconButton;

            btn.entryTable = new Table();
            btn.entryTable.debugAll();
            btn.entryTable.setFillParent(false);

            var detailTable = createItemDeatil(btn);

            btn.entryTable.addElement(detailTable);
            btn.entryTable.setSize(detailTable.preferredWidth < 200 ? 200 : detailTable.preferredWidth, detailTable.preferredHeight < 200 ? 200 : detailTable.preferredHeight);

            var back = new SubtextureDrawable(new Nez.Textures.Subtexture(windowFrame));

            back.setPadding(0, btn.entryTable.preferredWidth, 0, btn.entryTable.preferredHeight);
            btn.entryTable.setBackground(back);

            var x = btn.getX() + btn.getWidth();
            var y = btn.getY();



            Rectangle rectangle = new Rectangle((int)(playerPropTable.getX() + allContain.getX() + x), (int)(playerPropTable.getY() + allContain.getY() + y), (int)btn.entryTable.getWidth(), (int)btn.entryTable.getHeight());

            if (rectangle.Bottom > Screen.height)
            {
                y = btn.getY() + btn.getHeight() - btn.entryTable.getHeight();
            }
            if (rectangle.Right > Screen.width)
            {
                x = btn.getX() - btn.entryTable.getWidth();
            }

            playerPropTable.addElement(btn.entryTable).setPosition(x, y);
        }
Example #6
0
        private void initRecipeDetailTable(Recipe.Recipe recipe = null)
        {
            recipeDetailTable = new Table();
            var back = new SubtextureDrawable(new Nez.Textures.Subtexture(windowFrame));

            back.setPadding(0, 620, 0, 540);
            recipeDetailTable.setBackground(back);

            detailCell = allContain.add(recipeDetailTable).top().right().pad(25);


            recipeDetailContentTable = new Table();
            if (recipe != null)
            {
                bool enable = true;
                foreach (var mater in recipe.rawMaterials)
                {
                    recipeDetailContentTable.add(new Image(mater.material.itemIcon)).size(64);
                    if (player.items.Keys.Where(m => m.id == mater.material.id).Count() > 0)
                    {
                        var item  = player.items.Keys.Where(m => m.id == mater.material.id).First();
                        var label = new Label($"{player.items[item]}/{mater.count}");
                        if (player.items[item] < mater.count)
                        {
                            label.setFontColor(Color.Red);
                            recipeDetailContentTable.add(label);
                            enable = false;
                        }
                        else
                        {
                            recipeDetailContentTable.add(label);
                        }
                    }
                    else
                    {
                        var label = new Label($"0/{mater.count}");
                        label.setFontColor(Color.Red);
                        recipeDetailContentTable.add(label);
                        enable = false;
                    }

                    recipeDetailContentTable.row();
                }
                if (enable)
                {
                    var button = new TextButton("建造", Skin.createDefaultSkin());
                    button.onClicked += btn => {
                        foreach (var mat in recipe.rawMaterials)
                        {
                            player.throwOut(player.items.Keys.Where(m => m.id == mat.material.id).First(), mat.count);
                        }

                        //Core.startCoroutine(createProcessBar(recipe));
                        player.pickUp(recipe.produce, recipe.porduceCount);
                        allContain.clear();
                        initRecipeTable();
                        initRecipeDetailTable(recipe);
                    };
                    recipeDetailContentTable.add(button).width(50).height(20);
                }
                ;
            }

            recipeDetailScrollPane = new ScrollPane(recipeDetailContentTable, Skin.createDefaultSkin());
            recipeDetailTable.addElement(recipeDetailScrollPane).setPosition(30, 30);
        }
Example #7
0
        private void initplayerPropTable()
        {
            playerPropTable = new Table();
            var back = new SubtextureDrawable(new Nez.Textures.Subtexture(windowFrame));

            back.setPadding(0, 620, 0, 540);
            playerPropTable.setBackground(back);
            playerPropTable.setSize(540, 620);
            allContain.add(playerPropTable).top().left().pad(25);

            playerPropContentTable = new Table();
            playerPropContentTable.setFillParent(true);
            playerPropTable.addElement(playerPropContentTable);

            ItemIconButton ApropsButton, SpropsButton, DpropsButton, FpropsButton, GpropsButton;

            if (player.AProps == null)
            {
                ApropsButton = new ItemIconButton(new PrimitiveDrawable(Color.DarkGray));
            }
            else
            {
                ApropsButton = createItembutton(player.AProps);
            }

            if (player.SProps == null)
            {
                SpropsButton = new ItemIconButton(new PrimitiveDrawable(Color.DarkGray));
            }
            else
            {
                SpropsButton = createItembutton(player.SProps);
            }

            if (player.DProps == null)
            {
                DpropsButton = new ItemIconButton(new PrimitiveDrawable(Color.DarkGray));
            }
            else
            {
                DpropsButton = createItembutton(player.DProps);
            }

            if (player.FProps == null)
            {
                FpropsButton = new ItemIconButton(new PrimitiveDrawable(Color.DarkGray));
            }
            else
            {
                FpropsButton = createItembutton(player.FProps);
            }

            if (player.GProps == null)
            {
                GpropsButton = new ItemIconButton(new PrimitiveDrawable(Color.DarkGray));
            }
            else
            {
                GpropsButton = createItembutton(player.GProps);
            }


            playerPropContentTable.add(ApropsButton).size(64);
            playerPropContentTable.add(SpropsButton).size(64);
            playerPropContentTable.add(DpropsButton).size(64);
            playerPropContentTable.add(FpropsButton).size(64);
            playerPropContentTable.add(GpropsButton).size(64);
        }
Example #8
0
        private void initPropsDetailTable()
        {
            propsTable = new Table();
            var back = new SubtextureDrawable(new Nez.Textures.Subtexture(windowFrame));

            back.setPadding(0, 620, 0, 540);
            propsTable.setBackground(back);

            allContain.add(propsTable).right().top().pad(25);

            propsDeatilTable = new Table();
            propsDeatilTable.setFillParent(true).top().left();

            ButtonGroup buttonGroup = new ButtonGroup();
            int         counts      = 0;

            var ItemList = player.items.Keys.Where(m => m.types == ItemComponent.ItemTypes.ExecuteableProp).ToList();

            if (player.AProps != null)
            {
                var item = ItemList.Where(m => m.id == player.AProps.id).First();
                ItemList.Remove(item);
            }
            if (player.SProps != null)
            {
                var item = ItemList.Where(m => m.id == player.SProps.id).First();
                ItemList.Remove(item);
            }
            if (player.DProps != null)
            {
                var item = ItemList.Where(m => m.id == player.DProps.id).First();
                ItemList.Remove(item);
            }
            if (player.FProps != null)
            {
                var item = ItemList.Where(m => m.id == player.FProps.id).First();
                ItemList.Remove(item);
            }
            if (player.GProps != null)
            {
                var item = ItemList.Where(m => m.id == player.GProps.id).First();
                ItemList.Remove(item);
            }

            foreach (var item in ItemList)
            {
                var imageUp   = new SubtextureDrawable(item.itemIcon);
                var imageDown = new SubtextureDrawable(item.itemIcon);
                imageDown.tintColor = Color.DarkGray;
                var imageChecked = new SubtextureDrawable(item.itemIcon);
                imageChecked.tintColor = Color.DarkKhaki;
                var button = new ItemIconButton(imageUp, imageDown, imageChecked);
                button.setBackground(new SubtextureDrawable(buttonFrame));
                button.item          = item;
                button.OnMouseEntry += Button_OnMouseEntry;
                button.OnMouseExit  += Button_OnMouseExit;
                button.onClicked    += Button_onClicked;
                buttonGroup.add(button);
                counts++;

                propsDeatilTable.add(button).size(64);
                if (counts > rowcount)
                {
                    counts = 0;
                    propsDeatilTable.row();
                }
            }
            propsScrollPane = new ScrollPane(propsDeatilTable, Skin.createDefaultSkin());

            propsTable.addElement(propsScrollPane).setPosition(30, 30);
            propsScrollPane.setSize(500, 540);
        }