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 void Initialize() { Sce.PlayStation.HighLevel.UI.Panel dialog = new Panel();//create panel dialog.Width = 960;//only for vita dialog.Height = 544; ImageBox ib = new ImageBox(); //set background images ib.Width = dialog.Width; ib.Image = new ImageAsset("/Application/resources/lose.png",false); ib.Height = dialog.Height; ib.SetPosition(0.0f,0.0f); Button buttonUI1 = new Button(); //set buttons positions buttonUI1.Name = "replay"; buttonUI1.Text = "replay"; buttonUI1.Width = 250; buttonUI1.Height = 50; buttonUI1.Alpha = 0.8f; buttonUI1.SetPosition(dialog.Width/15,dialog.Height - 100); buttonUI1.TouchEventReceived += (sender, e) => { Support.SoundSystem.Instance.Play("ButtonClick.wav"); Director.Instance.ReplaceScene(new GameScene()); }; Button buttonUI2 = new Button(); buttonUI2.Name = "home"; buttonUI2.Text = "home"; buttonUI2.Width = 250; buttonUI2.Height = 50; buttonUI2.Alpha = 0.8f; buttonUI2.SetPosition(dialog.Width/2.7f,dialog.Height - 100); buttonUI2.TouchEventReceived += (sender, e) => { Support.SoundSystem.Instance.Play("ButtonClick.wav"); Director.Instance.ReplaceScene(new MenuScene()); }; Sce.PlayStation.HighLevel.UI.Label scoreLabel = new Sce.PlayStation.HighLevel.UI.Label(); labelSetting(scoreLabel, //total score "Total Score: " + GameScene.totalScore, 690, 0, 300, 100, 30, FontStyle.Regular, new UIColor(255, 0, 0, 255)); dialog.AddChildLast(ib); dialog.AddChildLast(buttonUI1); dialog.AddChildLast(buttonUI2); dialog.AddChildLast(scoreLabel); _uiScene = new Sce.PlayStation.HighLevel.UI.Scene(); _uiScene.RootWidget.AddChildLast(dialog); UISystem.SetScene(_uiScene); // create menu scene }
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); }
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); }
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); }
public LoadingScreen(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene, Sce.PlayStation.HighLevel.UI.Scene uiScene) : base(scene) { // loadingTexture0 = new TextureInfo("/Application/textures/LoadingScreens/Level0Load.png"); // loadingTexture1 = new TextureInfo("/Application/textures/LoadingScreens/Level1Load.png"); // loadingTexture2 = new TextureInfo("/Application/textures/LoadingScreens/Level2Load.png"); // loadingTexture3 = new TextureInfo("/Application/textures/LoadingScreens/Level3Load.png"); // loadingTexture4 = new TextureInfo("/Application/textures/LoadingScreens/Level4Load.png"); // loadingTexture5 = new TextureInfo("/Application/textures/LoadingScreens/Level5Load.png"); // loadingTexture6 = new TextureInfo("/Application/textures/LoadingScreens/Level6Load.png"); // loadingTexture7 = new TextureInfo("/Application/textures/LoadingScreens/Level7Load.png"); // loadingTexture8 = new TextureInfo("/Application/textures/LoadingScreens/Level8Load.png"); // loadingTexture9 = new TextureInfo("/Application/textures/LoadingScreens/Level9Load.png"); // loadingTexture10 = new TextureInfo("/Application/textures/LoadingScreens/Level10Load.png"); // loadingTexture11 = new TextureInfo("/Application/textures/LoadingScreens/Level11Load.png"); // loadingTexture12 = new TextureInfo("/Application/textures/LoadingScreens/Level12Load.png"); // loadingTexture13 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture14 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture15 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture16 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture17 = new TextureInfo("/Application/textures/LoadingScreens/Level0Load.png"); // //loadingTexture18 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture19 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture20 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture21 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture22 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture23 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture24 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture25 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); // //loadingTexture26 = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png"); textureInfo = AppMain.loadingTexture0; sprite = new SpriteUV(); sprite = new SpriteUV(textureInfo); sprite.Quad.S = textureInfo.TextureSizef; sprite.Position = new Vector2(-5000.0f, -5000.0f); sprite.CenterSprite(new Vector2(0.5f, 0.5f)); loadingLabel = new Sce.PlayStation.HighLevel.UI.Label(); loadingLabel.X = 804.0f; loadingLabel.Y = 503.0f; loadingLabel.Text = "Loading..."; loadingLabel.TextColor = new UIColor(0.0f, 0.0f, 0.0f, 1.0f); uiScene.RootWidget.AddChildLast(loadingLabel); levelLabel = new Sce.PlayStation.HighLevel.UI.Label(); levelLabel.X = 15.0f; levelLabel.Y = 503.0f; levelLabel.Text = ""; levelLabel.TextColor = new UIColor(1.0f, 1.0f, 1.0f, 1.0f); //levelLabel.Font = new UIFont(FontAlias.System, 32, FontStyle.Regular); uiScene.RootWidget.AddChildLast(levelLabel); loadingSymbol = new BusyIndicator(true); loadingSymbol.SetPosition(910, 495); loadingSymbol.SetSize(48, 48); loadingSymbol.Anchors = Anchors.Height | Anchors.Width; uiScene.RootWidget.AddChildLast(loadingSymbol); loadingSymbol.Start(); readyButton = new Button(); readyButton.SetPosition(860, 490); readyButton.Text = "PLAY"; readyButton.SetSize(88, 48); readyButton.BackgroundFilterColor = new UIColor(255.0f, 255.0f, 0.0f, 1.0f); readyButton.ButtonAction += HandleButtonAction; readyButton.Visible = false; uiScene.RootWidget.AddChildLast(readyButton); readyButton2 = new Button(); readyButton2.SetPosition(190, 450); readyButton2.Text = "JOIN X"; readyButton2.SetSize(88, 48); readyButton2.BackgroundFilterColor = new UIColor(255.0f, 255.0f, 0.0f, 1.0f); readyButton2.ButtonAction += HandleButtonAction; readyButton2.Visible = false; uiScene.RootWidget.AddChildLast(readyButton2); scene.AddChild(sprite); UISystem.SetScene(uiScene); startBox.Min = new Vector2(sprite.Position.X + loadingLabel.X - 500, sprite.Position.Y + loadingLabel.Y - 500); startBox.Max = new Vector2(sprite.Position.X + loadingLabel.X + 500, sprite.Position.Y + loadingLabel.Y + 500); }
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); }
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); }
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); }
public OptionScene() { Console.WriteLine("---- option scene ----"); this.Camera.SetViewFromViewport(); Sce.PlayStation.HighLevel.UI.Panel panel = new Panel();//create panel panel.Width = Director.Instance.GL.Context.GetViewport().Width; panel.Height = Director.Instance.GL.Context.GetViewport().Height; Sce.PlayStation.HighLevel.UI.Label title_label = new Sce.PlayStation.HighLevel.UI.Label();//title label Sce.PlayStation.HighLevel.UI.Label music_label = new Sce.PlayStation.HighLevel.UI.Label();//music label Sce.PlayStation.HighLevel.UI.Label sound_label = new Sce.PlayStation.HighLevel.UI.Label();//sound label labelSetting(title_label, //label name "Option", //label content panel.Width/10, //x position 10, //y position 250, //x size 100, //y size 64, //font size FontStyle.Bold, //font style new UIColor(0, 255, 0, 255)); //font color labelSetting(music_label, "Music :", panel.Width/7, panel.Height/5, 150, 100, 32, FontStyle.Regular, new UIColor(0, 255, 0, 255)); labelSetting(sound_label, "Sound :", panel.Width/7, panel.Height/3f, 150, 100, 32, FontStyle.Regular, new UIColor(0, 255, 0, 255)); Sce.PlayStation.HighLevel.UI.CheckBox checkMusicButton = new CheckBox(); //music checkMusicButton.Checked = isMusicCheckboxChanged; checkMusicButton.SetPosition(panel.Width/3,panel.Height/4.5f); checkMusicButton.SetSize(50,50); checkMusicButton.CheckedChanged += HandleCheckMusicButtonCheckedChanged; sliderForMusic = new Sce.PlayStation.HighLevel.UI.Slider(); sliderForMusic.SetPosition(panel.Width/2f,panel.Height/4.5f); sliderForMusic.SetSize(200,50); sliderForMusic.MinValue = 0; sliderForMusic.MaxValue = 1; sliderForMusic.Value = 0.5f; sliderForMusic.ValueChanging += HandleSliderForMusicValueChanging;//end music Sce.PlayStation.HighLevel.UI.CheckBox checkSoundButton = new CheckBox();//sound checkSoundButton.Checked = isSoundCheckboxChanged; checkSoundButton.SetPosition(panel.Width/3,panel.Height/2.5f); checkSoundButton.SetSize(50,50); checkSoundButton.CheckedChanged += HandleCheckSoundButtonCheckedChanged; sliderForSound = new Sce.PlayStation.HighLevel.UI.Slider(); sliderForSound.SetPosition(panel.Width/2f,panel.Height/2.5f); sliderForSound.SetSize(200,50); sliderForSound.MinValue = 0; sliderForSound.MaxValue = 1; sliderForSound.Value = Support.SoundSystem.volumOfSound; sliderForSound.ValueChanging += HandleSliderForSoundValueChanging;//end sound Button buttonUI1 = new Button(); //buttons buttonUI1.Name = "go back"; buttonUI1.Text = "go back"; buttonUI1.Width = 250; buttonUI1.Height = 50; buttonUI1.Alpha = 0.8f; buttonUI1.SetPosition(panel.Width/5,panel.Height - 100); buttonUI1.TouchEventReceived += (sender, e) => { Support.SoundSystem.Instance.PlayNoClobber("ButtonClick.wav"); Director.Instance.ReplaceScene(new MenuScene()); }; Button buttonUI2 = new Button(); buttonUI2.Name = "reset"; buttonUI2.Text = "reset"; buttonUI2.Width = 250; buttonUI2.Height = 50; buttonUI2.Alpha = 0.8f; buttonUI2.SetPosition(panel.Width/2f,panel.Height - 100); buttonUI2.TouchEventReceived += (sender, e) => { Support.SoundSystem.Instance.PlayNoClobber("ButtonClick.wav"); }; _uiScene = new Sce.PlayStation.HighLevel.UI.Scene(); panel.AddChildLast(title_label);//add widgets in panel panel.AddChildLast(music_label); panel.AddChildLast(sound_label); panel.AddChildLast(checkMusicButton); panel.AddChildLast(checkSoundButton); panel.AddChildLast(sliderForMusic); panel.AddChildLast(sliderForSound); panel.AddChildLast(buttonUI1); panel.AddChildLast(buttonUI2); _uiScene.RootWidget.AddChildLast(panel);//add panel in rootwidget UISystem.SetScene(_uiScene); //add rootwidget in scene Scheduler.Instance.ScheduleUpdateForTarget(this,0,false); //run the loop }
public void Initialize() { //graphics = new GraphicsContext(); //UISystem.Initialize(graphics); Console.WriteLine("---- game scene -----"); ImageRect rectScreen = AppMain.graphics.Screen.Rectangle; generator = new Random (); dots = new List<SimpleSprite> (); //dots_2 = new List<SimpleSprite> (); hits = new List<Hits> (); //creating texture2D in prep for the Simple Sprites //texture = new Texture2D ("/Application/resources/world.png", false); texture2 = new Texture2D ("/Application/resources/Bomb_mini.png", false); texture2_left = new Texture2D("/Application/resources/Bomb_mini_left.png", false); texture2_right = new Texture2D("/Application/resources/Bomb_mini_right.png", false); texture3 = new Texture2D ("/Application/resources/dot_1.png", false); Atlanta = new Texture2D ("/Application/resources/Atlanta.png", false); Paris_1 = new Texture2D ("/Application/resources/Paris_01.png", false); Paris_2 = new Texture2D ("/Application/resources/Paris_02.png", false); Paris_3 = new Texture2D ("/Application/resources/Paris_03.png", false); Paris_4 = new Texture2D ("/Application/resources/Paris_04.png", false); Atlanta_01 = new Texture2D("/Application/resources/Atlanta_01.png", false); Atlanta_02 = new Texture2D("/Application/resources/Atlanta_02.png", false); Atlanta_03 = new Texture2D("/Application/resources/Atlanta_03.png", false); Atlanta_04 = new Texture2D("/Application/resources/Atlanta_04.png", false); LA_01 = new Texture2D("/Application/resources/LA_01.png", false); LA_02 = new Texture2D("/Application/resources/LA_02.png", false); LA_03 = new Texture2D("/Application/resources/LA_03.png", false); LA_04 = new Texture2D("/Application/resources/LA_04.png", false); NYC_01= new Texture2D("/Application/resources/NYC_01.png", false); NYC_02= new Texture2D("/Application/resources/NYC_02.png", false); NYC_03= new Texture2D("/Application/resources/NYC_03.png", false); NYC_04= new Texture2D("/Application/resources/NYC_04.png", false); LosAngeles = new Texture2D ("/Application/resources/LA.png", false); NewYork = new Texture2D ("/Application/resources/NYC.png", false); particle_Tex = new Texture2D ("/Application/resources/fire_particle.png", false); skyline_1_fire = new Texture2D ("/Application/resources/Paris_01_hit.png", false); skyline_2_fire = new Texture2D ("/Application/resources/Paris_02_hit.png", false); skyline_3_fire = new Texture2D ("/Application/resources/Paris_03_hit.png", false); skyline_4_fire = new Texture2D ("/Application/resources/Paris_04_hit.png", false); explosionPic = new Texture2D("/Application/resources/GraySmoke.png",false); //create array to put different player maps in. SimpleSprite[] skylines = new SimpleSprite[] { ATL1 = new SimpleSprite (AppMain.graphics, Atlanta_01),//0 paris_1 = new SimpleSprite (AppMain.graphics, Paris_1),//1 LA = new SimpleSprite (AppMain.graphics, LA_01), NYC = new SimpleSprite (AppMain.graphics, NYC_01), ATL = new SimpleSprite (AppMain.graphics, Atlanta_01), }; for (int s = 0; s <= skylines.Length; ++s) { if (s == Convert.ToInt32 (ID)) { play_Sky_Line_1 = skylines [s]; play_Sky_Line_1.Position.X = 0; play_Sky_Line_1.Position.Y = 0; } if (play_Sky_Line_1 == skylines [1]) { play_Sky_Line_2 = new SimpleSprite (AppMain.graphics, Paris_2); play_Sky_Line_3 = new SimpleSprite (AppMain.graphics, Paris_3); play_Sky_Line_4 = new SimpleSprite (AppMain.graphics, Paris_4); } if (play_Sky_Line_1 == skylines [2]) { play_Sky_Line_2 = new SimpleSprite (AppMain.graphics, LA_02); play_Sky_Line_3 = new SimpleSprite (AppMain.graphics, LA_03); play_Sky_Line_4 = new SimpleSprite (AppMain.graphics, LA_04); } if (play_Sky_Line_1 == skylines [3]) { play_Sky_Line_2 = new SimpleSprite (AppMain.graphics, NYC_02); play_Sky_Line_3 = new SimpleSprite (AppMain.graphics, NYC_03); play_Sky_Line_4 = new SimpleSprite (AppMain.graphics, NYC_04); } if (play_Sky_Line_1 == skylines [4]) { play_Sky_Line_2 = new SimpleSprite (AppMain.graphics, Atlanta_02); play_Sky_Line_3 = new SimpleSprite (AppMain.graphics, Atlanta_03); play_Sky_Line_4 = new SimpleSprite (AppMain.graphics, Atlanta_04); } //if(skylines[s] == LA_1) //{// //play_Sky_Line_2 = skylines [LA_2]; //play_Sky_Line_3 = skylines [LA_3]; //play_Sky_Line_4 = skylines [LA_4]; //} } play_Sky_Line_2.Position.X = 240; play_Sky_Line_2.Position.Y = 0; play_Sky_Line_3.Position.X = 480; play_Sky_Line_3.Position.Y = 0; play_Sky_Line_4.Position.X = 720; play_Sky_Line_4.Position.Y = 0; skyline_1 = new Rectangle (0, 410, Paris_1.Width, 134); //skyline_2 = new Rectangle(240, 410, Paris_2.Width, 134); //skyline_3 = new Rectangle(480, 410, Paris_3.Width, 134); //skyline_4 = new Rectangle(720, 410, Paris_4.Width, 134); //World = new SimpleSprite (AppMain.graphics, texture); Fire_skyline_1 = new SimpleSprite (AppMain.graphics, skyline_1_fire); Fire_skyline_2 = new SimpleSprite (AppMain.graphics, skyline_2_fire); Fire_skyline_3 = new SimpleSprite (AppMain.graphics, skyline_3_fire); Fire_skyline_4 = new SimpleSprite (AppMain.graphics, skyline_4_fire); yellow_Dot = new SimpleSprite (AppMain.graphics, texture3); red_Dot = new SimpleSprite (AppMain.graphics, texture2); particle = new SimpleSprite (AppMain.graphics, particle_Tex); spriteArray [0] = red_Dot; spriteArray [1] = yellow_Dot; timeCount = new Sce.PlayStation.HighLevel.UI.Label(); score = new Sce.PlayStation.HighLevel.UI.Label(); labelOfScore = new Sce.PlayStation.HighLevel.UI.Label(); labelSetting(timeCount, //time count "30", 960/2 - 20, 0, 150, 100, 32, FontStyle.Regular, new UIColor(0, 0, 0, 255)); timer = new System.Diagnostics.Stopwatch();//timer labelSetting(score, //score "0", 960 - 100, 0, 150, 100, 20, FontStyle.Regular, new UIColor(0, 0, 0, 255)); labelSetting(labelOfScore, //score board "Score: ", 960 - 200, 0, 150, 100, 20, FontStyle.Regular, new UIColor(0, 0, 0, 255)); //heath bar -- saparate to 5 parts _uiScene = new Sce.PlayStation.HighLevel.UI.Scene(); ImageBox healthIcon = new ImageBox(); healthIcon.Image = new ImageAsset("/Application/resources/shield-grey.png"); healthIcon.PivotType = PivotType.MiddleCenter; healthIcon.Width = healthIcon.Image.Width/4.5f; healthIcon.Height = healthIcon.Image.Height/4.5f; healthIcon.SetPosition(35,40); healthbar_01 = new ImageBox(); healthbar_01.Image = new ImageAsset("/Application/resources/red-rectangle.jpg"); healthbar_01.PivotType = PivotType.MiddleCenter; healthbar_01.Width = healthbar_01.Image.Width/4.5f; healthbar_01.Height = healthbar_01.Image.Height/4.5f; healthbar_01.SetPosition(100,40); healthbar_02 = new ImageBox(); healthbar_02.Image = new ImageAsset("/Application/resources/red-rectangle.jpg"); healthbar_02.PivotType = PivotType.MiddleCenter; healthbar_02.Width = healthbar_02.Image.Width/4.5f; healthbar_02.Height = healthbar_02.Image.Height/4.5f; healthbar_02.SetPosition(155,40); healthbar_03 = new ImageBox(); healthbar_03.Image = new ImageAsset("/Application/resources/red-rectangle.jpg"); healthbar_03.PivotType = PivotType.MiddleCenter; healthbar_03.Width = healthbar_03.Image.Width/4.5f; healthbar_03.Height = healthbar_03.Image.Height/4.5f; healthbar_03.SetPosition(210,40); healthbar_04 = new ImageBox(); healthbar_04.Image = new ImageAsset("/Application/resources/red-rectangle.jpg"); healthbar_04.PivotType = PivotType.MiddleCenter; healthbar_04.Width = healthbar_04.Image.Width/4.5f; healthbar_04.Height = healthbar_04.Image.Height/4.5f; healthbar_04.SetPosition(265,40); _uiScene.RootWidget.AddChildLast(timeCount); _uiScene.RootWidget.AddChildLast(score); _uiScene.RootWidget.AddChildLast(healthIcon); _uiScene.RootWidget.AddChildLast(healthbar_01); _uiScene.RootWidget.AddChildLast(healthbar_02); _uiScene.RootWidget.AddChildLast(healthbar_03); _uiScene.RootWidget.AddChildLast(healthbar_04); _uiScene.RootWidget.AddChildLast(labelOfScore); UISystem.SetScene(_uiScene); // create menu scene }
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); }