public override void Update(float dT) { var touches = Touch.GetData(0); timer += dT; if (timer > 0.5f) { splat.Color = new Vector4(0.0f, 0.0f, 0.0f, 1.0f); ScaleSplat(dT); } if (timer > 2.0f) { ScaleTitle(dT); if (timer > 2.5f) { title.Color = new Vector4(1.0f, 1.0f, 1.0f, 1.0f); } } if (timer >= 5.0) { logo.Color = new Vector4(1.0f, 1.0f, 1.0f, 1.0f); } if (touches.Count > 0 && touches[0].Status == TouchStatus.Down || timer >= 8.0f) { SoundPlayer.Dispose(); SceneManager.Instance.setStartScene(); } Director.Instance.Update(); }
public TitleScene() { this.Camera.SetViewFromViewport(); m_texture = new Texture2D("Application/images/title.png", false); m_ti = new TextureInfo(m_texture); SpriteUV titleScreen = new SpriteUV(m_ti); titleScreen.Scale = m_ti.TextureSizef; titleScreen.Pivot = new Vector2(0.5f, 0.5f); titleScreen.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width / 2.0f, Director.Instance.GL.Context.GetViewport().Height / 2.0f); this.AddChild(titleScreen); Vector4 origColor = titleScreen.Color; titleScreen.Color = new Vector4(0, 0, 0, 0); var tintAction = new TintTo(origColor, 10.0f); ActionManager.Instance.AddAction(tintAction, titleScreen); tintAction.Run(); m_titleSong = new Bgm("/Application/audio/titlesong.mp3"); if (m_songPlayer != null) { m_songPlayer.Dispose(); } m_songPlayer = m_titleSong.CreatePlayer(); Scheduler.Instance.ScheduleUpdateForTarget(this, 0, false); // Clear any queued clicks so we dont immediately exit if coming in from the menu Touch.GetData(0).Clear(); }
public void Dispose() { if (_currentSong == this && _bgmPlayer != null) { _bgmPlayer.Stop(); _bgmPlayer.Dispose(); } _bgm.Dispose(); }
private void PlatformDispose(bool disposing) { if (_currentSong == this && _bgmPlayer != null) { _bgmPlayer.Stop(); _bgmPlayer.Dispose(); } _bgm.Dispose(); }
//Resets the game in order to make a fresh, new game public static void NewGame() { //Disposes of menu music, and plays game music bgmplay.Dispose(); Bgm bgm2 = new Bgm("/Application/Sounds/RomanticFall.mp3"); bgmplay2 = bgm2.CreatePlayer(); bgmplay2.Loop = true; bgmplay2.Play(); background = new Background(graphics, backTex); backplanets = new BackgroundPlanets(graphics); enemyTimeCounter = 0; weapons = new List <Weapon> (); enemies = new List <Enemy> (); pickups = new List <Pickup> (); ebullets = new List <EnemyBullet> (); p = new Player(graphics, 100, 100, pTex); counter = -1; currentWeapon = GameWeapons.Missles; enemyCounter = enemies.Count; timeDelta = 0; hasLaser = false; hasMissle = true; hasSpread = false; p1 = new Pickup(graphics, powTex, gen.Next(100, 700), gen.Next(100, 500)); pickups.Add(p1); p2 = new Pickup(graphics, powTex, gen.Next(100, 700), gen.Next(100, 500)); pickups.Add(p2); spreadNext = false; laserNext = false; playerScore = 0; enterName = ""; newHighScore = false; }
//Stops any music currently playing public static void StopMusic() { if (musicPlayer != null) { musicPlayer.Stop(); musicPlayer.Dispose(); musicPlayer = null; } }
public virtual int StopMusic() { if (_musicPlayer != null) { _musicPlayer.Stop(); _musicPlayer.Dispose(); _musicPlayer = null; _music = null; } return(0); }
public override void Update(float dT) { var touches = Touch.GetData(0); timer += dT; if (touches.Count > 0 && touches[0].Status == TouchStatus.Down || timer >= 5.0f) { hahaSoundPlayer.Dispose(); SceneManager.Instance.setStartScene(); } Director.Instance.Update(); }
/// BGMの停止 public void StopBgm() { if (bgmPlayer != null) { if (bgmPlayer.Status == BgmStatus.Playing) { bgmPlayer.Stop(); } bgmPlayer.Dispose(); } bgmPlayer = null; }
public override void OnExit() { player.Stop(); music.Dispose(); player.Dispose(); sprite.TextureInfo.Dispose(); this.RemoveAllChildren(true); base.OnExit(); }
public static void Dispose() { if (_bgmPlayer != null) { _bgmPlayer.Dispose(); _bgmPlayer = null; } if (_soundPlayer != null) { _soundPlayer.Dispose(); _soundPlayer = null; } }
//Background Music private static void MusicPlay(string music) { try { bgmp.Dispose(); } catch {} Bgm bgm = new Bgm(music); bgmp = bgm.CreatePlayer(); bgmp.Loop = true; bgmp.Play(); }
public override void Update(float dT) { uiTime.Text = "Time: " + ScoreManager.Instance.getTime(); uiScore.Text = "Score: " + ScoreManager.Instance.getScore(); foreach (Tank tank in tankList) { tank.Update(dT); tank.rotateTurret(player.Position(), dT); if (player.isTouching() && player.Collision(tank.getPosition(), tank.getSize())) { alive = false; } } player.Update(); if (player.isTouching()) { ScoreManager.Instance.runScore(); if (bgSoundPlayer.Status == BgmStatus.Paused) { bgSoundPlayer.Resume(); } else if (bgSoundPlayer.Status != BgmStatus.Playing) { bgSoundPlayer.Play(); } } else { bgSoundPlayer.Pause(); } if (!alive) { bgSoundPlayer.Dispose(); ScoreManager.Instance.setScore(); SceneManager.Instance.setEndScene(); } Director.Instance.Update(); }
public override void OnExit() { lumberMillList.RemoveAllChildren(true); mineAndStrongHoldList.RemoveAllChildren(true); mineDrillList.RemoveAllChildren(true); lumbermillSheetTextureInfo.Dispose(); mineSheetTextureInfo.Dispose(); strongHoldAndMineSheetTextureInfo.Dispose(); worldmap.TextureInfo.Dispose(); boombox.Stop(); music.Dispose(); boombox.Dispose(); this.RemoveAllChildren(true); Console.WriteLine(lumbermillSheetTextureInfo.Disposed.ToString() + " " + mineSheetTextureInfo.Disposed.ToString() + " " + strongHoldAndMineSheetTextureInfo.Disposed.ToString()); }
/// <summary> /// 音乐淡入淡出管理器 /// </summary> public void MusicManager() { if (musicStatus == SoundComanndStatus.Play) { if (MusicList.Count == 1) { if (MusicPlayer == null) { CreatMusicPlayer(MusicList[0]); } else if (MusicPlayer.Status == BgmStatus.Playing && MusicPlayer.Volume < musicVolume) { if ((MusicPlayer.Volume += musicVolume / (float)(musicSoundIn / 200)) <= musicVolume) { MusicPlayer.Volume += musicVolume / (float)(musicSoundIn / 200); } else { MusicPlayer.Volume = musicVolume; } } } else if (MusicList.Count >= 2) { musicStatus = SoundComanndStatus.Stop; } } else if (musicStatus == SoundComanndStatus.Stop) { if (MusicPlayer == null) { MusicList.RemoveAt(0); if (MusicList.Count == 1) { musicStatus = SoundComanndStatus.Play; } } else if (MusicPlayer.Status == BgmStatus.Playing && MusicPlayer.Volume > 0) { if ((MusicPlayer.Volume -= musicVolume / (float)(musicSoundOut / 200)) >= 0) { MusicPlayer.Volume -= musicVolume / (float)(musicSoundOut / 200); } else { MusicPlayer.Volume = 0; } } else if (MusicPlayer.Volume <= 0) { MusicPlayer.Stop(); MusicPlayer.Dispose(); MusicPlayer = null; MusicList.RemoveAt(0); if (MusicList.Count == 1) { musicStatus = SoundComanndStatus.Play; } } } }
public static void Update() { var gamePadData = GamePad.GetData(0); //tester.Position.X = dat.X; //tester.Position.Y = dat.Y; //Menu Handling if (start || directions || enterscore || highscore || end) { menuBuffer++; if (start) { if ((gamePadData.Buttons & GamePadButtons.Square) != 0 && //need != 0? menuBuffer >= MENU_INPUT_BUFFER) { start = false; directions = true; menuBuffer = 0; } if ((gamePadData.Buttons & GamePadButtons.Cross) != 0 && menuBuffer >= MENU_INPUT_BUFFER) { start = false; game = true; menuBuffer = 0; score = 0; difficulty = 0; player = new Player(graphics); died = false; paused = false; for (int i = enemies.Count - 1; i >= 0; i--) { enemies.RemoveAt(i); } for (int i = projectiles.Count - 1; i >= 0; i--) { projectiles.RemoveAt(i); } gotFlame = false; gotLazer = false; wpn = new WeaponBasic(graphics); if (!gameMusic) { bgmp.Dispose(); Bgm bgm1 = new Bgm("/Application/Assets/playstate.mp3"); bgmp1 = bgm1.CreatePlayer(); bgmp1.Loop = true; bgmp1.Play(); gameMusic = true; } } if ((gamePadData.Buttons & GamePadButtons.Circle) != 0 && menuBuffer >= MENU_INPUT_BUFFER) { start = false; highscore = true; menuBuffer = 0; UISystem.SetScene(sceneScores, null); } if ((gamePadData.Buttons & GamePadButtons.Start) != 0 && menuBuffer >= MENU_INPUT_BUFFER) { start = false; end = true; menuBuffer = 0; } } if (directions) { if ((gamePadData.Buttons & GamePadButtons.Square) != 0 && menuBuffer >= MENU_INPUT_BUFFER) { directions = false; start = true; menuBuffer = 0; } } if (highscore) { if ((gamePadData.Buttons & GamePadButtons.Square) != 0 && menuBuffer >= MENU_INPUT_BUFFER) { highscore = false; start = true; menuBuffer = 0; UISystem.SetScene(sceneGame, null); } if ((gamePadData.Buttons & GamePadButtons.Start) != 0 && menuBuffer >= MENU_INPUT_BUFFER) { highscore = false; end = true; menuBuffer = 0; UISystem.SetScene(sceneGame, null); } } if (enterscore) { if ((gamePadData.Buttons & GamePadButtons.Up) != 0 && menuBuffer >= MENU_INPUT_BUFFER - 22) { if (label4.Text.Length == 1) { if (!label4.Text.Equals("z", StringComparison.OrdinalIgnoreCase)) //look into why the oridinal ignore case { label4.Text = ((char)(label4.Text.ToCharArray()[0] + 1)).ToString().ToUpper(); } else { label4.Text = "A"; } } else if (label4.Text.Length == 2) { if (!label4.Text.Substring(1).Equals("z", StringComparison.OrdinalIgnoreCase)) { label4.Text = label4.Text.Substring(0, 1) + ((char)(label4.Text.ToCharArray()[1] + 1)).ToString().ToUpper(); } else { label4.Text = label4.Text.Substring(0, 1) + "A"; } } else if (label4.Text.Length == 3) { if (!label4.Text.Substring(2).Equals("z", StringComparison.OrdinalIgnoreCase)) { label4.Text = label4.Text.Substring(0, 2) + ((char)(label4.Text.ToCharArray()[2] + 1)).ToString().ToUpper(); } else { label4.Text = label4.Text.Substring(0, 2) + "A"; } } menuBuffer = 0; } if ((gamePadData.Buttons & GamePadButtons.Down) != 0 && menuBuffer >= MENU_INPUT_BUFFER - 22) { if (label4.Text.Length == 1) { if (!label4.Text.Equals("a", StringComparison.OrdinalIgnoreCase)) { label4.Text = ((char)(label4.Text.ToCharArray()[0] - 1)).ToString().ToUpper(); } else { label4.Text = "Z"; } } if (label4.Text.Length == 2) { if (!label4.Text.Substring(1).Equals("a", StringComparison.OrdinalIgnoreCase)) { label4.Text = label4.Text.Substring(0, 1) + ((char)(label4.Text.ToCharArray()[1] - 1)).ToString().ToUpper(); } else { label4.Text = label4.Text.Substring(0, 1) + "Z"; } } if (label4.Text.Length == 3) { if (!label4.Text.Substring(2).Equals("a", StringComparison.OrdinalIgnoreCase)) { label4.Text = label4.Text.Substring(0, 2) + ((char)(label4.Text.ToCharArray()[2] - 1)).ToString().ToUpper(); } else { label4.Text = label4.Text.Substring(0, 2) + "Z"; } } menuBuffer = 0; } if ((gamePadData.Buttons & GamePadButtons.Cross) != 0 && menuBuffer >= MENU_INPUT_BUFFER - 20) { if (hiScore == (score - score % .01)) { highscore = true; enterscore = false; UISystem.SetScene(sceneScores); try { StreamReader sr = new StreamReader("/Documents/highscores.txt"); string tempS = sr.ReadLine(); hiScore = Double.Parse(tempS.Substring(3)); label3.Text = tempS.Substring(0, 3) + ": " + hiScore; sr.Close(); } catch (FileNotFoundException) { label3.Text = "File Not Found!"; } label4.Text = "A"; label4.Font.Size += 15; } if (label4.Text.Length < 3) { label4.Text += "A"; } else { try { StreamWriter sw = new StreamWriter("/Documents/highscores.txt"); sw.WriteLine(label4.Text + (score - score % .01)); hiScore = score - score % .01; sw.Close(); label4.Font.Size -= 15; label4.Text = "Entered! Press (s)"; } catch (FileNotFoundException) { label4.Font.Size -= 10; label4.Text = "File not Found! Highscore not saved!"; } } menuBuffer = 0; } } if (end) { if ((gamePadData.Buttons & GamePadButtons.Start) != 0 && menuBuffer >= MENU_INPUT_BUFFER) { exit = true; menuBuffer = 0; } } } //end menu else { //Keeps you from pause spamming via 25-frame buffer pauseFrameBuffer++; if ((gamePadData.Buttons & GamePadButtons.Select) != 0 && pauseFrameBuffer >= 25) { pauseFrameBuffer = 0; if (paused == false) { paused = true; } else { paused = false; } } if ((gamePadData.Buttons & GamePadButtons.Start) != 0) { end = true; } if (died && !paused) { start = true; } if (paused) { if (label1.Font.Size < initialL1FontSize + 30) //font constants { label1.Font.Size += 3; } if (label1.Height < initialL1Height + 18) { label1.Height += 1.8f; } if (label2.Font.Size < initialL2FontSize + 30) { label2.Font.Size += 3; } if (label2.Height < initialL2Height + 18) { label2.Height += 1.8f; } if (label2.Y > initialL2Y - 24) { label2.Y -= 2.4f; } } if (game && !paused) { //Add Time Score score += deltaTime / 500.0; //Increase Difficulty and recaculate spawn times difficulty += 0.5; if (DESpawnRate > 150) { DESpawnRate = -0.2642 * difficulty + 755.9524; } if (LOSpawnRate > 300) { LOSpawnRate = -0.4628 * difficulty + 3000.5714; } if (SESpawnRate > 300) { SESpawnRate = -0.9358 * difficulty + 6907.1429; } if (BESpawnRate > 12500) { BESpawnRate = -0.9643 * difficulty + 34285.7143; } //Checks for picking up the Flamethrower if (!gotFlame && distanceSquared(player.X + player.Area.Width / 2, flameBox.Position.X + flameBox.Width / 2, player.Y + player.Area.Height / 2, flameBox.Position.Y + flameBox.Height / 2) < Math.Pow(player.HitBox + flameBox.Height / 2, 2)) { gotFlame = true; score += 1000; } //etc if (!gotLazer && distanceSquared(player.X + player.Area.Width / 2, lazerBox.Position.X + lazerBox.Width / 2, player.Y + player.Area.Height / 2, lazerBox.Position.Y + lazerBox.Height / 2) < Math.Pow(player.HitBox + lazerBox.Height / 2, 2)) { gotLazer = true; score += 1000; } //Check for weapon change changeWeapons(gamePadData); //Spawn Enemies createEnemies(); //Update Player player.Update(gamePadData, deltaTime); //Update Weapon in use wpn.Update(player.X, player.Y, (int)player.Direction, gamePadData, deltaTime); //This handles the creation of projectiles from the weapon. if (wpn.MakeShot && distanceSquared(player.X + player.Area.Width / 2, shine.Position.X + shine.Width / 2, player.Y + player.Area.Height / 2, shine.Position.Y + shine.Height / 2) > Math.Pow(player.HitBox + shine.Height / 2, 2)) { if (wpn is WeaponBasic) { projectiles.Add(new ProjectileBasic(graphics, wpn.X, wpn.Y, wpn.Direction, projBTex)); } if (wpn is WeaponFlame) { projectiles.Add(new ProjectileFlame(graphics, wpn.X, wpn.Y, wpn.Direction, projFTex)); } if (wpn is WeaponLazer) { projectiles.Add(new ProjectileLazer(graphics, wpn.X, wpn.Y, wpn.Direction, projLTex)); } wpn.MakeShot = false; } //Collision checking checkForCollisions(); //Handle enemy updates and deletes updateLists(); //Label updates and normalization label1.Text = "Score: " + (score - score % 1); if (label1.Font.Size > initialL1FontSize) { label1.Font.Size -= 3; } if (label1.Height > initialL1Height) { label1.Height -= 1.8f; } label2.Text = "Health: " + player.Health; if (label2.Font.Size > initialL2FontSize) { label2.Font.Size -= 3; } if (label2.Height > initialL2Height) { label2.Height -= 1.8f; } if (label2.Y < initialL2Y) { label2.Y += 2.4f; } } //When paused, show more detailed score if (paused) { label1.Text = "Score: " + (score - score % .01); } //End of Game Scenario if (player.Delete) { paused = true; if (score > hiScore) { enterscore = true; label1.Text = "Final Score: " + (score - score % .01); label2.Text = "You got the High Score! (z) to Enter Initials!"; UISystem.SetScene(sceneHiScore, null); } else { died = true; label1.Text = "Final Score: " + (score - score % .01); label2.Text = "You have died! (z) to Main Menu."; } } } }
public static void Update() { // Query gamepad for current state var gamePadData = GamePad.GetData(0); List <TouchData> touches = Touch.GetData(0); foreach (TouchData data in touches) { currentTouchStatus = data.Status; float xPos = (data.X + 0.5f) * screenWidth; float yPos = (data.Y + 0.5f) * screenHeight; // Are we presing down on the touchpad? if (data.Status == TouchStatus.Down) { // Check to see if we are intersecting a flag if (InsideRect(xPos, yPos, scotlandRect)) { if (mp3Player.Status == BgmStatus.Playing) { mp3Player.Stop(); mp3Player.Dispose(); } Bgm scotlandVoice = new Bgm("/Application/sounds/scotlandVoice.mp3"); mp3Player = scotlandVoice.CreatePlayer(); mp3Player.Play(); } if (InsideRect(xPos, yPos, englandRect)) { if (mp3Player.Status == BgmStatus.Playing) { mp3Player.Stop(); mp3Player.Dispose(); } Bgm englandVoice = new Bgm("/Application/sounds/englandVoice.mp3"); mp3Player = englandVoice.CreatePlayer(); mp3Player.Play(); } if (InsideRect(xPos, yPos, n_irelandRect)) { if (mp3Player.Status == BgmStatus.Playing) { mp3Player.Stop(); mp3Player.Dispose(); } Bgm n_irelandVoice = new Bgm("/Application/sounds/n_irelandVoice.mp3"); mp3Player = n_irelandVoice.CreatePlayer(); mp3Player.Play(); } if (InsideRect(xPos, yPos, walesRect)) { if (mp3Player.Status == BgmStatus.Playing) { mp3Player.Stop(); mp3Player.Dispose(); } Bgm walesVoice = new Bgm("/Application/sounds/walesVoice.mp3"); mp3Player = walesVoice.CreatePlayer(); mp3Player.Play(); } } previousTouchStatus = currentTouchStatus; /* * Console.WriteLine("ID "+data.ID); * Console.WriteLine("Status "+data.Status); * Console.WriteLine("Xcoord "+(data.X + 0.5f) * screenWidth); * Console.WriteLine("Ycoord "+(data.Y + 0.5f) * screenHeight); */ } }
public void close() { stop(); bgmPlayer.Dispose(); bgm.Dispose(); }