示例#1
0
        public void Update(GameTime gameTime, ref Battle battle)
        {
            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (remainingDisplayTime > 0.0f)
            {
                remainingDisplayTime -= dt;
            }

            if (remainingDisplayTime <= 0.0f && messageQueue.size() > 0)
            {
                currentMessage = messageQueue.dequeue();
                remainingDisplayTime = messageDisplayTime;
            }
            if (endTurnButton.Contains(InputManager.MousePos))
            {
                if (InputManager.MouseHeld())
                {
                    endTurnButtonColor = Color.Crimson;

                }
                else if (InputManager.MouseReleased())
                {
                    // Switches player's turn number after the End Turn button has been pressed
                    battle.CurrentPlayer.ChangeTurnConditions();

                }
                else endTurnButtonColor = Color.DarkSlateBlue;
            }
            else endTurnButtonColor = Color.BlueViolet;
        }
示例#2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // VOLUME CONTROL (with plus and minus keys next to backspace)
            if (InputManager.KeyReady(Keys.OemPlus) && creditsSongInstance.Volume < 1)
            {
                if (creditsSongInstance.Volume + .1f < 1)
                    creditsSongInstance.Volume += .1f;
                else creditsSongInstance.Volume = 1f;
                if (battleSongInstance.Volume + .1f < 1)
                    battleSongInstance.Volume += .1f;
                else battleSongInstance.Volume = 1f;
            }
            if (InputManager.KeyReady(Keys.OemMinus) && creditsSongInstance.Volume > 0)
            {
                if (creditsSongInstance.Volume - .1f > 0)
                    creditsSongInstance.Volume -= .1f;
                else creditsSongInstance.Volume = 0f;
                if (battleSongInstance.Volume - .1f > 0)
                    battleSongInstance.Volume -= .1f;
                else battleSongInstance.Volume = 0f;
            }

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            if (menus.Count > 0) // if there's a menu
            {
                currMenu = menus.Peek();
                if (currMenu is ScenarioMenu)
                {
                    selectedScenario = (currMenu as ScenarioMenu).Update(this);
                    if (selectedScenario != null)
                    {
                        battle = new Battle(this, selectedScenario);
                        if (!Components.Contains(camera))
                            Components.Add(camera); // Add camera to the components to be updated when base.update is called
                        camera.ResetPosition();
                    }
                }
                else
                {
                    currMenu.Update();
                }

                if (battleSongInstance.State == SoundState.Playing)
                    battleSongInstance.Stop();
            }
            else
            {
                ///  Toggle battle music on/off with the "M" key!!!!
                if (battleSongInstance.State == SoundState.Playing)
                {
                    if (InputManager.KeyReady(Keys.M))
                    {
                        battleSongInstance.Pause();
                    }
                }
                else if (battleSongInstance.State == SoundState.Paused)
                {
                    if (InputManager.KeyReady(Keys.M))
                    {
                        battleSongInstance.Resume();
                    }
                }
                else if (battleSongInstance.State == SoundState.Stopped)
                {
                    if (InputManager.KeyReady(Keys.M))
                    {
                        battleSongInstance.Play();
                    }
                }

                battle.Update(this);
                //if (Components.Contains(camera)) Components.Remove(camera);
                infoBar.Update();
                updateBox.Update(gameTime, ref battle);
            }
            InputManager.Update(gameTime);

            if (exiting == true)
            {
                Exit();
            }

            base.Update(gameTime);
        }
示例#3
0
        /// <summary>
        /// Draws the update box and its content
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <param name="targetUnit"></param>
        /// <param name="battle">***PLEASE leave this here for future use: I will be using it to check whose turn it is (playerTurn is in Battle.cs) for the ENDTURN button once AI has been implemented.</param>
        public void Draw(SpriteBatch spriteBatch, Battle battle)
        {
            if (!HasNewMessage)
            {
                spriteBatch.Draw(white, updateBoxFrame, Color.Black);
                spriteBatch.Draw(white, updateBox, Color.White);

                if (targetUnit != null)
                {
                    spriteBatch.DrawString(updateBoxFont, "Army: " + (targetUnit.Army), new Vector2(updateBox.X + 30, updateBox.Y + 5), Color.Black);

                    // The text in the Update Box
                    spriteBatch.DrawString(updateBoxFont, "Level: " + targetUnit.Level, new Vector2(updateBox.X + 10, updateBox.Y + 30), Color.Black);
                    spriteBatch.DrawString(updateBoxFont, "Health: " + targetUnit.Health + " / " + targetUnit.MaxHealth, new Vector2(updateBox.X + 10, updateBox.Y + 45), Color.Black);
                    spriteBatch.DrawString(updateBoxFont, "Attack: " + targetUnit.Attack, new Vector2(updateBox.X + 10, updateBox.Y + 60), Color.Black);
                    spriteBatch.DrawString(updateBoxFont, "Defense: " + targetUnit.Defense, new Vector2(updateBox.X + 10, updateBox.Y + 75), Color.Black);
                }
            }

            // The text in the End Turn button
            spriteBatch.Draw(white, endTurnButton, null, endTurnButtonColor, 0f, Vector2.Zero, SpriteEffects.None, 0f);
            spriteBatch.DrawString(updateBoxFont, "END TURN", new Vector2(endTurnButton.X + 36, endTurnButton.Y + 3), Color.GhostWhite);
        }