Esempio n. 1
0
        private void InitializeUI()
        {
            uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
            Panel panel = new Panel();

            panel.Width  = Director.Instance.GL.Context.GetViewport().Width;
            panel.Height = Director.Instance.GL.Context.GetViewport().Height;

            uiScore      = new Sce.PlayStation.HighLevel.UI.Label();
            uiScore.Text = "Score: ";
            uiScore.HorizontalAlignment = HorizontalAlignment.Right;
            uiScore.VerticalAlignment   = VerticalAlignment.Top;
            uiScore.SetPosition(Director.Instance.GL.Context.GetViewport().Width - uiScore.Width, Director.Instance.GL.Context.GetViewport().Height *.01f);
            uiScore.TextColor = new UIColor(1.0f, 0.0f, 0.0f, 1.0f);
            uiScore.Font      = new UIFont(FontAlias.System, 25, FontStyle.Bold);

            uiTime      = new Sce.PlayStation.HighLevel.UI.Label();
            uiTime.Text = "Time: ";
            uiTime.HorizontalAlignment = HorizontalAlignment.Left;
            uiTime.VerticalAlignment   = VerticalAlignment.Top;
            uiTime.SetPosition(0.0f, Director.Instance.GL.Context.GetViewport().Height *.01f);
            uiTime.TextColor = new UIColor(1.0f, 1.0f, 0.0f, 1.0f);
            uiTime.Font      = new UIFont(FontAlias.System, 25, FontStyle.Bold);

            panel.AddChildLast(uiScore);
            panel.AddChildLast(uiTime);
            uiScene.RootWidget.AddChildLast(panel);
            UISystem.SetScene(uiScene);
        }
        public static void Initialize()
        {
            //Set up director and UISystem.
            Director.Initialize();
            UISystem.Initialize(Director.Instance.GL.Context);

            //Set game scene
            gameScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            gameScene.Camera.SetViewFromViewport();
            gameScene.Name = "gameScene";

            startScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            startScene.Camera.SetViewFromViewport();
            startScene.Name = "startScene";

            endScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            endScene.Camera.SetViewFromViewport();
            endScene.Name = "endScene";

            //Set the ui scene.
            uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
            Panel panel = new Panel();

            panel.Width  = Director.Instance.GL.Context.GetViewport().Width;
            panel.Height = Director.Instance.GL.Context.GetViewport().Height;
            scoreLabel   = new Sce.PlayStation.HighLevel.UI.Label();
            scoreLabel.HorizontalAlignment = HorizontalAlignment.Center;
            scoreLabel.VerticalAlignment   = VerticalAlignment.Top;
            scoreLabel.SetPosition(
                Director.Instance.GL.Context.GetViewport().Width / 2 - scoreLabel.Width / 2,
                Director.Instance.GL.Context.GetViewport().Height *0.1f - scoreLabel.Height / 2);
            scoreLabel.Text = "0";
            panel.AddChildLast(scoreLabel);
            uiScene.RootWidget.AddChildLast(panel);
            UISystem.SetScene(uiScene);

            //Create the background.
            background      = new Background(gameScene, gameScene.Name);
            titleBackground = new Background(startScene, startScene.Name);
            endBackground   = new Background(endScene, endScene.Name);
            //Create the flappy douche
            bird = new Bird(gameScene);


            //Create some obstacles.
            obstacles    = new Obstacle[2];
            obstacles[0] = new Obstacle(Director.Instance.GL.Context.GetViewport().Width *0.5f, gameScene);
            obstacles[1] = new Obstacle(Director.Instance.GL.Context.GetViewport().Width, gameScene);

            score      = 0;
            keyPressed = false;

            //Run the scene.
            Director.Instance.RunWithScene(startScene, true);
        }
