コード例 #1
0
ファイル: HUD.cs プロジェクト: RobinLieson/ar-battle-boats
        public HUD(SpriteFont uiFont,Texture2D health)
        {
            Border = GoblinEnums.BorderFactory.LineBorder;
            Transparency = 0.5f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)
            BackgroundColor = Color.Gray;
            healthPicture = health;
            DrawBackground = true;

            healthImage = new G2DPanel();
            healthImage.Texture = healthPicture;
            healthImage.Bounds = new Rectangle(0, 0, 80, 80);
            healthImage.Transparency = 1.0f;
            healthImage.Border = GoblinEnums.BorderFactory.LineBorder;
            healthImage.DrawBackground = true;
            healthImage.Visible = true;
            healthImage.DrawBorder = true;
            AddChild(healthImage);

            healthLabel = new G2DLabel();
            healthLabel.Bounds = new Rectangle(100, 0, 50, 80);
            healthLabel.TextTransparency = 0.5f;
            healthLabel.TextFont = uiFont;
            healthLabel.VerticalAlignment = GoblinEnums.VerticalAlignment.Center;
            AddChild(healthLabel);

            TextFont = uiFont;
        }
コード例 #2
0
ファイル: HUD.cs プロジェクト: bludman/designAR
        public HUD(Scene scene, Microsoft.Xna.Framework.Content.ContentManager Content)
        {
            this.scene = scene;
            this.Content = Content;

            textFont = Content.Load<SpriteFont>("DebugFont");

            G2DPanel statusBar = new G2DPanel();
            statusBar.Bounds = new Rectangle(-10, 570, 642, 170);
            statusBar.Border = GoblinEnums.BorderFactory.LineBorder;
            statusBar.Transparency = 0.5f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)
            statusBar.BackgroundColor = Color.Black;
            statusBar.DrawBorder = false;
            scene.UIRenderer.Add2DComponent(statusBar);

            G2DPanel topBar = new G2DPanel();
            topBar.Bounds = new Rectangle(-10, -3, 850, 35);
            topBar.Border = GoblinEnums.BorderFactory.LineBorder;
            topBar.Transparency = 0.5f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)
            topBar.BackgroundColor = Color.Black;
            topBar.DrawBorder = false;
            scene.UIRenderer.Add2DComponent(topBar);

            createCorderBackground();
        }
コード例 #3
0
ファイル: G2DPanel.cs プロジェクト: ARLM-Attic/goblin-xna
        /*/// <summary>
         * /// Set the border to be a titled border with a title
         * /// </summary>
         * /// <param name="title"></param>
         * public virtual void SetTitledBorder(String title)
         * {
         *  this.title = title;
         *  this.border = GoblinEnums.BorderFactory.TitledBorder;
         * }*/
        #endregion

        #region Action Methods
        /// <summary>
        /// Adds a child component to this panel.
        /// </summary>
        /// <remarks>
        /// Note that when you add a child component, the child component will automatically inherit the following
        /// properties from this panel: Transparency, TextTransparency, Visible, and Enabled. If you want to have
        /// a different value for these properties, then you should set these property values of the child component
        /// after adding to this panel.
        /// </remarks>
        /// <param name="comp">A 2D component to be added</param>
        public virtual void AddChild(G2DComponent comp)
        {
            if (comp.Parent != null)
            {
                throw new GoblinException("This G2DComponent already has a parent");
            }

            if (comp != null && !children.Contains(comp))
            {
                comp.Parent           = this;
                comp.Transparency     = Transparency;
                comp.TextTransparency = TextTransparency;
                comp.Visible          = Visible;
                comp.Enabled          = Enabled;
                comp.RegisterKeyInput();
                comp.RegisterMouseInput();
                children.Add(comp);

                G2DPanel root = (G2DPanel)comp.RootParent;

                InvokeComponentAddedEvent(this, comp);
            }
        }
コード例 #4
0
        private void CreateObject()
        {
            G2DPanel frame = new G2DPanel();
            frame.Bounds = new Rectangle(0, 0, 800, 600);
            frame.Border = GoblinEnums.BorderFactory.LineBorder;
            frame.Transparency = 1.0f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)
            frame.BackgroundColor = Color.Black;

            SpriteFont textBoxFont = Content.Load<SpriteFont>("TextBoxFont");
            SpriteFont textFont = Content.Load<SpriteFont>("TextFont");

            G2DLabel label = new G2DLabel();
            label.TextFont = textFont;
            label.TextColor = Color.Yellow;
            label.Bounds = new Rectangle(10, 100, 780, 200);
            label.Text = "Type Target ID and Press Enter";

            textF = new G2DTextField();
            textF.TextFont = textBoxFont;
            textF.TextColor = Color.Black;
            textF.Bounds = new Rectangle(10, 200, 780, 200);
            textF.Editable = false;
            textF.Text = "";

            frame.AddChild(label);
            frame.AddChild(textF);
            scene.UIRenderer.Add2DComponent(frame);
        }
