Пример #1
0
        private void CheckAbilityQueue()
        {
            _abilityMutex.WaitOne();

            // If the current ability is done, clear it
            if (_abilityThread != null && !_abilityThread.IsAlive)
            {
#if DEBUG
                Console.WriteLine("Killing action:");
                Console.WriteLine(_activeAbility.ToString());
#endif
                if (_activeAbility.Performer is Ally)
                {
                    _lastPartyAction = (AbilityState)_activeAbility.Clone();
                }
                _activeAbility.Performer.Ability.Reset();
                _activeAbility = null;
                _abilityThread = null;
            }
            // Dequeue next ability if none is in progress
            if (_abilityThread == null && _abilityQueue.Count > 0)
            {
                _activeAbility = _abilityQueue.Dequeue();
                _abilityThread = new Thread(new ThreadStart(_activeAbility.DoAction));
                _abilityThread.Start();
            }

            _abilityMutex.ReleaseMutex();
        }
Пример #2
0
        public void ActOnSelection()
        {
            ICombatant target;
            Ally       performer = Game.Battle.Commanding;

            #region Attack
            if (_option == _attackOption)
            {
                target = TargetSelector.Instance.Selected[0];

                int bd  = Formula.PhysicalBase(Game.Battle.Commanding);
                int dam = Formula.PhysicalDamage(bd, 16, target);

                AbilityState state = Game.Battle.Commanding.Ability;
                state.LongRange   = performer.LongRange;
                state.QuadraMagic = false;
                state.Type        = AttackType.Physical;
                state.Performer   = performer;
                state.Target      = TargetSelector.Instance.Selected;
                state.Action     += delegate() { target.AcceptDamage(Game.Battle.ActiveAbility.Performer, dam); };
            }
            #endregion Attack
            #region 2x-Cut
            else if (_option == _doubleCutOption2)
            {
                target = TargetSelector.Instance.Selected[0];

                int bd  = Formula.PhysicalBase(Game.Battle.Commanding);
                int dam = Formula.PhysicalDamage(bd, 16, target);

                AbilityState state = Game.Battle.Commanding.Ability;
                state.LongRange   = performer.LongRange;
                state.QuadraMagic = false;
                state.Type        = AttackType.Physical;
                state.Performer   = performer;
                state.Target      = TargetSelector.Instance.Selected;
                state.Action     += delegate() { target.AcceptDamage(Game.Battle.ActiveAbility.Performer, dam); };

                Game.Battle.EnqueueAction((AbilityState)state.Clone());
                Game.Battle.EnqueueAction((AbilityState)state.Clone());

                // Here we must disable the action hook, because we do not the second state
                //  to be attached to Ally.Ability. If it were, when the first one is disposed of
                //  it will reset the second one. See BattleState.CheckAbilityQueue()
                Selector.DisableActionHook(true);
            }
            #endregion 2x-Cut
            #region 4x-Cut
            else if (_option == _doubleCutOption4)
            {
                target = TargetSelector.Instance.Selected[0];

                int bd  = Formula.PhysicalBase(Game.Battle.Commanding);
                int dam = Formula.PhysicalDamage(bd, 16, target);

                AbilityState state = Game.Battle.Commanding.Ability;
                state.LongRange   = performer.LongRange;
                state.QuadraMagic = false;
                state.Type        = AttackType.Physical;
                state.Performer   = performer;
                state.Target      = TargetSelector.Instance.Selected;
                state.Action     += delegate() { target.AcceptDamage(Game.Battle.ActiveAbility.Performer, dam); };

                Game.Battle.EnqueueAction((AbilityState)state.Clone());
                Game.Battle.EnqueueAction((AbilityState)state.Clone());
                Game.Battle.EnqueueAction((AbilityState)state.Clone());
                Game.Battle.EnqueueAction((AbilityState)state.Clone());

                // Here we must disable the action hook, because we do not the first three states
                //  to be attached to Ally.Ability. If it were, when the first one is disposed of
                //  it will reset the others. See BattleState.CheckAbilityQueue()
                Selector.DisableActionHook(true);
            }
            #endregion 4x-Cut
            #region Sense
            else if (_option == _senseOption)
            {
                target = TargetSelector.Instance.Selected[0];

                AbilityState state = Game.Battle.Commanding.Ability;
                state.Performer = performer;
                state.Target    = new ICombatant[1];
                state.Target[0] = target;
                state.Action   += delegate() { target.Sense(); };
            }
            #endregion Sense
            #region Mime
            else if (_option == _mimeOption)
            {
                if (Game.Battle.LastPartyAbility == null)
                {
                    Selector.DisableActionHook(true);
                    Game.Battle.Commanding.TurnTimer.Reset();
                }
                else
                {
                    Game.Battle.Commanding.Ability = Game.Battle.LastPartyAbility;
                    try
                    {
                        Game.Battle.Commanding.Ability.Performer = performer;
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            #endregion Mime
            #region Deathblow
            else if (_option == _deathblowOption)
            {
                target = TargetSelector.Instance.Selected[0];

                int bd  = Formula.PhysicalBase(Game.Battle.Commanding);
                int dam = Formula.PhysicalDamage(bd, 16, target) * 2;

                AbilityState state = Game.Battle.Commanding.Ability;
                state.LongRange   = performer.LongRange;
                state.QuadraMagic = false;
                state.Type        = AttackType.Physical;
                state.Performer   = performer;
                state.Target      = TargetSelector.Instance.Selected;
                state.Action     += delegate() { target.AcceptDamage(Game.Battle.ActiveAbility.Performer, dam); };
            }
            #endregion Deathblow
            #region Steal
            else if (_option == _stealOption)
            {
                target = TargetSelector.Instance.Selected[0];

                AbilityState state = Game.Battle.Commanding.Ability;
                state.Type      = AttackType.Physical;
                state.Performer = performer;
                state.Target    = TargetSelector.Instance.Selected;
                state.Action   += delegate() { ((Enemy)target).StealItem(performer); };
            }
            #endregion Steal
            #region Mug
            else if (_option == _mugOption)
            {
                target = TargetSelector.Instance.Selected[0];

                int bd  = Formula.PhysicalBase(Game.Battle.Commanding);
                int dam = Formula.PhysicalDamage(bd, 16, target);

                AbilityState state = Game.Battle.Commanding.Ability;
                state.Type      = AttackType.Physical;
                state.Performer = performer;
                state.Target    = TargetSelector.Instance.Selected;
                state.Action   += delegate()
                {
                    target.AcceptDamage(Game.Battle.ActiveAbility.Performer, dam);
                    ((Enemy)target).StealItem(performer);
                };
            }
            #endregion Mug
        }