Esempio n. 3
0
 public static void SetUISystem(string scene)
 {
     if (scene == "game")
     {
         UISystem.SetScene(uiScene);
     }
     else if (scene == "highscores")
     {
         UISystem.SetScene(highscoresScene);
         highscoresLabel.Text = highscoresManager.GetHighScores();
         highscoresLabel.SetPosition(Director.Instance.GL.Context.GetViewport().Width / 2 - 15.0f,
                                     Director.Instance.GL.Context.GetViewport().Height / 2 + 5.0f);
     }
     else
     {
         UISystem.SetScene(null);
     }
 }
Esempio n. 4
0
        private void initScore()
        {
            uiScore1      = new Sce.PlayStation.HighLevel.UI.Label();
            uiScore1.Text = "1st Score: 0";
            uiScore1.HorizontalAlignment = HorizontalAlignment.Center;
            uiScore1.VerticalAlignment   = VerticalAlignment.Top;
            uiScore1.SetPosition(Director.Instance.GL.Context.GetViewport().Width / 2 - uiScore1.Width / 2, Director.Instance.GL.Context.GetViewport().Height *0.3f);
            uiScore1.TextColor = new UIColor(1.0f, 0.756f, 0.145f, 1.0f);
            uiScore1.Font      = new UIFont(FontAlias.System, 30, FontStyle.Bold);

            uiScore2      = new Sce.PlayStation.HighLevel.UI.Label();
            uiScore2.Text = "2nd Score: 0";;
            uiScore2.HorizontalAlignment = HorizontalAlignment.Center;
            uiScore2.VerticalAlignment   = VerticalAlignment.Top;
            uiScore2.SetPosition(Director.Instance.GL.Context.GetViewport().Width / 2 - uiScore1.Width / 2, Director.Instance.GL.Context.GetViewport().Height *0.4f);
            uiScore2.TextColor = new UIColor(1.0f, 0.756f, 0.145f, 1.0f);
            uiScore2.Font      = new UIFont(FontAlias.System, 25, FontStyle.Bold);

            uiScore3      = new Sce.PlayStation.HighLevel.UI.Label();
            uiScore3.Text = "3rd Score: 0";
            uiScore3.HorizontalAlignment = HorizontalAlignment.Center;
            uiScore3.VerticalAlignment   = VerticalAlignment.Top;
            uiScore3.SetPosition(Director.Instance.GL.Context.GetViewport().Width / 2 - uiScore1.Width / 2, Director.Instance.GL.Context.GetViewport().Height *0.5f);
            uiScore3.TextColor = new UIColor(1.0f, 0.756f, 0.145f, 1.0f);
            uiScore3.Font      = new UIFont(FontAlias.System, 25, FontStyle.Bold);

            uiScore4      = new Sce.PlayStation.HighLevel.UI.Label();
            uiScore4.Text = "4th Score: 0";
            uiScore4.HorizontalAlignment = HorizontalAlignment.Center;
            uiScore4.VerticalAlignment   = VerticalAlignment.Top;
            uiScore4.SetPosition(Director.Instance.GL.Context.GetViewport().Width / 2 - uiScore1.Width / 2, Director.Instance.GL.Context.GetViewport().Height *0.6f);
            uiScore4.TextColor = new UIColor(1.0f, 0.756f, 0.145f, 1.0f);
            uiScore4.Font      = new UIFont(FontAlias.System, 25, FontStyle.Bold);


            uiScore5      = new Sce.PlayStation.HighLevel.UI.Label();
            uiScore5.Text = "5th Score: 0";
            uiScore5.HorizontalAlignment = HorizontalAlignment.Center;
            uiScore5.VerticalAlignment   = VerticalAlignment.Top;
            uiScore5.SetPosition(Director.Instance.GL.Context.GetViewport().Width / 2 - uiScore1.Width / 2, Director.Instance.GL.Context.GetViewport().Height *0.7f);
            uiScore5.TextColor = new UIColor(1.0f, 0.756f, 0.145f, 1.0f);
            uiScore5.Font      = new UIFont(FontAlias.System, 25, FontStyle.Bold);
        }