コード例 #5
0
ファイル: Main.cs プロジェクト: RobinLieson/ar-battle-boats
        /// <summary>
        /// Creates the Menus
        /// </summary>
        private void CreateMainMenu()
        {
            if (!menuMusic.IsPlaying)
            {
                menuMusic = soundBank.GetCue("Plunder");
                menuMusic.Play();
            }

            // Create the main panel which holds all other GUI components
            frame = new G2DPanel();
            frame.Bounds = new Rectangle(337, 175, 350, 210);
            frame.Border = GoblinEnums.BorderFactory.LineBorder;
            frame.Transparency = 0.7f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            frame2 = new G2DPanel();
            frame2.Bounds = new Rectangle(262, 150, 500, 300);
            frame2.Border = GoblinEnums.BorderFactory.LineBorder;
            frame2.Transparency = 0.7f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            //Frame after winning
            winners = new G2DPanel();
            winners.Bounds = new Rectangle(175, 400, 350, 210);
            winners.Border = GoblinEnums.BorderFactory.LineBorder;
            winners.Transparency = 0f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            howto = new G2DPanel();
            howto.Bounds = new Rectangle(250, 175, 650, 400);
            howto.Texture = Content.Load<Texture2D>(tutorial1);
            howto.Border = GoblinEnums.BorderFactory.LineBorder;
            howto.Transparency = 1f;

            G2DButton localPlay = new G2DButton("Local Play");
            localPlay.Bounds = new Rectangle(120, 30, 100, 30);
            localPlay.Name = "localPlay";
            localPlay.TextFont = textFont;
            localPlay.Texture = Content.Load<Texture2D>("Images\\three");
            localPlay.HighlightColor = Color.Red;
            localPlay.ActionPerformedEvent += new ActionPerformed(HandleLocalPlay);

            G2DButton networkPlay = new G2DButton("Network Play");
            networkPlay.Bounds = new Rectangle(120, 70, 100, 30);
            networkPlay.Name = "networkPlay";
            networkPlay.TextFont = textFont;
            networkPlay.Texture = Content.Load<Texture2D>("Images\\three");
            networkPlay.HighlightColor = Color.Red;
            networkPlay.ActionPerformedEvent += new ActionPerformed(HandleNetworkPlay);

            G2DButton store = new G2DButton("Store");
            store.Bounds = new Rectangle(120, 110, 100, 30);
            store.Name = "store";
            store.TextFont = textFont;
            store.Texture = Content.Load<Texture2D>("Images\\three");
            store.HighlightColor = Color.Red;
            store.ActionPerformedEvent += new ActionPerformed(HandleStore);

            G2DButton howToPlay = new G2DButton("How To Play");
            howToPlay.Bounds = new Rectangle(120, 150, 100, 30);
            howToPlay.Name = "howToPlay";
            howToPlay.TextFont = textFont;
            howToPlay.Texture = Content.Load<Texture2D>("Images\\three");
            howToPlay.HighlightColor = Color.Red;
            howToPlay.ActionPerformedEvent += new ActionPerformed(howToPlay_ActionPerformedEvent);
            /////////////////////////////////////////////////////////////////////////////////

            G2DButton startGame = new G2DButton("Start Game");
            startGame.Bounds = new Rectangle(120, 30, 100, 30);
            startGame.Name = "startGame";
            startGame.TextFont = textFont;
            startGame.Texture = Content.Load<Texture2D>("Images\\three");
            startGame.HighlightColor = Color.Red;
            startGame.ActionPerformedEvent += new ActionPerformed(HandleStartGame);

            G2DButton hostGame = new G2DButton("Host Game");
            hostGame.Bounds = new Rectangle(120, 30, 100, 30);
            hostGame.Name = "hostGame";
            hostGame.TextFont = textFont;
            hostGame.Texture = Content.Load<Texture2D>("Images\\three");
            hostGame.HighlightColor = Color.Red;
            hostGame.ActionPerformedEvent += new ActionPerformed(HandleHostGame);

            G2DButton joinGame = new G2DButton("Join Game");
            joinGame.Bounds = new Rectangle(120, 70, 100, 30);
            joinGame.Name = "joinGame";
            joinGame.TextFont = textFont;
            joinGame.Texture = Content.Load<Texture2D>("Images\\three");
            joinGame.HighlightColor = Color.Red;
            joinGame.ActionPerformedEvent += new ActionPerformed(HandleJoinGame);

            G2DButton buyUpgrades = new G2DButton("Buy Upgrades");
            buyUpgrades.Bounds = new Rectangle(120, 30, 100, 30);
            buyUpgrades.Name = "buyUpgrades";
            buyUpgrades.TextFont = textFont;
            buyUpgrades.Texture = Content.Load<Texture2D>("Images\\three");
            buyUpgrades.HighlightColor = Color.Red;
            buyUpgrades.ActionPerformedEvent += new ActionPerformed(HandleBuyUpgrades);

            G2DButton back = new G2DButton("Back");
            back.Bounds = new Rectangle(120, 150, 100, 30);
            back.Name = "back";
            back.TextFont = textFont;
            back.Texture = Content.Load<Texture2D>("Images\\three");
            back.HighlightColor = Color.Red;
            back.ActionPerformedEvent += new ActionPerformed(HandleBack);

            G2DButton back2 = new G2DButton("Back");
            back2.Bounds = new Rectangle(110, 160, 100, 30);
            back2.Name = "back2";
            back2.TextFont = textFont;
            back2.Texture = Content.Load<Texture2D>("Images\\three");
            back2.HighlightColor = Color.Red;
            back2.ActionPerformedEvent += new ActionPerformed(HandleBack);

            G2DButton save = new G2DButton("Save");
            save.Bounds = new Rectangle(230, 160, 100, 30);
            save.Name = "save";
            save.TextFont = textFont;
            save.Texture = Content.Load<Texture2D>("Images\\three");
            save.HighlightColor = Color.Red;
            save.ActionPerformedEvent += new ActionPerformed(HandleSave);

            G2DButton quit = new G2DButton("Quit");
            quit.Bounds = new Rectangle(120, 190, 100, 30);
            quit.Name = "quit";
            quit.TextFont = textFont;
            quit.Texture = Content.Load<Texture2D>("Images\\three");
            quit.HighlightColor = Color.Red;
            quit.ActionPerformedEvent += new ActionPerformed(HandleQuit);

            ////////////////////////////*****Store****//////////////////////////////////

            G2DButton upgradeSpeed = new G2DButton("Upgrade Speed");
            upgradeSpeed.Bounds = new Rectangle(20, 30, 130, 30);
            upgradeSpeed.Name = "upgradeSpeed";
            upgradeSpeed.TextFont = textFont;
            upgradeSpeed.Texture = Content.Load<Texture2D>("Images\\three");
            upgradeSpeed.HighlightColor = Color.Red;
            upgradeSpeed.ActionPerformedEvent += new ActionPerformed(upgradeSpeed_ActionPerformedEvent);

            G2DButton upgradeArmour = new G2DButton("Upgrade Armour");
            upgradeArmour.Bounds = new Rectangle(20, 70, 130, 30);
            upgradeArmour.Name = "upgradeArmour";
            upgradeArmour.TextFont = textFont;
            upgradeArmour.Texture = Content.Load<Texture2D>("Images\\three");
            upgradeArmour.HighlightColor = Color.Red;
            upgradeArmour.ActionPerformedEvent += new ActionPerformed(upgradeArmour_ActionPerformedEvent);

            G2DButton upgradeMissle = new G2DButton("Upgrade Missle");
            upgradeMissle.Bounds = new Rectangle(20, 110, 130, 30);
            upgradeMissle.Name = "upgradeMissle";
            upgradeMissle.TextFont = textFont;
            upgradeMissle.Texture = Content.Load<Texture2D>("Images\\three");
            upgradeMissle.HighlightColor = Color.Red;
            upgradeMissle.ActionPerformedEvent += new ActionPerformed(upgradeMissle_ActionPerformedEvent);

            howtonext = new G2DButton("Next");
            howtonext.Bounds = new Rectangle(225, 350, 130, 30);
            howtonext.Name = "howtonext";
            howtonext.TextFont = textFont;
            howtonext.Texture = Content.Load<Texture2D>("Images\\three");
            howtonext.HighlightColor = Color.Red;
            //change
            howtonext.ActionPerformedEvent += new ActionPerformed(howtonext_ActionPerformedEvent);

            howtomenu = new G2DButton("Main Menu");
            howtomenu.Bounds = new Rectangle(450, 350, 130, 30);
            howtomenu.Name = "howtonext";
            howtomenu.TextFont = textFont;
            howtomenu.Texture = Content.Load<Texture2D>("Images\\three");
            howtomenu.HighlightColor = Color.Red;
            //change
            howtomenu.ActionPerformedEvent += new ActionPerformed(howtomenu_ActionPerformedEvent);

            howtoback = new G2DButton("Back");
            howtoback.Bounds = new Rectangle(25, 350, 130, 30);
            howtoback.Name = "howtoback";
            howtoback.TextFont = textFont;
            howtoback.Texture = Content.Load<Texture2D>("Images\\three");
            howtoback.HighlightColor = Color.Red;
            howtoback.ActionPerformedEvent += new ActionPerformed(howtoback_ActionPerformedEvent);

            missleLevel = new G2DLabel();
            missleLevel.Bounds = new Rectangle(170, 115, 130, 30);
            missleLevel.Name = "missleLevel";
            missleLevel.TextFont = textFont;

            armourLevel = new G2DLabel();
            armourLevel.Bounds = new Rectangle(170, 75, 130, 30);
            armourLevel.Name = "armourLevel";
            armourLevel.TextFont = textFont;

            speedLevel = new G2DLabel();
            speedLevel.Bounds = new Rectangle(170, 35, 130, 30);
            speedLevel.Name = "speedLevel";
            speedLevel.TextFont = textFont;

            missleCost = new G2DLabel();
            missleCost.Bounds = new Rectangle(270, 115, 130, 30);
            missleCost.Name = "missleCost";
            missleCost.TextFont = textFont;

            armourCost = new G2DLabel();
            armourCost.Bounds = new Rectangle(270, 75, 130, 30);
            armourCost.Name = "armourCost";
            armourCost.TextFont = textFont;

            speedCost = new G2DLabel();
            speedCost.Bounds = new Rectangle(270, 35, 130, 30);
            speedCost.Name = "speedCost";
            speedCost.TextFont = textFont;

            moneyLevel = new G2DLabel();
            moneyLevel.Bounds = new Rectangle(370, 35, 130, 30);
            moneyLevel.Name = "moneyLevel";
            moneyLevel.TextFont = textFont;
            moneyLevel.TextColor = Color.ForestGreen;

            //////////////////////////////////////////////////////////////////////////////

            scene.UIRenderer.Add2DComponent(frame);
            scene.UIRenderer.Add2DComponent(frame2);
            scene.UIRenderer.Add2DComponent(winners);// added this
            scene.UIRenderer.Add2DComponent(howto);

            frame.AddChild(localPlay);
            frame.AddChild(networkPlay);
            frame.AddChild(store);
            frame.AddChild(startGame);
            frame.AddChild(joinGame);
            frame.AddChild(hostGame);
            frame.AddChild(buyUpgrades);
            frame.AddChild(back);
            frame.AddChild(howToPlay);

            frame2.AddChild(upgradeSpeed);
            frame2.AddChild(upgradeArmour);
            frame2.AddChild(upgradeMissle);
            frame2.AddChild(back2);
            frame2.AddChild(save);

            frame2.AddChild(speedLevel);
            frame2.AddChild(armourLevel);
            frame2.AddChild(missleLevel);

            frame2.AddChild(moneyLevel);

            frame2.AddChild(missleCost);
            frame2.AddChild(speedCost);
            frame2.AddChild(armourCost);
            howto.AddChild(howtonext);
            howto.AddChild(howtoback);
            howto.AddChild(howtomenu);

            localPlay.Enabled = true;
            networkPlay.Enabled = true;
            store.Enabled = true;
            startGame.Enabled = false;
            joinGame.Enabled = false;
            hostGame.Enabled = false;
            buyUpgrades.Enabled = false;
            back.Enabled = false;
            upgradeSpeed.Enabled = false;
            upgradeArmour.Enabled = false;
            upgradeMissle.Enabled = false;
            howToPlay.Enabled = true;

            frame2.Enabled = false;
            frame2.Visible = false;

            startGame.Visible = false;
            joinGame.Visible = false;
            hostGame.Visible = false;
            buyUpgrades.Visible = false;
            back.Visible = false;
            upgradeSpeed.Visible = false;
            upgradeArmour.Visible = false;
            upgradeMissle.Visible = false;
            howToPlay.Visible = true;
            howto.Visible = false;
            howto.Enabled = false;
            howtonext.Visible = false;
            howtonext.Enabled = false;
            howtoback.Visible = false;
            howtoback.Enabled = false;
            howtomenu.Visible = false;
            howtomenu.Enabled = false;
        }
 private void CreateControlPanel()
 {
     objectFrame = new G2DPanel();
     objectFrame.Bounds = new Rectangle(670, State.Height - 200, 120, 190);
     objectFrame.Border = GoblinEnums.BorderFactory.LineBorder;
     objectFrame.BorderColor = Color.Gold;
     // Ranges from 0 (fully transparent) to 1 (fully opaque)
     objectFrame.Transparency = 0.5f;
     //Label for rotation
     G2DLabel label1 = new G2DLabel("Object Rotates along:");
     label1.TextFont = textFont;
     label1.Bounds = new Rectangle(5, 5, 80, 20);
     // Create radio button for x-axis rotation.
     G2DRadioButton radioX = new G2DRadioButton("x-axis");
     radioX.TextFont = textFont;
     radioX.Bounds = new Rectangle(5, 15, 80, 20);
     radioX.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedAxisX);
     // Create radio button for y-axis rotation.
     G2DRadioButton radioY = new G2DRadioButton("y-axis");
     radioY.TextFont = textFont;
     radioY.Bounds = new Rectangle(5, 30, 80, 20);
     radioY.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedAxisY);
     // Create radio button for z-axis rotation.
     G2DRadioButton radioZ = new G2DRadioButton("z-axis");
     radioZ.TextFont = textFont;
     radioZ.Bounds = new Rectangle(5, 45, 80, 20);
     radioZ.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedAxisZ);
     //Create a ButtonGroup object which controls the radio button selections
     group1 = new ButtonGroup();
     group1.Add(radioX);
     group1.Add(radioY);
     group1.Add(radioZ);
     //Label for rotation direction.
     G2DLabel label2 = new G2DLabel("Rotation Direction:");
     label2.TextFont = textFont;
     label2.Bounds = new Rectangle(5, 65, 80, 20);
     // Create radio button for clockwise
     G2DRadioButton clockwise = new G2DRadioButton("Clockwise");
     clockwise.TextFont = textFont;
     clockwise.Bounds = new Rectangle(5, 80, 80, 20);
     clockwise.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedDirection);
     // Create radio button for counterclockwise.
     G2DRadioButton counterclockwise = new G2DRadioButton("Counterclockwise");
     counterclockwise.TextFont = textFont;
     counterclockwise.Bounds = new Rectangle(5, 95, 80, 20);
     counterclockwise.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedDirection);
     //Create a ButtonGroup object which controls the radio button selections.
     group2 = new ButtonGroup();
     group2.Add(clockwise);
     group2.Add(counterclockwise);
     //Label for speed
     G2DLabel label3 = new G2DLabel("Rotation Speed:");
     label3.TextFont = textFont;
     label3.Bounds = new Rectangle(5, 115, 80, 20);
     //Slider for speed of rotation
     slider = new G2DSlider();
     slider.TextFont = textFont;
     slider.Bounds = new Rectangle(5, 145, 110, 20);
     slider.Maximum = 8;
     slider.Minimum = 0;
     slider.MajorTickSpacing = 0;
     slider.MinorTickSpacing = 1;
     slider.Value = 0;
     slider.PaintTicks = true;
     slider.PaintLabels = true;
     slider.StateChangedEvent += new StateChanged(HandleStateChangedSpeed);
     G2DButton reset = new G2DButton("Reset");
     reset.Bounds = new Rectangle(5, 165, 55, 20);
     reset.TextFont = textFont;
     reset.ActionPerformedEvent += new ActionPerformed(HandleActionReset);
     G2DButton rotate = new G2DButton("Rotate");
     rotate.Bounds = new Rectangle(65, 165, 50, 20);
     rotate.ActionPerformedEvent += new ActionPerformed(HandleActionRotate);
     rotate.TextFont = textFont;
     objectFrame.AddChild(label1);
     objectFrame.AddChild(radioX);
     objectFrame.AddChild(radioY);
     objectFrame.AddChild(radioZ);
     objectFrame.AddChild(label2);
     objectFrame.AddChild(clockwise);
     objectFrame.AddChild(counterclockwise);
     objectFrame.AddChild(label3);
     objectFrame.AddChild(slider);
     objectFrame.AddChild(reset);
     objectFrame.AddChild(rotate);
     scene.UIRenderer.Add2DComponent(objectFrame);
 }
