public void Update(Player player, Dictionary<string,CaseFile> levelCases) { casesListTest.Clear(); caseDistance.Clear(); foreach(KeyValuePair<string,CaseFile> i in levelCases) { double x; double y; double distance; x = Math.Abs(i.Value.rectangle.X - player.playerRectangle.X); y = Math.Abs(i.Value.rectangle.Y - player.playerRectangle.Y); distance = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)); caseDistance.Add(distance); casesList.Add(i.Value); } if (caseDistance[0] < caseDistance[1] && caseDistance[0] < caseDistance[2]) { playRelativeSound(player, 0); } else if (caseDistance[1] < caseDistance[0] && caseDistance[1] < caseDistance[2]) { playRelativeSound(player, 1); } else if (caseDistance[2] < caseDistance[1] && caseDistance[2] < caseDistance[0]) { playRelativeSound(player, 2); } }
public void Update3(Player player, Rectangle _1,Rectangle _2, Rectangle _3) { casesListTest.Clear(); caseDistance.Clear(); casesListTest.Add(_1); casesListTest.Add(_2); casesListTest.Add(_3); foreach (Rectangle i in casesListTest) { double x; double y; double distance; x = Math.Abs(i.X - player.playerRectangle.X); y = Math.Abs(i.Y - player.playerRectangle.Y); distance = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)); caseDistance.Add(distance); } if (caseDistance[0] < caseDistance[1] && caseDistance[0] < caseDistance[2]) { playRelativeSound(player, 0); } else if (caseDistance[1] < caseDistance[0] && caseDistance[1] < caseDistance[2]) { playRelativeSound(player, 1); } else if (caseDistance[2] < caseDistance[1] && caseDistance[2] < caseDistance[0]) { playRelativeSound(player, 2); } }
public void UpdateTest(Player player, Rectangle inRectangle) { double x; double y; double distance; x = Math.Abs(inRectangle.X - player.playerRectangle.X); y = Math.Abs(inRectangle.Y - player.playerRectangle.Y); distance = Math.Sqrt(Math.Pow(x,2) + Math.Pow(y,2)); double panNum = inRectangle.X - player.playerRectangle.X; pan = MathHelper.Clamp((float)(panNum/100), -1, 1); volume = MathHelper.Clamp((float)(100 / distance), 0, 1); heartBeatInst.Pan = (float)pan; heartBeatInst.Volume = (float)volume; if (heartBeatInst.State != SoundState.Playing) { heartBeatInst.Play(); } }
private void playRelativeSound(Player player, int i) { double panNum = casesListTest[i].X - player.playerRectangle.X; pan = MathHelper.Clamp((float)(panNum / 100), -1, 1); volume = MathHelper.Clamp((float)(100 / caseDistance[i]), 0, 1); heartBeatInst.Pan = (float)pan; heartBeatInst.Volume = (float)volume; if (heartBeatInst.State != SoundState.Playing) { heartBeatInst.Play(); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { ScreenSize = new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); screenWidth = GraphicsDevice.Viewport.Width; screenHeight = GraphicsDevice.Viewport.Height; BulletDir = Vector2.Zero; noOfClues = 5; // List of cases #region caseList Sprite CaseItem = new Sprite(Content.Load<Texture2D>("case"), new Rectangle(0, 0, Content.Load<Texture2D>("case").Width, Content.Load<Texture2D>("case").Height), 0.0f, SpriteEffects.None, Color.White); for (int i = 0; i < noOfClues; i++) { caseList.Add("Case" + i.ToString(), new CaseFile(Content.Load<Texture2D>("popUp"), new Rectangle(10, 10, 150, 200), new Rectangle(0, 0, 3200, 2400), 0.0f, SpriteEffects.None, Color.White, CaseItem.Copy(), "lol", "hehe", Vector2.Zero)); } #endregion #region MenuSetup mainMenu = new Menu(new Rectangle(0, -5, screenWidth*8/10, screenHeight / 8), Content.Load<Texture2D>("MainMenuTitle")); mainMenu.Add(new Rectangle(0, 0, screenWidth / 10, screenHeight / 10), Content.Load<Texture2D>("MainMenuPlay")); mainMenu.Add(new Rectangle(0, 0, screenWidth / 5, screenHeight / 9), Content.Load<Texture2D>("MainMenuSettings")); mainMenu.Add(new Rectangle(0, 0, screenWidth / 12, screenHeight / 9), Content.Load<Texture2D>("MainMenuExit")); Alignment align = Alignment.Left; mainMenu.Setup(align, screenHeight, screenWidth); mainMenu.backgroundRectangle = new Rectangle(0, 0, screenWidth, screenHeight); mainMenu.backgroundTexture = Content.Load<Texture2D>("MainMenuBackground"); #endregion // Creates the user player = new Player( Content.Load<Texture2D>("Tron_Charcter2"), 8, 3); player.Load(); // Creates the enemy enemy = new Enemy( Content.Load<Texture2D>("Tron_Charcter2"), 8, 3); enemy.Load(); CaseFont = Content.Load<SpriteFont>("cFont"); splashScreen = new Sprite(Content.Load<Texture2D>("betaJester1"), new Rectangle(0, 0, screenWidth, screenHeight), 0.0f, SpriteEffects.None, Color.White); //ixjingle = Content.Load<SoundEffect>("ixjingle"); //heartBeatIntro = Content.Load<SoundEffect>("GGJ13_Theme"); background = new Background(Content.Load<Texture2D>("gamebackground"), Content.Load<Texture2D>("gamebackgroundback"), Content.Load<Texture2D>("gamebackgroundmiddle"), Content.Load<Texture2D>("gamebackgroundfront"), 200 * 32, screenWidth, screenHeight); playerData = PlayerData.Load(); //heartBeatTracker = new HeartBeatTracker(Content.Load<SoundEffect>("heartBeat")); ParticleEffects = new ParticleSystem(Vector2.Zero); ParticleEffects.AddEmitter(new Vector2(0.001f, 0.6f), new Vector2(0, 1), new Vector2(0.0f * MathHelper.Pi, 0.0f * -MathHelper.Pi), new Vector2(1f, 1f), new Vector2(60, 70), new Vector2(15, 15f), Color.White, Color.White, Color.White, Color.White, new Vector2(0, 700), new Vector2(0, 120), 500, new Vector2(100, 100), Content.Load<Texture2D>("raindrop"), 0, (int)ScreenSize.X); if (playerData == null) { playerData = new PlayerData(100, 0.0f, 0, 0); } enemyGun = new Gun(new Vector2(enemy.enemyRectangle.X + enemy.enemyRectangle.Width, enemy.enemyRectangle.Y), Content.Load<Texture2D>("bullet"), new Rectangle(0, 0, Content.Load<Texture2D>("bullet").Width, Content.Load<Texture2D>("bullet").Height), 5, 0.0f, SpriteEffects.None, Color.White, 1, null, null, false); playerGun = new Gun(new Vector2(player.playerRectangle.X + player.playerRectangle.Width, player.playerRectangle.Y), Content.Load<Texture2D>("bullet"), new Rectangle(0, 0, Content.Load<Texture2D>("bullet").Width, Content.Load<Texture2D>("bullet").Height), 5, 0.0f, SpriteEffects.None, Color.White, 1, null, null, false); spriteBatch = new SpriteBatch(GraphicsDevice); Tile.TileSetTexture = Content.Load<Texture2D>("TileSet"); background = new Background(Content.Load<Texture2D>("gameBackground"), Content.Load<Texture2D>("gameBackgroundBack"), Content.Load<Texture2D>("gameBackgroundMiddle"), Content.Load<Texture2D>("gameBackgroundFront"), (200 * 32), GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); }