Esempio n. 5
0
        public TitleScreen(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene, Sce.PlayStation.HighLevel.UI.Scene uiScene) : base(scene)
        {
            scene1 = scene;

            textureInfo     = new TextureInfo("/Application/textures/GravityNinja.png");
            sprite          = new SpriteUV();
            sprite          = new SpriteUV(textureInfo);
            sprite.Quad.S   = textureInfo.TextureSizef;
            sprite.Position = new Vector2(0.0f, 0.0f);

            playTexture         = new TextureInfo("/Application/textures/play.png");
            playSelectTexture   = new TextureInfo("/Application/textures/playSelected.png");
            playSprite          = new SpriteUV();
            playSprite          = new SpriteUV(playSelectTexture);
            playSprite.Quad.S   = playTexture.TextureSizef * 0.7f;
            playSprite.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width *0.78f - (playTexture.TextureSizef.X / 2), 200);

            controlTexture         = new TextureInfo("/Application/textures/cog.png");
            controlSprite          = new SpriteUV();
            controlSprite          = new SpriteUV(controlTexture);
            controlSprite.Quad.S   = controlTexture.TextureSizef * 0.05f;
            controlSprite.Position = new Vector2(10.0f, 10.0f);

            playBox.Min = playSprite.Position;
            playBox.Max = playSprite.Position + playSprite.TextureInfo.TextureSizef;

            controlsBox.Min = controlSprite.Position;
            controlsBox.Max = controlSprite.Position + controlSprite.TextureInfo.TextureSizef * 0.05f;

            label = new Sce.PlayStation.HighLevel.UI.Label();
            label.SetPosition(10, 90);
            label.Text = "Awaiting Input...";

            backButton = new Button();
            backButton.SetPosition(10, 140);
            backButton.SetSize(100, 50);
            backButton.Text          = "Back";
            backButton.ButtonAction += HandleButtonAction;

            inputButton = new Button();
            inputButton.SetPosition(380, 10);
            inputButton.SetSize(100, 50);
            inputButton.Text          = "Enter";
            inputButton.ButtonAction += HandleInputAction;

            command = new EditableText();
            command.SetPosition(10, 10);
            command.Text = "Enter Command";

            dialog = new Dialog();
            dialog.SetSize(500, 200);
            dialog.ShowEffect = new BunjeeJumpEffect(dialog, 0.4f);
            dialog.HideEffect = new TiltDropEffect();
            dialog.AddChildFirst(label);
            dialog.AddChildFirst(command);
            dialog.AddChildFirst(backButton);
            dialog.AddChildFirst(inputButton);

            scene.AddChild(sprite);
            scene.AddChild(playSprite);
            scene.AddChild(controlSprite);

            UISystem.SetScene(uiScene);
        }