コード例 #7
0
ファイル: Tutorial8.cs プロジェクト: cjoelrun/Battle-Royal
        private void Create2DGUI()
        {
            p1Frame = new G2DPanel();
            p1Frame.Bounds = new Rectangle(0, 0, 150, 80);
            p1Frame.Border = GoblinEnums.BorderFactory.LineBorder;
            p1Frame.Transparency = 1.0f;
            p1Frame.BackgroundColor = Color.CornflowerBlue;

            //Generic Label: P1
            G2DLabel p1Label = new G2DLabel("P1: ");
            p1Label.Bounds = new Rectangle(10, 10, 10, 10);
            p1Label.TextFont = uiFont;

            //Life Point Label: P1
            p1LifeLab = new G2DLabel();
            p1LifeLab.Bounds = new Rectangle(25, 10, 20, 40);
            p1LifeLab.Text = p1life.ToString() + " LP";
            p1LifeLab.TextFont = uiFont;

            //Generic Label: P1M1
            G2DLabel p1m1StatLab = new G2DLabel("M1: ");
            p1m1StatLab.Bounds = new Rectangle(10, 25, 10, 10);
            p1m1StatLab.TextFont = uiFont;

            //Status Label: P1M1
            p1m1LifeLab = new G2DLabel();
            p1m1LifeLab.Bounds = new Rectangle(25, 25, 20, 40);
            p1m1LifeLab.TextFont = uiFont;

            //Generic Label: P1M2
            G2DLabel p1m2StatLab = new G2DLabel("M2: ");
            p1m2StatLab.Bounds = new Rectangle(10, 40, 10, 10);
            p1m2StatLab.TextFont = uiFont;

            //Status Label: P1M2
            p1m2LifeLab = new G2DLabel();
            p1m2LifeLab.Bounds = new Rectangle(25, 40, 20, 40);
            p1m2LifeLab.TextFont = uiFont;

            //Generic Label: P1M3
            G2DLabel p1m3StatLab = new G2DLabel("M3: ");
            p1m3StatLab.Bounds = new Rectangle(10, 55, 10, 10);
            p1m3StatLab.TextFont = uiFont;

            //Status Label: P1M3
            p1m3LifeLab = new G2DLabel();
            p1m3LifeLab.Bounds = new Rectangle(25, 55, 20, 40);
            p1m3LifeLab.TextFont = uiFont;

            p1Frame.AddChild(p1Label);
            p1Frame.AddChild(p1LifeLab);
            p1Frame.AddChild(p1m1StatLab);
            p1Frame.AddChild(p1m1LifeLab);
            p1Frame.AddChild(p1m2StatLab);
            p1Frame.AddChild(p1m2LifeLab);
            p1Frame.AddChild(p1m3StatLab);
            p1Frame.AddChild(p1m3LifeLab);
            scene.UIRenderer.Add2DComponent(p1Frame);

            p2Frame = new G2DPanel();
            p2Frame.Bounds = new Rectangle(650, 0, 150, 80);
            p2Frame.Border = GoblinEnums.BorderFactory.LineBorder;
            p2Frame.Transparency = 1.0f;
            p2Frame.BackgroundColor = Color.CornflowerBlue;

            //Generic Label: P2
            G2DLabel p2Label = new G2DLabel("P2: ");
            p2Label.Bounds = new Rectangle(15, 10, 10, 10);
            p2Label.TextFont = uiFont;

            //Life Point Label: P2
            p2LifeLab = new G2DLabel();
            p2LifeLab.Bounds = new Rectangle(35, 10, 40, 40);
            p2LifeLab.Text = p2life.ToString() + " LP";
            p2LifeLab.TextFont = uiFont;

            //Generic Label: P2M1
            G2DLabel p2m1StatLab = new G2DLabel("M1: ");
            p2m1StatLab.Bounds = new Rectangle(15, 25, 10, 10);
            p2m1StatLab.TextFont = uiFont;

            //Status Label: P2M1
            p2m1LifeLab = new G2DLabel();
            p2m1LifeLab.Bounds = new Rectangle(35, 25, 20, 40);
            p2m1LifeLab.TextFont = uiFont;

            //Generic Label: P2M2
            G2DLabel p2m2StatLab = new G2DLabel("M2: ");
            p2m2StatLab.Bounds = new Rectangle(15, 40, 10, 10);
            p2m2StatLab.TextFont = uiFont;

            //Status Label: P2M2
            p2m2LifeLab = new G2DLabel();
            p2m2LifeLab.Bounds = new Rectangle(35, 40, 20, 40);
            p2m2LifeLab.TextFont = uiFont;

            //Generic Label: P2M3
            G2DLabel p2m3StatLab = new G2DLabel("M3: ");
            p2m3StatLab.Bounds = new Rectangle(15, 55, 10, 10);
            p2m3StatLab.TextFont = uiFont;

            //Status Label: P2M3
            p2m3LifeLab = new G2DLabel();
            p2m3LifeLab.Bounds = new Rectangle(35, 55, 20, 40);
            p2m3LifeLab.TextFont = uiFont;

            p2Frame.AddChild(p2Label);
            p2Frame.AddChild(p2LifeLab);
            p2Frame.AddChild(p2m1StatLab);
            p2Frame.AddChild(p2m1LifeLab);
            p2Frame.AddChild(p2m2StatLab);
            p2Frame.AddChild(p2m2LifeLab);
            p2Frame.AddChild(p2m3StatLab);
            p2Frame.AddChild(p2m3LifeLab);
            scene.UIRenderer.Add2DComponent(p2Frame);
        }
