/// <summary>
        /// Starts a new combat stage.  Called right after the stage changes.
        /// </summary>
        /// <remarks>The stage never changes into NotStarted.</remarks>
        protected override void StartStage()
        {
            switch (stage)
            {
            case CombatActionStage.Preparing:     // called from Start()
            {
                // play the animations
                combatant.CombatSprite.PlayAnimation("ItemCast");
                itemSpritePosition = Combatant.Position;
                item.SpellSprite.PlayAnimation("Creation");
                Session.Party.RemoveFromInventory(item, 1);
            }
            break;

            case CombatActionStage.Advancing:
            {
                // play the animations
                item.SpellSprite.PlayAnimation("Traveling");
                // calculate the projectile destination
                projectileDirection = Target.Position -
                                      Combatant.OriginalPosition;
                totalProjectileDistance = projectileDirection.Length();
                projectileDirection.Normalize();
                projectileDistanceCovered = 0f;
                // determine if the projectile is flipped
                if (Target.Position.X > Combatant.Position.X)
                {
                    projectileSpriteEffect = SpriteEffects.FlipHorizontally;
                }
                else
                {
                    projectileSpriteEffect = SpriteEffects.None;
                }
                // get the projectile's cue and play it
                projectileCue = AudioManager.GetCue(item.TravelingCueName);
                if (projectileCue != null)
                {
                    projectileCue.Play();
                }
            }
            break;

            case CombatActionStage.Executing:
                // play the animation
                item.SpellSprite.PlayAnimation("Impact");
                // stop the projectile sound effect
                if (projectileCue != null)
                {
                    projectileCue.Stop(AudioStopOptions.Immediate);
                }
                // apply the item effect to the primary target
                bool damagedAnyone = ApplyItem(Target);
                // apply the item effect to the secondary targets
                foreach (Combatant targetCombatant in
                         CombatEngine.SecondaryTargetedCombatants)
                {
                    // skip any dead or dying combatants
                    if (targetCombatant.IsDeadOrDying)
                    {
                        continue;
                    }
                    // apply the effect
                    damagedAnyone |= ApplyItem(targetCombatant);
                }
                // play the impact sound effect
                if (damagedAnyone)
                {
                    AudioManager.PlayCue(item.ImpactCueName);
                    if (item.Overlay != null)
                    {
                        item.Overlay.PlayAnimation(0);
                        item.Overlay.ResetAnimation();
                    }
                }

                break;

            case CombatActionStage.Returning:
                // play the animation
                combatant.CombatSprite.PlayAnimation("Idle");
                break;

            case CombatActionStage.Finishing:
                // play the animation
                combatant.CombatSprite.PlayAnimation("Idle");
                break;

            case CombatActionStage.Complete:
                // play the animation
                combatant.CombatSprite.PlayAnimation("Idle");
                break;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initialize the static AudioManager functionality.
 /// </summary>
 /// <param name="game">The game that this component will be attached to.</param>
 /// <param name="settingsFile">The filename of the XACT settings file.</param>
 /// <param name="waveBankFile">The filename of the XACT wavebank file.</param>
 /// <param name="soundBankFile">The filename of the XACT soundbank file.</param>
 public static void Initialize(Game game, string settingsFile,
     string waveBankFile, string soundBankFile)
 {
     audioManager = new AudioManager(game, settingsFile, waveBankFile,
         soundBankFile);
     if (game != null)
     {
         game.Components.Add(audioManager);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        public override void HandleInput()
        {
            bool stayClicked  = false;
            bool leaveClicked = false;

            if (InputManager.IsButtonClicked(new Rectangle((int)stayPosition.X, (int)stayPosition.Y,
                                                           120, 40)))
            {
                int partyCharge = GetChargeForParty(Session.Party);
                if (Session.Party.PartyGold >= partyCharge)
                {
                    AudioManager.PlayCue("Money");
                    Session.Party.PartyGold -= partyCharge;
                    selectionMark            = 2;
                    ChangeDialogue(serviceRenderedMessage);
                    HealParty(Session.Party);
                }
                else
                {
                    selectionMark = 2;
                    ChangeDialogue(noGoldMessage);
                }
            }

            if (InputManager.IsButtonClicked(new Rectangle((int)leavePosition.X, (int)leavePosition.Y,
                                                           120, 40)))
            {
                ExitScreen();
            }
            // exit the screen
            if (InputManager.IsActionTriggered(InputManager.Action.Back))
            {
                ExitScreen();
                return;
            }
            // move the cursor up
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp) || stayClicked)
            {
                if (selectionMark == 2)
                {
                    selectionMark = 1;
                }
            }
            // move the cursor down
            else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown) || leaveClicked)
            {
                if (selectionMark == 1)
                {
                    selectionMark = 2;
                }
            }
            // select an option
            else if (InputManager.IsActionTriggered(InputManager.Action.Ok))
            {
                if (selectionMark == 1)
                {
                    int partyCharge = GetChargeForParty(Session.Party);
                    if (Session.Party.PartyGold >= partyCharge)
                    {
                        AudioManager.PlayCue("Money");
                        Session.Party.PartyGold -= partyCharge;
                        selectionMark            = 2;
                        ChangeDialogue(serviceRenderedMessage);
                        HealParty(Session.Party);
                    }
                    else
                    {
                        selectionMark = 2;
                        ChangeDialogue(noGoldMessage);
                    }
                }
                else
                {
                    ExitScreen();
                    return;
                }
            }
        }