Esempio n. 6
0
        public static void Initialize()
        {
            //Set up director and UISystem.
            Director.Initialize();
            UISystem.Initialize(Director.Instance.GL.Context);

            //Set game scene
            gameScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            gameScene.Camera.SetViewFromViewport();

            //Set the ui scene.
            uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
            Panel panel = new Panel();

            panel.Width  = Director.Instance.GL.Context.GetViewport().Width;
            panel.Height = Director.Instance.GL.Context.GetViewport().Height;

            scoreLabel = new Sce.PlayStation.HighLevel.UI.Label();
            scoreLabel.HorizontalAlignment = HorizontalAlignment.Left;
            scoreLabel.VerticalAlignment   = VerticalAlignment.Top;

            scoreLabel.TextShadow                  = new TextShadowSettings();
            scoreLabel.TextShadow.Color            = new UIColor(0.0f, 0.0f, 0.0f, 1.0f);
            scoreLabel.TextShadow.HorizontalOffset = 2.0f;
            scoreLabel.TextShadow.VerticalOffset   = 2.0f;

            scoreLabel.SetPosition(
                Director.Instance.GL.Context.GetViewport().Width / 2 - scoreLabel.Width / 2,
                Director.Instance.GL.Context.GetViewport().Width *0.1f - scoreLabel.Height / 2);

            scoreLabel.Text = "Score: " + score.ToString();

            airLabel = new Sce.PlayStation.HighLevel.UI.Label();
            airLabel.HorizontalAlignment = HorizontalAlignment.Right;
            airLabel.VerticalAlignment   = VerticalAlignment.Top;

            airLabel.TextShadow                  = new TextShadowSettings();
            airLabel.TextShadow.Color            = new UIColor(0.0f, 0.0f, 0.0f, 1.0f);
            airLabel.TextShadow.HorizontalOffset = 2.0f;
            airLabel.TextShadow.VerticalOffset   = 2.0f;

            airLabel.SetPosition(
                Director.Instance.GL.Context.GetViewport().Width / 2 - airLabel.Width / 2,
                Director.Instance.GL.Context.GetViewport().Width *0.1f - airLabel.Height / 2);
            airLabel.Text = "Air: " + air.ToString();

            windowWidth  = Director.Instance.GL.Context.GetViewport().Width;
            windowHeight = Director.Instance.GL.Context.GetViewport().Height;

            panel.AddChildLast(scoreLabel);
            panel.AddChildLast(airLabel);
            uiScene.RootWidget.AddChildLast(panel);
            UISystem.SetScene(uiScene);

            //Create the background.
            background = new Background(gameScene);

            //Create the flappy guy
            bird = new Bird(gameScene);

            //Create some chains.
            chain    = new Chain[OBSTACLE_COUNT];
            chain[0] = new Chain(windowWidth * 0.5f, gameScene);
            chain[1] = new Chain(windowWidth, gameScene);

            //Create seamines and attach to chain
            seamine    = new Mine[OBSTACLE_COUNT];
            seamine[0] = new Mine((X = chain[0].GetX + chain[0].GetMaxX) - 80, Y = chain[0].GetY + chain[0].GetMaxY, gameScene);
            seamine[1] = new Mine((X = chain[1].GetX + chain[1].GetMaxX) - 80, Y = chain[1].GetY + chain[1].GetMaxY, gameScene);

            //Create Bubbles
            bubble = new List <Bubble>();
            bubble.Add(new Bubble(windowWidth / 4, -70.0f, 0.75f, gameScene));
            bubble.Add(new Bubble(windowWidth / 2, -42.0f, 0.25f, gameScene));
            bubble.Add(new Bubble((windowWidth / 4) * 3, -103.0f, 0.5f, gameScene));
            bubble.Add(new Bubble(windowWidth, -129.0f, 0.5f, gameScene));

            //Run the scene.
            Director.Instance.RunWithScene(gameScene, true);
        }
