コード例 #1
0
ファイル: DebugMenu.cs プロジェクト: jwmcglynn/TeamQ
        public DebugMenu(Controller ctrl)
            : base(ctrl)
        {
            Controller.IsMouseVisible = true;

            TextWidget title = new TextWidget(this, "font", "Sputnik's Great Adventure");
            title.PositionPercent = new Vector2(0.5f, 0.3f);
            AddChild(title);

            float ypos = 50.0f;

            TextButton button = new TextButton(this, "Main Menu");
            button.PositionPercent = title.PositionPercent;
            button.Position = new Vector2(0.0f, ypos);
            button.CreateButton(new Rectangle(-50, -16, 100, 32));
            button.OnActivate += () => {
                Controller.ChangeEnvironment(new MainMenu(Controller));
            };
            AddChild(button);

            ypos += 50.0f;
            button = new TextButton(this, "Start Gym");
            button.PositionPercent = title.PositionPercent;
            button.Position = new Vector2(0.0f, ypos);
            button.CreateButton(new Rectangle(-50, -16, 100, 32));
            button.OnActivate += () => {
                Controller.ChangeEnvironment(new GymEnvironment(Controller));
            };
            AddChild(button);

            ypos += 50.0f;
            button = new TextButton(this, "Start Level 1");
            button.PositionPercent = title.PositionPercent;
            button.Position = new Vector2(0.0f, ypos);
            button.CreateButton(new Rectangle(-50, -16, 100, 32));
            button.OnActivate += () => {
                Controller.ChangeEnvironment(new Level1Environment(Controller));
            };
            AddChild(button);
            ypos += 50.0f;
            button = new TextButton(this, "Quit");
            button.PositionPercent = title.PositionPercent;
            button.Position = new Vector2(0.0f, ypos);
            button.CreateButton(new Rectangle(-50, -16, 100, 32));
            button.OnActivate += () => {
                Controller.Exit();
            };
            AddChild(button);
        }
コード例 #2
0
ファイル: LevelEndHUD.cs プロジェクト: jwmcglynn/TeamQ
        public LevelEndHUD(GameEnvironment env)
            : base(env.Controller)
        {
            Environment = env;

            Sound.PlayCue("stage_clear");

            /////

            // Background color.
            m_background = new RectangleWidget(this, ScreenSize.X * 0.5f, ScreenSize.Y * 0.5f);
            m_background.PositionPercent = new Vector2(0.5f, 0.5f);
            m_background.Position = new Vector2(0.0f, 20.0f);
            m_background.VertexColor = Color.Black;
            m_background.Alpha = 0.5f;
            m_background.Zindex = 1.0f;
            AddChild(m_background);

            // Title.
            TextWidget winTitle = new TextWidget(this, "font", "You win!");
            winTitle.PositionPercent = new Vector2(0.5f, 0.5f);
            winTitle.Position = new Vector2(0.0f, -50.0f);
            winTitle.Zindex = 0.5f;
            AddChild(winTitle);

            // Score.
            TextWidget score = new TextWidget(this, "font", String.Format("Time: {0:0.00} seconds.", env.LevelTimeSpent));
            score.PositionPercent = new Vector2(0.5f, 0.5f);
            score.Position = new Vector2(0.0f, 0.0f);
            score.Zindex = 0.5f;
            AddChild(score);

            // Press key to exit.
            TextWidget exit = new TextWidget(this, "font", "Press SPACE for Main Menu");
            exit.PositionPercent = new Vector2(0.5f, 0.5f);
            exit.Position = new Vector2(0.0f, 50.0f);
            exit.Zindex = 0.5f;
            AddChild(exit);
        }