Exemplo n.º 1
0
        protected override void LoadContent()
        {
            #region DoNotEdit
            spriteBatch = new SpriteBatch(GraphicsDevice);
            #endregion
            pauseMenu.LoadContent(Content);
            cursor.Texture = Content.Load <Texture2D>("Textures/UI/Cursors/cursorNormal");       // Загрузка контента для курсора
            pauseButton.LoadContent(Content);
            shopButton.LoadContent(Content);
            closeShopButton.LoadContent(Content);
            shop.LoadContent(Content);
            mainMenu.LoadContent(Content);
            for (int i = 0; i < wallList.Count; i++)
            {
                wallList[i].LoadContent(Content);
            }

            eritroTexture      = Content.Load <Texture2D>("Textures/eritro");
            leikoTexture       = Content.Load <Texture2D>("Textures/leiko");
            bacteriumTexture   = Content.Load <Texture2D>("Textures/bacterium");
            tromboTexture      = Content.Load <Texture2D>("Textures/trombo");
            _bite_soundEffect  = Content.Load <SoundEffect>("Sounds/bite");
            _death_soundEffect = Content.Load <SoundEffect>("Sounds/kill");
            background.LoadContent(Content);
            music       = Content.Load <Song>("Sounds/music1");
            penetration = Content.Load <SoundEffect>("Sounds/Penetration");

            endMenu.LoadContent(Content);

            hud.LoadContent(Content);

            InGameNotification.LoadContent(Content);        //  Внутриигровые уведомления (например недостаточно денег)
        }
Exemplo n.º 2
0
 public void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(backgound, backgroundRectangle, Color.White);
     card0.Draw(spriteBatch);
     card1.Draw(spriteBatch);
     card2.Draw(spriteBatch);
     spriteBatch.Draw(topTexture, topRectangle, Color.White);
     spriteBatch.DrawString(fontBold, "Магазин", new Vector2(10, 4), Color.Black);
     spriteBatch.DrawString(fontRegular, "У вас: " + money + "R", new Vector2(12, 48), Color.Black);
     InGameNotification.Draw(spriteBatch);
 }
Exemplo n.º 3
0
 public void LoadContent(ContentManager Content)
 {
     backgound  = Content.Load <Texture2D>("Textures/UI/background");
     topTexture = Content.Load <Texture2D>("Textures/UI/top");
     card0.LoadContent(Content);
     card1.LoadContent(Content);
     card2.LoadContent(Content);
     InGameNotification.LoadContent(Content);
     #region Fonts
     fontRegular = Content.Load <SpriteFont>("Fonts/regular");
     fontBold    = Content.Load <SpriteFont>("Fonts/bold");
     #endregion
     _currentMouseState  = Mouse.GetState();
     _previousMouseState = _currentMouseState;
 }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
 void showNotification()
 {
     InGameNotification.Show("У вас недостаточно денег", true, Game1.gameWidth / 2 - 400,
                             Game1.gameHeight / 2 - 65);     //  КОСТЫЛЬ
     InGameNotification.isVisible = true;
 }
Exemplo n.º 6
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(new Color(123, 17, 17));
            spriteBatch.Begin();
            {
                switch (gameState)
                {
                case State.PauseMenu:
                    background.Draw(spriteBatch);
                    for (int i = 0; i < cellList.Count; i++)
                    {
                        cellList[i].Draw(spriteBatch);
                    }

                    for (int i = 0; i < bacteriumList.Count; i++)
                    {
                        bacteriumList[i].Draw(spriteBatch);
                    }

                    for (int i = 0; i < leikoList.Count; i++)
                    {
                        leikoList[i].Draw(spriteBatch);
                    }
                    for (int i = 0; i < wallList.Count; i++)
                    {
                        wallList[i].Draw(spriteBatch);
                    }
                    for (int i = 0; i < tromboList.Count; i++)
                    {
                        tromboList[i].Draw(spriteBatch);
                    }

                    pauseMenu.Draw(spriteBatch);
                    break;

                case State.Playing:
                    background.Draw(spriteBatch);
                    for (int i = 0; i < cellList.Count; i++)
                    {
                        cellList[i].Draw(spriteBatch);
                    }

                    for (int i = 0; i < bacteriumList.Count; i++)
                    {
                        bacteriumList[i].Draw(spriteBatch);
                    }

                    for (int i = 0; i < leikoList.Count; i++)
                    {
                        leikoList[i].Draw(spriteBatch);
                    }
                    for (int i = 0; i < wallList.Count; i++)
                    {
                        wallList[i].Draw(spriteBatch);
                    }
                    for (int i = 0; i < tromboList.Count; i++)
                    {
                        tromboList[i].Draw(spriteBatch);
                    }

                    hud.Draw(spriteBatch);
                    shopButton.Draw(spriteBatch);
                    pauseButton.Draw(spriteBatch);

                    ClearAll();
                    break;

                case State.Shop:
                    background.Draw(spriteBatch);
                    for (int i = 0; i < cellList.Count; i++)
                    {
                        cellList[i].Draw(spriteBatch);
                    }

                    for (int i = 0; i < bacteriumList.Count; i++)
                    {
                        bacteriumList[i].Draw(spriteBatch);
                    }

                    for (int i = 0; i < leikoList.Count; i++)
                    {
                        leikoList[i].Draw(spriteBatch);
                    }
                    for (int i = 0; i < wallList.Count; i++)
                    {
                        wallList[i].Draw(spriteBatch);
                    }
                    for (int i = 0; i < tromboList.Count; i++)
                    {
                        tromboList[i].Draw(spriteBatch);
                    }

                    shop.Draw(spriteBatch);
                    closeShopButton.Draw(spriteBatch);
                    break;

                case State.MainMenu:
                    mainMenu.Draw(spriteBatch);
                    break;

                case State.Defeat:
                    endMenu.Draw(spriteBatch);
                    break;

                case State.Victory:
                    endMenu.Draw(spriteBatch);
                    break;
                }
                InGameNotification.Draw(spriteBatch); //  Отрисовка уведомлений
                cursor.Draw(spriteBatch);             // Отрисовка курсора
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemplo n.º 7
0
        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);
        }