Esempio n. 7
0
        public HighScoreScene(int highscore)
        {
            m_highscore = highscore;

            this.Camera.SetViewFromViewport();
            Sce.PlayStation.HighLevel.UI.Panel dialog = new Panel();
            dialog.Width  = Director.Instance.GL.Context.GetViewport().Width;
            dialog.Height = Director.Instance.GL.Context.GetViewport().Height;

            ImageBox ib = new ImageBox();

            ib.Width  = dialog.Width;
            ib.Image  = new ImageAsset("/Application/images/title.png", false);
            ib.Height = dialog.Height;
            ib.SetPosition(0.0f, 0.0f);

            // editable text box parameters
            editTextBox.Name   = "editText";
            editTextBox.Text   = "You got a new high score, Enter your name (do not enter ',' or spaces)";
            editTextBox.Width  = 400;
            editTextBox.Height = 100;
            editTextBox.SetPosition(dialog.Width / 2.0f - editTextBox.Width / 2.0f, 220.0f);

            // retrieve highscores
            // retrieve highscore from server
            Client m_client = new Client(new string[1] {
                "Highscorers1234567890"
            });

            string[] highScorers     = new string[10];
            string[] sectionsMessage = m_client.responseMessage.Split(' ');
            highScorers = sectionsMessage[sectionsMessage.Length - 1].Split(',');

            string labelText = "Highscores" + Environment.NewLine +
                               highScorers[0] + ": " + highScorers[1] + Environment.NewLine +
                               highScorers[2] + ": " + highScorers[3] + Environment.NewLine +
                               highScorers[4] + ": " + highScorers[5] + Environment.NewLine +
                               highScorers[6] + ": " + highScorers[7] + Environment.NewLine +
                               highScorers[8] + ": " + highScorers[9] + Environment.NewLine;

            lb.Label highscores = new lb.Label();
            highscores.Name   = "highscores";
            highscores.Text   = labelText;
            highscores.Width  = 300;
            highscores.Height = 400;
            highscores.Alpha  = 0.8f;
            highscores.SetPosition(50, 220.0f);

            // when text box changed - fire event ( change player name and replace scene )
            editTextBox.TextChanged += OnTextEdit;

            dialog.AddChildLast(ib);
            dialog.AddChildLast(editTextBox);
            dialog.AddChildLast(highscores);

            m_uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
            m_uiScene.RootWidget.AddChildLast(dialog);
            m_uiScene.RootWidget.AddChildLast(highscores);

            UISystem.SetScene(m_uiScene);
            Scheduler.Instance.ScheduleUpdateForTarget(this, 0, false);
        }
Esempio n. 8
0
        public static void Initialize()
        {
            //Set up director and UISystem.
            Director.Initialize();
            UISystem.Initialize(Director.Instance.GL.Context);

            //Set game scene
            gameScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            gameScene.Camera.SetViewFromViewport();

            //Set the ui scene.
            uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
            Panel panel = new Panel();

            panel.Width  = Director.Instance.GL.Context.GetViewport().Width;
            panel.Height = Director.Instance.GL.Context.GetViewport().Height;
            uiScene.RootWidget.AddChildLast(panel);

            //Set the highscores scene.
            highscoresManager = new HighScoreManager(gameScene);
            highscoresScene   = new Sce.PlayStation.HighLevel.UI.Scene();
            Panel highscoresPanel = new Panel();

            highscoresPanel.Width  = Director.Instance.GL.Context.GetViewport().Width;
            highscoresPanel.Height = Director.Instance.GL.Context.GetViewport().Height;
            highscoresScene.RootWidget.AddChildLast(highscoresPanel);

            // Setup highscores label
            highscoresLabel        = new Sce.PlayStation.HighLevel.UI.Label();
            highscoresLabel.Height = 200.0f;
            highscoresLabel.Text   = "Retrieving Data";
            highscoresPanel.AddChildLast(highscoresLabel);
            highscoresScene.RootWidget.AddChildLast(highscoresPanel);

            // Setup ui scene labels
            scoreLabel = new Sce.PlayStation.HighLevel.UI.Label();
            scoreLabel.SetPosition(10, 8);
            int roundedScore = (int)FMath.Floor(score / 100) * 100;

            scoreLabel.Text = "Score: " + roundedScore.ToString("N0");
            panel.AddChildLast(scoreLabel);

            gameSpeedLabel = new Sce.PlayStation.HighLevel.UI.Label();
            gameSpeedLabel.SetPosition(770, 8);
            float speed = FMath.Round(moveSpeed * 10) / 10;             // round to 1dp

            gameSpeedLabel.Text = "Game Speed: " + moveSpeed.ToString("N1");
            panel.AddChildLast(gameSpeedLabel);

            soundManager = new SoundManager();

            //Create Sprite
            rTextureInfo     = new TextureInfo("/Application/textures/reset.png");
            rSprite          = new SpriteUV();
            rSprite          = new SpriteUV(rTextureInfo);
            rSprite.Quad.S   = rTextureInfo.TextureSizef;
            rSprite.Scale    = new Vector2(1.0f, 1.0f);
            rSprite.Position = new Vector2(0.0f, 0.0f);
            rSprite.CenterSprite();

            //Run the scene.
            Director.Instance.RunWithScene(gameScene, true);
            screenManager = new ScreenManager(gameScene);
        }