コード例 #8
0
        private void CreateControlPanel()
        {
            objectFrame = new G2DPanel();
            objectFrame.Bounds = new Rectangle(700, State.Height - 160, 90, 150);
            objectFrame.Border = GoblinEnums.BorderFactory.LineBorder;
            objectFrame.BorderColor = Color.Gold;
            // Ranges from 0 (fully transparent) to 1 (fully opaque)
            objectFrame.Transparency = 0.5f;

            G2DButton visualizeFile = new G2DButton("Visulize");
            visualizeFile.TextFont = textFont;
            visualizeFile.Bounds = new Rectangle(5, 5, 70, 20);
            visualizeFile.ActionPerformedEvent += new ActionPerformed(HandleVisualizeActionsPerformed);
            objectFrame.AddChild(visualizeFile);

            G2DRadioButton radioDownTown = new G2DRadioButton("Downtown");
            radioDownTown.TextFont = textFont;
            radioDownTown.Bounds = new Rectangle(5, 25, 70, 20);
            radioDownTown.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedSection);
            G2DRadioButton radioMidtownEast = new G2DRadioButton("MidtownEast");
            radioMidtownEast.TextFont = textFont;
            radioMidtownEast.Bounds = new Rectangle(5, 40, 70, 20);
            radioMidtownEast.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedSection);
            G2DRadioButton radioMidtownWest = new G2DRadioButton("MidtownWest");
            radioMidtownWest.TextFont = textFont;
            radioMidtownWest.Bounds = new Rectangle(5, 55, 70, 20);
            radioMidtownWest.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedSection);
            G2DRadioButton radioUptown = new G2DRadioButton("Uptown");
            radioUptown.TextFont = textFont;
            radioUptown.Bounds = new Rectangle(5, 70, 70, 20);
            radioUptown.ActionPerformedEvent += new ActionPerformed(HandleActionPerformedSection);
            group1 = new ButtonGroup();
            group1.Add(radioDownTown);
            group1.Add(radioMidtownEast);
            group1.Add(radioMidtownWest);
            group1.Add(radioUptown);
            objectFrame.AddChild(radioDownTown);
            objectFrame.AddChild(radioMidtownEast);
            objectFrame.AddChild(radioMidtownWest);
            objectFrame.AddChild(radioUptown);

            G2DButton focusButton = new G2DButton("Camera Focus");
            focusButton.TextFont = textFont;
            focusButton.Bounds = new Rectangle(5, 95, 80, 20);
            focusButton.ActionPerformedEvent += new ActionPerformed(HandleCameraActionsPerformed);
            objectFrame.AddChild(focusButton);

            G2DButton resetButton = new G2DButton("Reset");
            resetButton.TextFont = textFont;
            resetButton.Bounds = new Rectangle(5, 120, 80, 20);
            resetButton.ActionPerformedEvent += new ActionPerformed(HandleResetActionsPerformed);
            objectFrame.AddChild(resetButton);

            scene.UIRenderer.Add2DComponent(objectFrame);
        }
