コード例 #1
0
ファイル: Settings.cs プロジェクト: JadenAlekis/RogueMechs
        protected override void _load()
        {
            MainFrame.backgroundColor = Color.Black;

            Label lblAdd = new Label(MainFrame, "titleLbl", "Settings", 20, 20, Color.White);
            lblAdd.width = graphics.PreferredBackBufferWidth - 40;
            lblAdd.height = 100;
            lblAdd.fontSize = FontSizes.Medium;
            MainFrame.AddChild(lblAdd);

            Dropdown ddAdd = new Dropdown(MainFrame, "resDD", "Resolution", 0, 200, Color.White);
            ddAdd.width = 200;
            ddAdd.height = 20;
            ddAdd.HorizCenterToParent();

            Button btnAdd = new Button(ddAdd, "res1", "800x600", 0, (ddAdd.height + 1), ddAdd.width, ddAdd.height);
            ddAdd.AddChild(btnAdd);
            btnAdd = new Button(ddAdd, "res2", "1280x720", 0, (ddAdd.height + 1) * 2, ddAdd.width, ddAdd.height);
            ddAdd.AddChild(btnAdd);
            btnAdd = new Button(ddAdd, "res3", "1600x900", 0, (ddAdd.height + 1) * 3, ddAdd.width, ddAdd.height);
            ddAdd.AddChild(btnAdd);

            MainFrame.AddChild(ddAdd);

            btnAdd = new Button(ddAdd, "test", "Test", 100, 500, ddAdd.width, ddAdd.height);
            MainFrame.AddChild(btnAdd);
        }
コード例 #2
0
ファイル: Brawl.cs プロジェクト: JadenAlekis/RogueMechs
        protected override void _load()
        {
            MainFrame.backgroundColor = Color.Black * 0.0f;

            Label lblAdd = new Label(MainFrame, "titleLbl", "Time Limit:", (graphics.PreferredBackBufferWidth / 2) - (graphics.PreferredBackBufferWidth / 8), 20, Color.White);
            lblAdd.width = graphics.PreferredBackBufferWidth/8;
            lblAdd.height = 40;
            lblAdd.fontSize = FontSizes.Medium;
            lblAdd.backgroundColor = Color.White * 0.50f;
            lblAdd.horizAlignment = HorizAlignments.AlignRight;
            MainFrame.AddChild(lblAdd);

            lblAdd = new Label(MainFrame, "timerLbl", "0:00", (graphics.PreferredBackBufferWidth / 2), 20, Color.White);
            lblAdd.width = graphics.PreferredBackBufferWidth / 16;
            lblAdd.height = 40;
            lblAdd.fontSize = FontSizes.Medium;
            lblAdd.backgroundColor = Color.White * 0.50f;
            MainFrame.AddChild(lblAdd);

            //Create the phyics engine for this scene.
            world = new World(Vector2.UnitY * 10);

            level = new TheGrinder(world);
            Level.ActiveLevel = level;

            HAL = new AI(world);
            Player newPlayer = new GenericBrawler(world, 1, level.GetInitialSpawn());
            newPlayer.isAI = true;
            players.Add(newPlayer);

            newPlayer = new GenericBrawler(world, 2, level.GetInitialSpawn());
            newPlayer.isAI = true;
            players.Add(newPlayer);

            newPlayer = new GenericBrawler(world, 3, level.GetInitialSpawn());
            newPlayer.isAI = true;
            players.Add(newPlayer);

            newPlayer = new GenericBrawler(world, 4, level.GetInitialSpawn());
            newPlayer.isAI = true;
            players.Add(newPlayer);

            camera = new Camera2D();
            camera.targetPosition = new Vector2(800, 450);

            //Load UI based on number of players
            for (int i = 0; i < players.Count; i++)
            {
                lblAdd = new Label(MainFrame, "name" + i + "Lbl", players[i].name, i * (graphics.PreferredBackBufferWidth / 4) + 100, graphics.PreferredBackBufferHeight - 50, Color.White);
                lblAdd.width = 200;
                lblAdd.height = 20;
                lblAdd.backgroundColor = players[i].color * 0.75f;
                MainFrame.AddChild(lblAdd);

                lblAdd = new Label(MainFrame, "damage" + i + "Lbl", "0%", i * (graphics.PreferredBackBufferWidth / 4) + 100, graphics.PreferredBackBufferHeight - 100, Color.White);
                lblAdd.width = 100;
                lblAdd.height = 50;
                lblAdd.fontSize = FontSizes.Medium;
                lblAdd.backgroundColor = players[i].color * 0.75f;
                MainFrame.AddChild(lblAdd);

                lblAdd = new Label(MainFrame, "score" + i + "Lbl", "0", i * (graphics.PreferredBackBufferWidth / 4) + 200, graphics.PreferredBackBufferHeight - 100, Color.White);
                lblAdd.width = 150;
                lblAdd.height = 50;
                lblAdd.fontSize = FontSizes.Medium;
                lblAdd.backgroundColor = players[i].color * 0.75f;
                MainFrame.AddChild(lblAdd);
            }

            flag = new AggroFlag(world, level);

            timer = TIME_LIMIT;
            //Sound.PlayBGMusic();
        }