Esempio n. 9
0
        public MenuScene()
        {
            this.Camera.SetViewFromViewport();
            Panel dialog = new Panel();

            dialog.Width  = Director.Instance.GL.Context.GetViewport().Width;
            dialog.Height = Director.Instance.GL.Context.GetViewport().Height;

            ImageBox ib = new ImageBox();

            ib.Width  = dialog.Width;
            ib.Image  = new ImageAsset("/Application/images/title.png", false);
            ib.Height = dialog.Height;
            ib.SetPosition(0.0f, 0.0f);

            Button buttonPlay = new Button();

            buttonPlay.Name   = "buttonPlay";
            buttonPlay.Text   = "Play Game";
            buttonPlay.Width  = 300;
            buttonPlay.Height = 50;
            buttonPlay.Alpha  = 0.8f;
            buttonPlay.SetPosition(dialog.Width / 2.0f - buttonPlay.Width / 2.0f, 220.0f);
            buttonPlay.TouchEventReceived += OnButtonPlay;

            Button localMultiplayer = new Button();

            localMultiplayer.Name   = "localMultiplayer";
            localMultiplayer.Text   = "Local Multiplayer";
            localMultiplayer.Width  = 300;
            localMultiplayer.Height = 50;
            localMultiplayer.Alpha  = 0.8f;
            localMultiplayer.SetPosition(dialog.Width / 2.0f - buttonPlay.Width / 2.0f, 300.0f);
            localMultiplayer.TouchEventReceived += OnMultiplayerPlay;

            // retrieve highscores
            // retrieve highscore from server
            Client m_client = new Client(new string[1] {
                "Highscorers1234567890"
            });

            // check if server init
            if (m_client.responseMessage == "ERROR: no entries found")
            {
                m_client = new Client(new string[2] {
                    "Highscorers1234567890", "Sean,10,Bob,5,Fred,4,Will,3,Jim,1"
                });
            }

            string[] highScorers     = new string[10];
            string[] sectionsMessage = m_client.responseMessage.Split(' ');
            highScorers = sectionsMessage[sectionsMessage.Length - 1].Split(',');
            string labelText = "Highscores" + Environment.NewLine +
                               highScorers[0] + ": " + highScorers[1] + Environment.NewLine +
                               highScorers[2] + ": " + highScorers[3] + Environment.NewLine +
                               highScorers[4] + ": " + highScorers[5] + Environment.NewLine +
                               highScorers[6] + ": " + highScorers[7] + Environment.NewLine +
                               highScorers[8] + ": " + highScorers[9] + Environment.NewLine;

            lb.Label highscores = new lb.Label();
            highscores.Name   = "highscores";
            highscores.Text   = labelText;
            highscores.Width  = 300;
            highscores.Height = 400;
            highscores.Alpha  = 0.8f;
            highscores.SetPosition(50, 220.0f);

            dialog.AddChildLast(ib);
            dialog.AddChildLast(buttonPlay);
            dialog.AddChildLast(highscores);
            dialog.AddChildLast(localMultiplayer);
            m_uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
            m_uiScene.RootWidget.AddChildLast(dialog);
            m_uiScene.RootWidget.AddChildLast(highscores);
            m_uiScene.RootWidget.AddChildLast(localMultiplayer);
            UISystem.SetScene(m_uiScene);
            Scheduler.Instance.ScheduleUpdateForTarget(this, 0, false);
        }