public void Update(GameTime gameTime) { switch (InGameNotification.isVisible) { case false: card0.Update(gameTime); card1.Update(gameTime); card2.Update(gameTime); backgroundRectangle = new Rectangle(0, 0, 360, Game1.gameHeight); topRectangle = new Rectangle(0, 0, 360, 90); if ((card0.hasBeenClicked) && (money >= 20)) { card0.hasBeenClicked = false; OnClick0(); } if ((card1.hasBeenClicked) && (money >= 30)) { card1.hasBeenClicked = false; OnClick1(); } if ((card2.hasBeenClicked) && (money >= 40)) { card2.hasBeenClicked = false; OnClick2(); } break; case true: InGameNotification.Update(gameTime); break; } _previousMouseState = _currentMouseState; _currentMouseState = Mouse.GetState(); }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Delete)) { Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.End)) { Shop.money += 10; } Debug.Print(gameState.ToString()); switch (isGamePaused) { case false: // Если игра не на паузе, то... switch (gameState) { case State.PauseMenu: pauseMenu.Update(gameTime); MediaPlayer.Pause(); musicPlayed = true; break; case State.Playing: #region HUD pauseButton.Update(gameTime); shopButton.Update(gameTime); hud.Update(gameTime, oxygenPoints); #endregion #region Обновление игровых объектов if (!gameStarted) { SpawnEritro(1); SpawnLeiko(1); SpawnTrombo(1); gameStarted = true; } for (int i = 0; i < eritroList.Count; i++) { eritroList[i].Update(gameTime, new Rectangle(100, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height + eritroList[i].boundingBox.Height /*- eritroList[i].boundingBox.Height*/, 2, 2), wallList); } for (int i = 0; i < bacteriumList.Count; i++) { bacteriumList[i].Update(gameTime, cellList, wallList); } for (int i = 0; i < leikoList.Count; i++) { leikoList[i].Update(gameTime, bacteriumList, wallList); } for (int i = 0; i < tromboList.Count; i++) { tromboList[i].Update(gameTime, wallList); } for (int i = 0; i < wallList.Count; i++) { wallList[i].Update(gameTime); } if (musicPlayed == false) { MediaPlayer.Play(music); MediaPlayer.Volume = .05f; MediaPlayer.IsRepeating = true; musicPlayed = true; } else { MediaPlayer.Resume(); } Shop.money = oxygenPoints; background.Update(gameTime); /*if (oxygenPoints == hud.oxygenBarRectangle.Width) * { * gameState = State.Victory; * }*/ if ((oxygenPoints < 20) && (eritroList.Count == 0)) { endMenu.isMusicPlayed = false; gameState = State.Defeat; } if (oxygenPoints >= hud.oxygenBarCellRectangle.Width) { endMenu.isMusicPlayed = false; gameState = State.Victory; } #endregion #region Очистка от уничтоженных объектов ClearAll(); #endregion #region Создание бактерий spawnTimer++; if (spawnTimer == 1000) { Debug.Print("Бактерия заспавнилась успешно!"); #region Training. Notification appears once. if (Bacterium.needNotification) { InGameNotification.Show("Внимание! Прорыв сосуда!", true, gameWidth / 2 - 400, gameHeight / 2 - 65); Bacterium.needNotification = !Bacterium.needNotification; } #endregion SpawnBacterium(random.Next(0, 2)); spawnTimer = 0; SoundEffect.MasterVolume = 0.5f; penetration.Play(); wallList[random.Next(2, wallList.Count)].hp = 0; } #endregion break; case State.Shop: closeShopButton.Update(gameTime); shop.Update(gameTime); break; case State.MainMenu: mainMenu.Update(gameTime); break; case State.Victory: endMenu.Update(gameTime, " Ваш организм выжил и смог \n накопить достаточно кислорода \n для завершения игры.", 1); break; case State.Defeat: endMenu.Update(gameTime, " Вы не справились с заданием. \n Ваш организм погиб.", 0); break; } break; case true: // Если игра на паузе, то.. InGameNotification.Update(gameTime); break; } #region UI MouseState CurrentMouseState = Mouse.GetState(); // Считывание текущего состояния мыши cursor.Position = new Vector2(CurrentMouseState.X, CurrentMouseState.Y); // Привязка позиции внутриигрового курсора к десктопному cursorRectangle = new Rectangle((int)cursor.Position.X, (int)cursor.Position.Y, 5, 5); #endregion base.Update(gameTime); }