コード例 #9
0
ファイル: Tutorial3.cs プロジェクト: NinjaSteph/SureShot
        private void Create2DGUI()
        {
            // Create the main panel which holds all other GUI components
            G2DPanel frame = new G2DPanel();
            frame.Bounds = new Rectangle(325, State.Height - 180, 150, 170);
            frame.Border = GoblinEnums.BorderFactory.LineBorder;
            frame.Transparency = 0.7f;  // Ranges from 0 (fully transparent) to 1 (fully opaque)

            label = "User Interfaces";

            // Loads the fonts used for rendering UI labels and slider labels
            uiFont = Content.Load<SpriteFont>("UIFont");
            sliderFont = Content.Load<SpriteFont>("SliderFont");

            // Create four Radio Buttons
            G2DRadioButton radio1 = new G2DRadioButton("User Interfaces");
            radio1.TextFont = uiFont;
            radio1.Bounds = new Rectangle(10, 5, 80, 20);
            radio1.DoClick(); // make this radio button selected initially
            radio1.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            G2DRadioButton radio2 = new G2DRadioButton("Computer Graphics");
            radio2.TextFont = uiFont;
            radio2.Bounds = new Rectangle(10, 25, 80, 20);
            radio2.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            G2DRadioButton radio3 = new G2DRadioButton("Augmented Reality");
            radio3.TextFont = uiFont;
            radio3.Bounds = new Rectangle(10, 45, 80, 20);
            radio3.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            sliderRadio = new G2DRadioButton("Slider Control");
            sliderRadio.TextFont = uiFont;
            sliderRadio.Bounds = new Rectangle(10, 65, 80, 20);
            sliderRadio.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            // Create a slider
            G2DSlider slider = new G2DSlider();
            slider.TextFont = sliderFont;
            slider.Bounds = new Rectangle(5, 100, 140, 30);
            slider.Maximum = 40;
            slider.MajorTickSpacing = 20;
            slider.MinorTickSpacing = 5;
            slider.PaintTicks = true;
            slider.PaintLabels = true;
            slider.StateChangedEvent += new StateChanged(HandleStateChanged);

            // Create a ButtonGroup object which controls the radio 
            // button selections
            ButtonGroup group = new ButtonGroup();
            group.Add(radio1);
            group.Add(radio2);
            group.Add(radio3);
            group.Add(sliderRadio);

            // Create a Button
            G2DButton button = new G2DButton("I Love");
            button.TextFont = uiFont;
            button.Bounds = new Rectangle(50, 145, 50, 20);
            button.ActionPerformedEvent += new ActionPerformed(HandleActionPerformed);

            // Add all of the components to the main panel
            frame.AddChild(radio1);
            frame.AddChild(radio2);
            frame.AddChild(radio3);
            frame.AddChild(sliderRadio);
            frame.AddChild(button);
            frame.AddChild(slider);

            scene.UIRenderer.Add2DComponent(frame);
        }
