private void setSOrigin() { score_origin = FontDis.MeasureString(score.ToString()); score_origin = new Vector2(score_origin.X / 2, score_origin.Y / 2); score_str_pos = new Vector2(counterPos[1].X + 96, counterPos[1].Y + 94); score_str_pos2 = new Vector2(counterPos[1].X + 97, counterPos[1].Y + 95); }
protected override void LoadContent() { // music songList.Add(Content.Load <Song>("music/theStorm")); // main menu songList.Add(Content.Load <Song>("music/newGame")); // random ingame music songList.Add(Content.Load <Song>("music/crush")); playingIngameMusic = false; MediaPlayer.Volume = volBGM; MediaPlayer.IsRepeating = true; MediaPlayer.Play(songList[0]); // sounds buttonSounds.Add(Content.Load <SoundEffect>("sound/movingTray")); buttonSounds.Add(Content.Load <SoundEffect>("sound/click")); table_tap = Content.Load <SoundEffect>("sound/tock"); cookie_crumble = Content.Load <SoundEffect>("sound/crumble"); SoundEffect.MasterVolume = volSFX; spriteBatch = new SpriteBatch(GraphicsDevice); // textures filter_Black = new Texture2D(GraphicsDevice, (int)screen.X, (int)screen.Y); sliderBase = Content.Load <Texture2D>("img/slider"); counterTextures.Add(Content.Load <Texture2D>("img/clock")); counterTextures.Add(Content.Load <Texture2D>("img/score")); backroundTextures.Add(Content.Load <Texture2D>("img/background")); // order defines value of points cookieTextures.Add(Content.Load <Texture2D>("cookies/cookie_base")); cookieTextures.Add(Content.Load <Texture2D>("cookies/cookie_cream")); cookieTextures.Add(Content.Load <Texture2D>("cookies/cookie_sprinkles")); cookieTextures.Add(Content.Load <Texture2D>("cookies/cookie_choc")); cookieTextures.Add(Content.Load <Texture2D>("cookies/cookie_nuts")); cookieTextures.Add(Content.Load <Texture2D>("cookies/cookie_cherry")); cookieTextures.Add(Content.Load <Texture2D>("cookies/cookie_strawberrycream")); //decorationTextures.Add(Content.Load<Texture2D>("img/vase")); particleTextures.Add(Content.Load <Texture2D>("particle/diamant")); particleTextures.Add(Content.Load <Texture2D>("particle/kreis")); particleTextures.Add(Content.Load <Texture2D>("particle/stern")); Particles = new ParticleEngine(particleTextures); buttonTextures.Add(Content.Load <Texture2D>("img/button_tray")); buttonTextures.Add(Content.Load <Texture2D>("img/button")); buttonTextures.Add(Content.Load <Texture2D>("img/button_hover")); pointerTextures.Add(Content.Load <Texture2D>("img/pointer_idle")); pointerTextures.Add(Content.Load <Texture2D>("img/pointer_click")); // fonts FontDis = Content.Load <SpriteFont>("font/FontDisplay"); FontInfo = Content.Load <SpriteFont>("font/FontInfo"); FontMsg = Content.Load <SpriteFont>("font/FontMsg"); FontBtn = Content.Load <SpriteFont>("font/FontBtn"); // load / initialize other content.. curBackground = rng.Next(0, backroundTextures.Count); counterPos.Add(new Vector2(0, 0)); counterPos.Add(new Vector2(screen.X - counterTextures[1].Width, 0)); // timer and string origin / position setSOrigin(); for (int i = 0; i < counterTextures.Count; i++) { rect_counterList.Add(new Rectangle((int)counterPos[i].X, (int)counterPos[i].Y, counterTextures[i].Width, counterTextures[i].Height)); } for (int i = 0; i < Cookies.Length; i++) { Cookies[i] = new Cookie(rect_counterList, cookieTextures, screen, rng); } for (int i = 0; i < btn_pos.Length - 3; i++) { multiplier = i >= 1 ? 2 : 1; btn_pos[i] = new Vector2(btn_offset.X, (buttonTextures[1].Height * i) + btn_offset.Y * multiplier); buttons.Add(new Button(buttonTextures, btn_pos[i], FontBtn, btn_str[i], i)); } // Quit btn_pos[btn_pos.Length - 3] = new Vector2(btn_offset.X, screen.Y - buttonTextures[1].Height - btn_offset.Y); buttons.Add(new Button(buttonTextures, btn_pos[btn_pos.Length - 3], FontBtn, btn_str[btn_pos.Length - 3], (int)gameState.quit)); // credits btn_pos[btn_pos.Length - 2] = new Vector2(screen.X - buttonTextures[1].Width - btn_offset.X, screen.Y - buttonTextures[1].Height - btn_offset.Y); buttons.Add(new Button(buttonTextures, btn_pos[btn_pos.Length - 2], FontBtn, btn_str[btn_pos.Length - 2], (int)gameState.credits)); // back button btn_pos[btn_pos.Length - 1] = new Vector2(btn_offset.X, screen.Y - buttonTextures[1].Height - btn_offset.Y); buttons.Add(new Button(buttonTextures, btn_pos[btn_pos.Length - 1], FontBtn, btn_str[btn_pos.Length - 1], (int)gameState.back)); slider.Add(new Slider(sliderBase, cookieTextures, new Vector2(btn_offset.X + 25, btn_offset.Y + 125), FontBtn, "Volume Music", volBGM, rng)); slider.Add(new Slider(sliderBase, cookieTextures, new Vector2(btn_offset.X + 25, btn_offset.Y + 225), FontBtn, "Volume Sound", volSFX, rng)); checkBox.Add(new CheckBox(cookieTextures, new Vector2(btn_offset.X + 25, btn_offset.Y + 325), FontBtn, "Mute BGM", rng)); checkBox.Add(new CheckBox(cookieTextures, new Vector2(btn_offset.X + 25, btn_offset.Y + 425), FontBtn, "Mute SFX", rng)); str_score = str_score_pre + score.ToString(); score_pos = FontInfo.MeasureString(str_score); score_pos = new Vector2((screen.X / 2) - (score_pos.X / 2), (screen.Y / 2) - (score_pos.Y / 2)); str_pos_bl = new Vector2(50, screen.Y - 225); timer_origin = FontDis.MeasureString(timer.ToString()); timer_origin = new Vector2(timer_origin.X / 2, timer_origin.Y / 2); timer_str_pos[0] = new Vector2(counterPos[0].X + 74, counterPos[0].Y + 110); timer_str_pos[1] = new Vector2(counterPos[0].X + 86, counterPos[0].Y + 107); timer_str_pos[2] = new Vector2(counterPos[0].X + 98, counterPos[0].Y + 104); curTPos = 0; pauseStrSize = FontMsg.MeasureString(str_pause); pause_pos = new Vector2((screen.X / 2) - (pauseStrSize.X / 2), (screen.Y / 2) - (pauseStrSize.Y / 2)); cancelStrSize = FontMsg.MeasureString(str_pause); cancel_pos = new Vector2((screen.X / 2) - (cancelStrSize.X), (screen.Y / 2) - (cancelStrSize.Y / 2)); cookies_pos = new Vector2(15, screen.Y - 35); }