/// <summary>
        /// Called when the effectowner attacked an enemy
        /// </summary>
        /// <param name="e">The event which was raised</param>
        /// <param name="sender">Sender of the event</param>
        /// <param name="args">EventArgs associated with the event</param>
        private static void AttackFinished(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = (GamePlayer)sender;

            if (e == GameLivingEvent.CastFinished)
            {
                CastingEventArgs cfea = args as CastingEventArgs;

                if (cfea.SpellHandler.Caster != player)
                {
                    return;
                }

                //cancel if the effectowner casts a non-positive spell
                if (!cfea.SpellHandler.HasPositiveEffect)
                {
                    SpeedOfSoundEffect effect = player.EffectList.GetOfType <SpeedOfSoundEffect>();
                    if (effect != null)
                    {
                        effect.Cancel(false);
                    }
                }
            }
            else if (e == GameLivingEvent.AttackFinished)
            {
                AttackFinishedEventArgs afargs = args as AttackFinishedEventArgs;
                if (afargs == null)
                {
                    return;
                }

                if (afargs.AttackData.Attacker != player)
                {
                    return;
                }

                switch (afargs.AttackData.AttackResult)
                {
                case GameLiving.eAttackResult.HitStyle:
                case GameLiving.eAttackResult.HitUnstyled:
                case GameLiving.eAttackResult.Blocked:
                case GameLiving.eAttackResult.Evaded:
                case GameLiving.eAttackResult.Fumbled:
                case GameLiving.eAttackResult.Missed:
                case GameLiving.eAttackResult.Parried:
                    SpeedOfSoundEffect effect = player.EffectList.GetOfType <SpeedOfSoundEffect>();
                    if (effect != null)
                    {
                        effect.Cancel(false);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles attacks on player/by player
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="arguments"></param>
        private void OnAttack(DOLEvent e, object sender, EventArgs arguments)
        {
            GameLiving living = sender as GameLiving;

            if (living == null)
            {
                return;
            }
            AttackedByEnemyEventArgs attackedByEnemy = arguments as AttackedByEnemyEventArgs;
            AttackFinishedEventArgs  attackFinished  = arguments as AttackFinishedEventArgs;
            CastingEventArgs         castFinished    = arguments as CastingEventArgs;
            AttackData    ad = null;
            ISpellHandler sp = null;

            if (attackedByEnemy != null)
            {
                ad = attackedByEnemy.AttackData;
            }
            else if (attackFinished != null)
            {
                ad = attackFinished.AttackData;
            }
            else if (castFinished != null)
            {
                sp = castFinished.SpellHandler;
                ad = castFinished.LastAttackData;
            }

            // Speed should drop if the player casts an offensive spell
            if (sp == null && ad == null)
            {
                return;
            }
            else if (sp == null && (ad.AttackResult != GameLiving.eAttackResult.HitStyle && ad.AttackResult != GameLiving.eAttackResult.HitUnstyled))
            {
                return;
            }
            else if (sp != null && (sp.HasPositiveEffect || ad == null))
            {
                return;
            }

            GameSpellEffect speed = SpellHandler.FindEffectOnTarget(living, this);

            if (speed != null)
            {
                speed.Cancel(false);
            }
        }
Ejemplo n.º 3
0
        private void CastingController_Canceled(CastingEventArgs obj)
        {
            if (castingController.CastingState == CastingState.CardCast)
            {
                gameState.PlayerOne.Hand.AddCard(obj.Card);
            }

            //Untap all lands used to cast the casting card
            foreach (Card card in gameState.PlayerOne.Elysium)
            {
                if (card.IsTapped && !card.IsManaDrained)
                {
                    card.IsTapped = false;
                }
            }
        }
Ejemplo n.º 4
0
        public static void FinishCastSpellCallback(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer       caster = sender as GamePlayer;
            CastingEventArgs fargs  = args as CastingEventArgs;

            if (caster == null || fargs == null)
            {
                return;
            }

            if (fargs.SpellHandler.Spell.SpellType == "Resurrect")
            {
                PlayerStatistics stats = caster.Statistics as PlayerStatistics;
                if (stats != null)
                {
                    stats.RessurectionsPerformed++;
                }
            }
        }
Ejemplo n.º 5
0
        private void CastingController_CostPaid(CastingEventArgs obj)
        {
            //Add the refunded mana to your mana pool
            gameState.PlayerOne.Mana += obj.Refund;

            if (castingController.CastingState == CastingState.CardCast)
            {
                gameState.AddStateAction(new CardCastAction(obj.Card, gameState.PlayerOne));
                gameState.ContinueGame();
                endTurnButton.Text = "End Turn";
                promptBox.Text     = string.Empty;
            }
            else if (castingController.CastingState == CastingState.Ability)
            {
                gameState.AddStateAction(new AbilityAction(obj.Card, gameState.PlayerOne, obj.Ability));
                gameState.ContinueGame();
                endTurnButton.Text = "End Turn";
                promptBox.Text     = string.Empty;
            }
        }
Ejemplo n.º 6
0
        private void Model_Casting(
            object sender,
            CastingEventArgs args)
        {
            var view = this.View as ActionView;

            if (view == null)
            {
                return;
            }

            // キャストの最大値を保存する
            this.castDurationMax =
                args.CastDurationMax - args.CastDurationCurrent;

            this.CastingRemain = this.castDurationMax;
            this.CastingProgressRateToDisplay = 0;

            // サウンド
            Task.Run(() => this.PlaySound(args.CastSkillName));

            // カウントダウン
            this.RefreshCountdown();

            // カウントダウンの開始
            this.castingStopwatch.Restart();
            if (this.countdownTimer.IsEnabled)
            {
                this.countdownTimer.Stop();
            }

            this.countdownTimer.Start();

            // アニメーション開始
            view.BeginAnimation(this.castDurationMax);

            var message =
                $"{args.Actor} starts using {args.CastSkillName}. duration={args.CastDurationMax}, id={args.CastSkillID}";

            this.logger.Info(message);
        }