コード例 #10
0
 private void CreateSolar2DGUI()
 {
     // Create the main panel which holds all other GUI components
     G2DPanel frame = new G2DPanel();
     frame.Bounds = new Rectangle(10, State.Height - 170, 90, 160);
     frame.Border = GoblinEnums.BorderFactory.LineBorder;
     frame.BorderColor = Color.Gold;
     // Ranges from 0 (fully transparent) to 1 (fully opaque)
     frame.Transparency = 0.2f;
     //Label for the panel.
     G2DLabel label1 = new G2DLabel("Camera Control");
     label1.TextFont = textFont2;
     label1.Bounds = new Rectangle(5, 2, 80, 15);
     //Label for the first slider.
     G2DLabel label2 = new G2DLabel("-4    x-axis    4");
     label2.TextFont = textFont1;
     label2.Bounds = new Rectangle(5, 15, 80, 15);
     // Create a slider (moving camera along x axis).
     G2DSlider slider1 = new G2DSlider();
     slider1.TextFont = textFont1;
     slider1.Bounds = new Rectangle(5, 40, 80, 15);
     slider1.Maximum = 4;
     slider1.Minimum = -4;
     slider1.MajorTickSpacing = 0;
     slider1.MinorTickSpacing = 1;
     slider1.Value = 0;
     slider1.PaintTicks = true;
     slider1.PaintLabels = true;
     slider1.StateChangedEvent += new StateChanged(HandleStateChanged1);
     //Label for the second slider
     G2DLabel label3 = new G2DLabel("-4    y-axis    4");
     label3.TextFont = textFont1;
     label3.Bounds = new Rectangle(5, 65, 80, 15);
     // Create a slider (moving camera along y axis).
     G2DSlider slider2 = new G2DSlider();
     slider2.TextFont = textFont1;
     slider2.Bounds = new Rectangle(5, 90, 80, 15);
     slider2.Maximum = 4;
     slider2.Minimum = -4;
     slider2.MajorTickSpacing = 0;
     slider2.MinorTickSpacing = 1;
     slider2.Value = 0;
     slider2.PaintTicks = true;
     slider2.PaintLabels = true;
     slider2.StateChangedEvent += new StateChanged(HandleStateChanged2);
     //Label for the third slider.
     G2DLabel label4 = new G2DLabel("-4    z-axis    4");
     label4.TextFont = textFont1;
     label4.Bounds = new Rectangle(5, 115, 80, 15);
     // Create a slider (moving camera along z axis).
     G2DSlider slider3 = new G2DSlider();
     slider3.TextFont = textFont1;
     slider3.Bounds = new Rectangle(5, 140, 80, 15);
     slider3.Maximum = 4;
     slider3.Minimum = -4;
     slider3.MajorTickSpacing = 0;
     slider3.MinorTickSpacing = 1;
     slider3.Value = 0;
     slider3.PaintTicks = true;
     slider3.PaintLabels = true;
     slider3.StateChangedEvent += new StateChanged(HandleStateChanged3);
     //Add labels and sliders to the frame
     frame.AddChild(label1);
     frame.AddChild(label2);
     frame.AddChild(label3);
     frame.AddChild(label4);
     frame.AddChild(slider1);
     frame.AddChild(slider2);
     frame.AddChild(slider3);
     //Render the frame and add the frame to the scene.
     scene.UIRenderer.Add2DComponent(frame);
 }