Beispiel #1
0
        public MainMenu()
        {
            gui     = new Gui();
            nameBox = gui.AddTextBox(new Vector2(500, 100), 200, 15);
            ipBox   = gui.AddTextBox(new Vector2(500, 200), 200, 15);

            nameBox.Buffer = GameSettings.PlayerName;
            ipBox.Buffer   = GameSettings.ConnectIP;

            gui.AddButton(new Vector2(100, 100), "Create Game", CreateGame);
            gui.AddButton(new Vector2(100, 200), "Join Game", JoinGame);
        }
Beispiel #2
0
        public ToolbarButton(
            Transform parent, string name,
            Anchor anchor, Vec2 pos, Vec2 size,
            float margin, Font font)
        {
            pane = Gui.CreatePane(
                parent, name, offColor,
                size, anchor, pos);

            img = Gui.CreateImage(pane.rectTransform, "<image>", null);
            img.rectTransform.SetFillWithMargin(margin);
            Gui.AddButton(img.gameObject, () => OnClick());

            TextCfg cfg = new TextCfg
            {
                font        = font,
                fontSizeMin = 5,
                fontSizeMax = 14,
                autoResize  = true,
                style       = FontStyle.Bold,
                anchor      = TextAnchor.LowerCenter,
                horiWrap    = HorizontalWrapMode.Wrap,
                vertWrap    = VerticalWrapMode.Truncate
            };

            text = Gui.CreateText(img.transform, "<text>", cfg);
            text.rectTransform.SetFillPartial(
                new Vec2(0, .08f), new Vec2(1, .48f));
        }
Beispiel #3
0
        private Btn MakeButton(RectTransform parent, int order)
        {
            Image pane   = Gui.CreateColor(parent, "<button>", ToolbarButton.offColor);
            var   xfPane = pane.rectTransform;

            xfPane.SetFixed(Anchor.TopLeft, new Vec2(8, 8 + 58 * order), new Vec2(parent.sizeDelta.x - 16, 50));
            var btn = Gui.AddButton(pane.gameObject);

            TextCfg cfg = TextCfg.Default(font);

            cfg.fontSize = 20;
            cfg.style    = FontStyle.Bold;
            cfg.anchor   = TextAnchor.UpperCenter;

            Text topText = Gui.CreateText(pane.rectTransform, "<name>", cfg);

            topText.rectTransform.SetFixed(Anchor.TopLeft, new Vec2(6, 4), new Vec2(xfPane.sizeDelta.x, 30));

            cfg.fontSize = 16;
            cfg.style    = FontStyle.Normal;
            Text botText = Gui.CreateText(pane.rectTransform, "<materials>", cfg);

            botText.rectTransform.SetFixed(Anchor.TopLeft, new Vec2(6, 26), new Vec2(xfPane.sizeDelta.x, 30));

            return(new Btn()
            {
                button = btn,
                textMain = topText,
                textSub = botText
            });
        }
Beispiel #4
0
        private Btn CreateButton()
        {
            var img = Gui.CreateColor(pane, "<button>", ToolbarButton.offColor);

            img.rectTransform.pivot = new Vec2(0, 1);
            var btn    = Gui.AddButton(img.gameObject);
            var layout = img.gameObject.AddComponent <HorizontalLayoutGroup>();

            layout.childAlignment         = TextAnchor.UpperLeft;
            layout.childControlWidth      = true;
            layout.childControlHeight     = true;
            layout.childForceExpandWidth  = true;
            layout.childForceExpandHeight = true;
            layout.childScaleHeight       = true;
            layout.childScaleWidth        = true;
            layout.padding = new RectOffset(8, 8, 8, 8);

            TextCfg cfg = new TextCfg
            {
                font       = font,
                fontSize   = 20,
                autoResize = false,
                style      = FontStyle.Normal,// Bold,
                anchor     = TextAnchor.UpperLeft,
                horiWrap   = HorizontalWrapMode.Wrap,
                vertWrap   = VerticalWrapMode.Overflow
            };

            var text = Gui.CreateText(img.transform, "<text>", cfg);

            text.rectTransform.pivot = new Vec2(0, 1);
            text.text = "Foobar manchu monskder sdf";

            return(new Btn(img.gameObject, btn, text));
        }
Beispiel #5
0
        public GameLobby()
        {
            currentSeed      = GameEngine.GetInstance().Client.ServerSeed;
            terrainGenerator = new TerrainGenerator();
            terrainGenerator.Generate(currentSeed);

            font = GameEngine.GetInstance().ResourceManager.GetSpriteFont(@"Gui\guiFont");

            gui = new Gui();
            // gui.AddLabel(new Vector2(100, 100), "Players");
            if (GameSettings.IsServer)
            {
                gui.AddButton(new Vector2(1000 - 35, 600), "Start Game", StartGame);
                gui.AddButton(new Vector2(1000, 400), "New Map", Generate);
                gui.AddButton(new Vector2(828, 400), "Load Map", Generate);
            }
            else
            {
                gui.AddButton(new Vector2(1000, 600), "Ready", SetReady);
            }


            gui.AddButton(new Vector2(100, 600), "Exit Lobby", MainMenu);
        }
        public WorldGenerator(World world)
        {
            gui        = new Gui();
            seed       = 0;
            rand       = new Random(seed);
            this.world = world;
            addLabel   = gui.AddLabel(new Vector2(100, 50), "Generator Add: " + GameSettings.GeneratorAdd.ToString());
            gui.AddSlider(new Vector2(100, 100), 300.0f, 1.0f, 100.0f, (float)GameSettings.GeneratorAdd, GeneratorAdd);
            subLabel = gui.AddLabel(new Vector2(100, 150), "Generator Sub: " + GameSettings.GeneratorSub.ToString());
            gui.AddSlider(new Vector2(100, 200), 300.0f, 0.05f, 20.0f, (float)GameSettings.GeneratorSub, GeneratorSub);

            freq1Label = gui.AddLabel(new Vector2(100, 250), "Freq1: " + freq1.ToString());
            gui.AddSlider(new Vector2(100, 300), 300.0f, 0.0f, 20.0f, freq1, Freq1);

            freq2Label = gui.AddLabel(new Vector2(100, 350), "Freq2: " + freq2.ToString());
            gui.AddSlider(new Vector2(100, 400), 300.0f, 0.0f, 20.0f, freq2, Freq2);

            freq3Label = gui.AddLabel(new Vector2(100, 450), "Freq3: " + freq3.ToString());
            gui.AddSlider(new Vector2(100, 500), 300.0f, 0.0f, 20.0f, freq3, Freq3);

            gui.AddButton(new Vector2(100, 600), "Generate", Generate);
        }