Esempio n. 1
0
        /******** Functions ********/

        /// <summary>
        /// Creates a new base.
        /// </summary>
        /// <param name="rectangle">The rectangle representing the outer boundary of the base.</param>
        public Base(Rectangle rectangle)
        {
            health = 1000;
            layout = new Layout.Layout(Brushes.Transparent);

            // Adding outer part of base.
            outerBase                  = new Layout.Box("outerBase");
            outerBase.area             = rectangle;
            outerBase.fill             = new SolidBrush(Color.FromArgb(255, 50, 50, 50));
            outerBase.borderLine.Width = 3;
            layout.AddBox(outerBase);

            // Adding inner part of base.
            innerBase                  = new Layout.Box("innerBase");
            innerBase.parent           = outerBase;
            innerBase.percentageSize   = new Size(50, 50);
            innerBase.anchor           = Layout.Anchor.Center;
            innerBase.fill             = Brushes.Gray;
            outerBase.borderLine.Width = 3;
            layout.AddBox(innerBase);
        }
Esempio n. 2
0
 /// <summary>
 /// Adds a box to the layout.
 /// </summary>
 /// <param name="box">The box to add.</param>
 public void AddBox(Box box)
 {
     boxes.Add(box);
 }
Esempio n. 3
0
        /******** Functions ********/

        public LevelState(GameStateManager gameStateManager)
        {
            // Randomize using ticks.
            random = new Random((int)DateTime.Now.Ticks);

            this.gameStateManager = gameStateManager;
            firstBlood            = false;
            victory        = false;
            stopwatch      = new Stopwatch();
            entities       = new List <Entity.Entity>();
            map            = new Map.Map(Program.mainForm.ClientSize.Width / 4 * 3, Program.mainForm.ClientSize.Height / 4 * 3);
            map.position.X = Program.mainForm.ClientSize.Width / 2 - map.size.Width;
            map.position.Y = Program.mainForm.ClientSize.Height / 2 - map.size.Height;

            layout = new Layout.Layout();
            layout.backgroundBrush = Brushes.Transparent;

            Layout.Box statusBox = new Layout.Box("statusBox");
            statusBox.percentageWidth    = 10;
            statusBox.percentageHeight   = 20;
            statusBox.percentageLocation = new PointF(89, 12.5f);

            // Redefining textbox standards.
            Textbox.SaveDefaultStyle();
            Textbox.defaultAnchor     = Anchor.Left;
            Textbox.defaultBorderline = Pens.Transparent;
            Textbox.defaultFill       = Brushes.Transparent;

            // Labels.
            Textbox timerLabel        = new Layout.Textbox("timerLabel");
            Textbox shotCounterLabel  = new Layout.Textbox("shotCounterLabel");
            Textbox enemyCounterLabel = new Layout.Textbox("enemyCounterLabel");
            Textbox scoreCounterLabel = new Layout.Textbox("scoreCounterLabel");

            timerLabel.parent             = statusBox;
            shotCounterLabel.parent       = statusBox;
            enemyCounterLabel.parent      = statusBox;
            scoreCounterLabel.parent      = statusBox;
            timerLabel.percentageY        = 5;
            shotCounterLabel.percentageY  = 30;
            enemyCounterLabel.percentageY = 55;
            scoreCounterLabel.percentageY = 80;
            timerLabel.text        = "Time:";
            shotCounterLabel.text  = "Shots:";
            enemyCounterLabel.text = "Hits:";
            scoreCounterLabel.text = "Score:";

            // Infoboxes.
            Textbox.defaultAnchor = Anchor.Right;

            Textbox timer        = new Textbox("timer");
            Textbox shotCounter  = new Textbox("shotCounter");
            Textbox enemyCounter = new Textbox("enemyCounter");
            Textbox scoreCounter = new Textbox("scoreCounter");

            timer.parent             = statusBox;
            shotCounter.parent       = statusBox;
            enemyCounter.parent      = statusBox;
            scoreCounter.parent      = statusBox;
            timer.percentageY        = timerLabel.percentageY;
            shotCounter.percentageY  = shotCounterLabel.percentageY;
            enemyCounter.percentageY = enemyCounterLabel.percentageY;
            scoreCounter.percentageY = scoreCounterLabel.percentageY;

            Textbox.RestoreDefaultStyle();

            // Adding boxes to layout.
            layout.AddBox(statusBox);
            layout.AddBox(timer);
            layout.AddBox(timerLabel);
            layout.AddBox(shotCounter);
            layout.AddBox(shotCounterLabel);
            layout.AddBox(enemyCounter);
            layout.AddBox(enemyCounterLabel);
            layout.AddBox(scoreCounter);
            layout.AddBox(scoreCounterLabel);

            // Already setting up victory dialogue.
#warning You may not set the relative position after setting the anchor or every child box will not show up correctly
            centerBox = new Layout.Box("centerBox");
            centerBox.percentageSize      = new SizeF(25, 15);
            centerBox.anchor              = Layout.Anchor.Center;
            centerBox.borderLine.Width    = 3;
            centerBox.borderLine.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel;
            centerBox.fill = Brushes.LightBlue;

            caption             = new Layout.Textbox("caption");
            caption.parent      = centerBox;
            caption.text        = "Please enter your name:";
            caption.percentageY = 20;
            caption.anchor      = Layout.Anchor.CenterX;

            inputBox                     = new Layout.Inputbox("inputBox");
            inputBox.parent              = centerBox;
            inputBox.percentageY         = 60;
            inputBox.anchor              = Layout.Anchor.CenterX;
            inputBox.text                = "";
            inputBox.maxLength           = 15;
            inputBox.maxSize             = true;
            inputBox.textAnchor          = Layout.Anchor.Center;
            inputBox.OnDelimiterEntered += NameEntered;

            layout.AddBox(centerBox);
            layout.AddBox(caption);
            layout.AddBox(inputBox);
        }