Exemplo n.º 1
0
        /******** Functions ********/

        public RushState(GameStateManager gameStateManager)
            : base(gameStateManager)
        {
            rushMap    = new Map.RushMap(map.size.Width, map.size.Height);
            difficulty = 30;

            // Health bar.
            healthBar                  = new Layout.Bar("healthBar");
            healthBar.maxValue         = rushMap.playerBase.health;
            healthBar.percentFull      = 100;
            healthBar.caption          = "";
            healthBar.status           = "";
            healthBar.fill             = Brushes.Red;
            healthBar.percentageY      = 93;
            healthBar.anchor           = Layout.Anchor.CenterX;
            healthBar.percentageSize   = new SizeF(20, 5);
            healthBar.padding          = 1;
            healthBar.borderLine.Width = 3;

            // Difficulty counter.
            difficultyBox             = new Layout.Textbox("difficultyBox");
            difficultyBox.percentageY = 2;
            difficultyBox.anchor      = Layout.Anchor.CenterX;

            layout.AddBox(difficultyBox);
            layout.AddBox(healthBar);
        }
Exemplo n.º 2
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);
        }