コード例 #3
0
ファイル: Brawl.cs プロジェクト: JadenAlekis/RogueMechs
        protected override void _update(GameTime gameTime)
        {
            #region Update Game Timer
            timer -= gameTime.ElapsedGameTime;
            if (timer < TimeSpan.Zero && !pause)
            {
                pause = true;
                Label lblAdd = new Label(MainFrame, "endLbl", "GAME!", (graphics.PreferredBackBufferWidth / 2) - (graphics.PreferredBackBufferWidth / 4), 20, Color.White);
                lblAdd.width = graphics.PreferredBackBufferWidth / 2;
                lblAdd.height = graphics.PreferredBackBufferHeight / 2;
                lblAdd.fontSize = FontSizes.Large;
                lblAdd.HorizCenterToParent();
                lblAdd.VertCenterToParent();

                float bestScore = 0;
                Player winner = null;

                foreach (var player in players)
                {
                    if(player.Score > bestScore)
                    {
                        bestScore = player.Score;
                        winner = player;
                    }
                }

                lblAdd.text += "\n\n" + winner.name + " Wins!";
                lblAdd.backgroundColor = winner.color * 0.75f;

                MainFrame.AddChild(lblAdd);
            }
            else if (timer < END_SCREEN_TIME && !ended)
            {
                Tinder.End();
                ended = true;
            }
            #endregion

            if (!pause)
            {
                #region Update UI Values
                //Update Damage Values
                for (int i = 0; i < players.Count; i++)
                {
                    UI lbl = MainFrame.Find("damage" + i + "Lbl");
                    if (lbl != null)
                    {
                        lbl.text = Math.Round(players[i].damage) + "%";
                    }
                }

                //Update Score Values
                for (int i = 0; i < players.Count; i++)
                {
                    UI lbl = MainFrame.Find("score" + i + "Lbl");
                    if (lbl != null)
                    {
                        lbl.text = Math.Round(players[i].Score).ToString();
                    }
                }

                {
                    UI lbl = MainFrame.Find("timerLbl");
                    lbl.text = (int)timer.TotalMinutes + ":" + ((int)timer.Seconds < 10 ? "0" : "") + (int)timer.Seconds;
                }
                #endregion

                #region Update UI
                MainFrame.Update(gameTime);
                #endregion

                #region Update Particles
                ParticleEmitter.Update(gameTime);
                #endregion

                #region Update Flag
                flag.Update(gameTime);
                #endregion

                #region Update AI
                foreach (var player in players)
                {
                    if(player.isAI)
                        HAL.ComputeActions(player, flag.GetPosition() * PIXELS_PER_METER);
                }
                #endregion

                #region Update Players
                foreach (var player in players)
                {
                    player.Update(gameTime);
                }
                #endregion

                #region Update Level
                level.Update(gameTime);
                #endregion

                #region Update Camera
                camera.SetAveragePosition(players);
                camera.Update(gameTime);
                #endregion

                #region Update Physics
                world.Step(Math.Min((float)gameTime.ElapsedGameTime.TotalMilliseconds * 0.001f, (1f / 30f)));
                #endregion
            }

            //Reset the scene
            if (Control.Actions.FirstOrDefault(x => x.actionType == ControlType.Reset) != null)
                Scene.QueueScene(new Brawl());
        }