コード例 #1
0
        protected Attack(AttackData data, T parent)
        {
            this.data = data;

            Parent = parent;
            timer  = new SingleTimer(t =>
            {
                if (ShouldAdvance(phase))
                {
                    AdvancePhase();
                }
                else
                {
                    isWaitingOnPhase = true;
                }
            });

            phase      = AttackPhases.Idle;
            phaseTicks = new Action <float>[]
            {
                WhilePreparing,
                WhileExecuting,
                WhileCooling,
                WhileResetting
            };
        }
コード例 #2
0
        private void AdvancePhase()
        {
            int phaseIndex;

            do
            {
                phase      = (AttackPhases)(((int)phase + 1) % 5);
                phaseIndex = (int)phase - 1;
            }
            // A phase is considered disabled if its duration is zero.
            while (phase != AttackPhases.Idle && data.Durations[phaseIndex] == 0);

            if (phase == AttackPhases.Complete)
            {
                return;
            }

            timer.Duration = data.Durations[phaseIndex];
            timer.Tick     = phaseTicks[phaseIndex];
            timer.IsPaused = false;

            switch (phase)
            {
            case AttackPhases.Prepare:
                OnPrepare();
                break;

            case AttackPhases.Execute:
                OnExecute();
                break;

            case AttackPhases.Cooldown:
                OnCooldown();
                break;

            case AttackPhases.Reset:
                OnReset();
                break;
            }
        }
コード例 #3
0
ファイル: BowShot.cs プロジェクト: LaserYGD/Zeldo-CSharp
 protected override bool ShouldAdvance(AttackPhases phase)
 {
     return(phase != AttackPhases.Prepare || ShouldRelease);
 }
コード例 #4
0
 public virtual void Cancel()
 {
     phase = AttackPhases.Complete;
 }
コード例 #5
0
 // This is useful when certain phases need to be stalled while waiting for another event to occur (e.g. once
 // the bow is drawn, an attack isn't executed until the button is released).
 protected virtual bool ShouldAdvance(AttackPhases phase)
 {
     return(true);
 }