/// <summary>
        /// Cancels the ability channeling for the current spell,
        /// reseting the ElapsedCasting timer and setting the casting spell to null
        /// </summary>
        public virtual void CancelChanneling()
        {
            _casting.OnChannelingCanceled(_dataHub);
            _casting = null;

            _elapsedChanneling = 0f;
            _castingState      = CastingState.None;
        }
Exemplo n.º 2
0
 public void changeState(CastingState newState)
 {
     state = newState;
     if (newState == CastingState.isTargeting)
     {
         canCast = true;
     }
 }
        /// <summary>
        /// Helper method to cast the ability after it is ready to be cast
        /// </summary>
        protected void UnleashAbility()
        {
            _castingState = CastingState.Casting;

            _casting.OnChannelingCompleted(_dataHub);
            _casting.CurrentCooldown = _casting.Cooldown;
            _casting.Cast(_dataHub, FinishAbilityCasting);

            _elapsedChanneling = 0f;
        }
Exemplo n.º 4
0
        public void StageCard(Card card)
        {
            stagedCard   = card;
            castingState = CastingState.CardCast;

            currentCost = new Cost(card);

            if (costPaid())
            {
                finishCasting();
            }
        }
Exemplo n.º 5
0
        public void StageAbility(Card card, Ability ability)
        {
            stagedCard    = card;
            stagedAbility = ability;
            castingState  = CastingState.Ability;

            currentCost = new Cost(ability);

            if (costPaid())
            {
                finishCasting();
            }
        }
Exemplo n.º 6
0
    void Awake()
    {
        damageReceived = 0;

        movingState   = new MovingState(this);
        rotatingState = new RotatingState(this);
        castingState  = new CastingState(this);
        stunnedState  = new StunnedState(this);
        deadState     = new DeadState(this);

        movingState.AddPauser(castingState);
        movingState.AddPauser(stunnedState);
        movingState.AddBlocker(deadState);

        rotatingState.AddPauser(stunnedState);
        rotatingState.AddBlocker(deadState);

        castingState.AddBlocker(stunnedState);
        castingState.AddBlocker(deadState);

        stunnedState.AddBlocker(deadState);

        actionStates = new List <ActionState>();
        actionStates.Add(movingState);
        actionStates.Add(rotatingState);
        actionStates.Add(castingState);
        actionStates.Add(stunnedState);
        actionStates.Add(deadState);

        if (skills == null)
        {
            skills = new List <Skill>();
        }

        if (perks == null)
        {
            perks = new List <Perk>();
        }

        graphics = gameObject.AddComponent <UnitGraphics>();

        if (activeController == null)
        {
            activeController = gameObject.GetComponent <UnitController>();
        }

        if (unitData == null)
        {
            unitData = new UnitData();
        }
    }
        /// <summary>
        /// Starts channeling the ability in the given slot
        /// If the channeling time is 0, the ability is unleashed
        /// instantly
        /// </summary>
        /// <param name="slot">The ability slot index</param>
        public virtual void StartChanneling(uint slot)
        {
            if (HasAbilityInSlot(slot) && !IsAbilityOnCd(slot) && _casting == null)
            {
                _casting = _abilities[slot];
                _casting.OnChannelingStarted(_dataHub);
                _castingState = CastingState.Channeling;

                // If the cast time for the spell is zero,
                // just cast it instantly
                if (_casting.ChannelingTime == 0f)
                {
                    UnleashAbility();
                }
            }
        }
 /// <summary>
 /// Finishes casting the current ability, setting the Casted Ability to null and
 /// the casting state to None
 /// </summary>
 public void FinishAbilityCasting()
 {
     _castingState = CastingState.None;
     _casting      = null;
 }
Exemplo n.º 9
0
        public void UpdateGraph(CalculationOptionsMage calculationOptions)
        {
            DisplayCalculations calculations = calculationOptions.Calculations;

            Chart.Series.Clear();
            Chart.Axes.Clear();

            Chart.Text = null;

            if (calculationOptions.SequenceReconstruction == null)
            {
                Chart.Text = "Sequence reconstruction data is not available.";
            }
            else
            {
                List <EffectCooldown> cooldownList = calculationOptions.Calculations.CooldownList;

                /*brushSubPoints = new Brush[cooldownList.Count];
                 * colorSubPointsA = new Color[cooldownList.Count];
                 * colorSubPointsB = new Color[cooldownList.Count];
                 * for (int i = 0; i < cooldownList.Count; i++)
                 * {
                 *  Color baseColor = cooldownList[i].Color;
                 *  brushSubPoints[i] = new SolidBrush(Color.FromArgb(baseColor.R / 2, baseColor.G / 2, baseColor.B / 2));
                 *  colorSubPointsA[i] = Color.FromArgb(baseColor.A / 2, baseColor.R / 2, baseColor.G / 2, baseColor.B / 2);
                 *  colorSubPointsB[i] = Color.FromArgb(baseColor.A / 2, baseColor);
                 * }
                 * StringFormat formatSubPoint = new StringFormat();
                 * formatSubPoint.Alignment = StringAlignment.Center;
                 * formatSubPoint.LineAlignment = StringAlignment.Center;
                 *
                 * int maxWidth = 1;
                 * for (int i = 0; i < cooldownList.Count; i++)
                 * {
                 *  string subPointName = cooldownList[i].Name;
                 *  int widthSubPoint = (int)Math.Ceiling(g.MeasureString(subPointName, fontLegend).Width + 2f);
                 *  if (widthSubPoint > maxWidth) maxWidth = widthSubPoint;
                 * }
                 * for (int i = 0; i < cooldownList.Count; i++)
                 * {
                 *  string cooldownName = cooldownList[i].Name;
                 *  rectSubPoint = new Rectangle(2, legendY, maxWidth, 16);
                 *  blendSubPoint = new System.Drawing.Drawing2D.ColorBlend(3);
                 *  blendSubPoint.Colors = new Color[] { colorSubPointsA[i], colorSubPointsB[i], colorSubPointsA[i] };
                 *  blendSubPoint.Positions = new float[] { 0f, 0.5f, 1f };
                 *  brushSubPointFill = new System.Drawing.Drawing2D.LinearGradientBrush(rectSubPoint, colorSubPointsA[i], colorSubPointsB[i], 67f);
                 *  brushSubPointFill.InterpolationColors = blendSubPoint;
                 *
                 *  g.FillRectangle(brushSubPointFill, rectSubPoint);
                 *  g.DrawRectangle(new Pen(brushSubPointFill), rectSubPoint);
                 *  g.DrawRectangle(new Pen(brushSubPointFill), rectSubPoint);
                 *  g.DrawRectangle(new Pen(brushSubPointFill), rectSubPoint);
                 *
                 *  g.DrawString(cooldownName, fontLegend, brushSubPoints[i], rectSubPoint, formatSubPoint);
                 *  legendY += 16;
                 * }*/

                if (calculationOptions.AdviseAdvancedSolver)
                {
                    Chart.Text = "Sequence Reconstruction was not fully successful, it is recommended that you enable more options in advanced solver (segment cooldowns, integral mana consumables, advanced constraints options)!";
                }

                /*g.DrawLine(Pens.Aqua, new Point(maxWidth + 40, 10), new Point(maxWidth + 80, 10));
                 * g.DrawString("Mana", fontLegend, Brushes.Black, new Point(maxWidth + 90, 2));
                 * g.DrawLine(Pens.Red, new Point(maxWidth + 40, 26), new Point(maxWidth + 80, 26));
                 * g.DrawString("Dps", fontLegend, Brushes.Black, new Point(maxWidth + 90, 18));*/

                List <SequenceItem> sequence = calculationOptions.SequenceReconstruction.sequence;

                List <TimeData> manaList = new List <TimeData>();

                float    mana     = calculations.StartingMana;
                int      gemCount = 0;
                float    time     = 0;
                Color    manaFill = Color.FromArgb(50, 0, 0, 255);
                float    maxMana  = calculations.BaseStats.Mana;
                float    maxDps   = 100;
                DateTime baseTime = new DateTime(2000, 1, 1, 0, 0, 0);
                manaList.Add(new TimeData()
                {
                    Time = baseTime, Value = mana
                });
                for (int i = 0; i < sequence.Count; i++)
                {
                    int          index    = sequence[i].Index;
                    VariableType type     = sequence[i].VariableType;
                    float        duration = (float)sequence[i].Duration;
                    Cycle        cycle    = sequence[i].Cycle;
                    CastingState state    = sequence[i].CastingState;
                    if (cycle != null)
                    {
                        float dps = (float)cycle.GetDamagePerSecond(state.ManaAdeptBonus, 1);
                        if (dps > maxDps)
                        {
                            maxDps = dps;
                        }
                    }
                    float mps = (float)sequence[i].Mps;
                    if (sequence[i].IsManaPotionOrGem)
                    {
                        float value = duration;
                        duration = 0;
                        if (sequence[i].VariableType == VariableType.ManaGem)
                        {
                            mana += (float)((1 + calculations.BaseStats.BonusManaGem) * calculations.ManaGemValue * value);
                            gemCount++;
                        }
                        else if (sequence[i].VariableType == VariableType.ManaPotion)
                        {
                            mana += (float)((1 + calculations.BaseStats.BonusManaPotionEffectMultiplier) * calculations.ManaPotionValue * value);
                        }
                        if (mana < 0)
                        {
                            mana = 0;
                        }
                        if (mana > maxMana)
                        {
                            mana = maxMana;
                        }
                        manaList.Add(new TimeData()
                        {
                            Time = baseTime + TimeSpan.FromSeconds(time) + TimeSpan.FromTicks(1), Value = mana
                        });
                    }
                    else
                    {
                        /*if (sequence[i].IsEvocation)
                         * {
                         *  switch (sequence[i].VariableType)
                         *  {
                         *      case VariableType.Evocation:
                         *          mps = -(float)calculationOptions.Calculations.EvocationRegen;
                         *          break;
                         *      case VariableType.EvocationIV:
                         *          mps = -(float)calculationOptions.Calculations.EvocationRegenIV;
                         *          break;
                         *      case VariableType.EvocationHero:
                         *          mps = -(float)calculationOptions.Calculations.EvocationRegenHero;
                         *          break;
                         *      case VariableType.EvocationIVHero:
                         *          mps = -(float)calculationOptions.Calculations.EvocationRegenIVHero;
                         *          break;
                         *  }
                         * }*/
                        float partTime = duration;
                        if (mana - mps * duration < 0)
                        {
                            partTime = mana / mps;
                        }
                        else if (mana - mps * duration > maxMana)
                        {
                            partTime = (mana - maxMana) / mps;
                        }
                        mana -= mps * duration;
                        if (mana < 0)
                        {
                            mana = 0;
                        }
                        if (mana > maxMana)
                        {
                            mana = maxMana;
                        }
                        manaList.Add(new TimeData()
                        {
                            Time = baseTime + TimeSpan.FromSeconds(time + partTime), Value = mana
                        });
                        if (partTime < duration)
                        {
                            manaList.Add(new TimeData()
                            {
                                Time = baseTime + TimeSpan.FromSeconds(time + duration), Value = mana
                            });
                        }
                    }
                    time += duration;
                }

                Style dateTimeAxisLabelStyle = new Style(typeof(DateTimeAxisLabel));
                dateTimeAxisLabelStyle.Setters.Add(new Setter(DateTimeAxisLabel.MinutesIntervalStringFormatProperty, "{0:m:ss}"));
                dateTimeAxisLabelStyle.Setters.Add(new Setter(DateTimeAxisLabel.SecondsIntervalStringFormatProperty, "{0:m:ss}"));
                DateTimeAxis timeAxis = new DateTimeAxis()
                {
                    //Title = "Time",
                    Minimum        = baseTime,
                    Maximum        = baseTime + TimeSpan.FromSeconds(calculationOptions.FightDuration),
                    IntervalType   = DateTimeIntervalType.Seconds,
                    AxisLabelStyle = dateTimeAxisLabelStyle,
                    Orientation    = AxisOrientation.X,
                    ShowGridLines  = true,
                    Location       = AxisLocation.Top,
                };

                Style hiddenCategoryLabelStyle = new Style(typeof(AxisLabel));
                hiddenCategoryLabelStyle.Setters.Add(new Setter(NumericAxisLabel.VisibilityProperty, Visibility.Collapsed));

                CategoryAxis categoryAxis = new CategoryAxis()
                {
                    AxisLabelStyle     = hiddenCategoryLabelStyle,
                    Orientation        = AxisOrientation.Y,
                    MajorTickMarkStyle = null,
                };

                int barCount = 0;
                for (int cooldown = 0; cooldown < cooldownList.Count; cooldown++)
                {
                    List <TimeIntervalData> data = new List <TimeIntervalData>();
                    //blendSubPoint = new System.Drawing.Drawing2D.ColorBlend(3);
                    //blendSubPoint.Colors = new Color[] { colorSubPointsA[cooldown], colorSubPointsB[cooldown], colorSubPointsA[cooldown] };
                    //blendSubPoint.Positions = new float[] { 0f, 0.5f, 1f };
                    bool  on     = false;
                    float timeOn = 0.0f;
                    time = 0;
                    for (int i = 0; i < sequence.Count; i++)
                    {
                        float duration = (float)sequence[i].Duration;
                        if (sequence[i].IsManaPotionOrGem)
                        {
                            duration = 0;
                        }
                        if (on && !sequence[i].CastingState.EffectsActive(cooldownList[cooldown]) && !sequence[i].IsManaPotionOrGem)
                        {
                            on = false;
                            if (time > timeOn)
                            {
                                data.Add(new TimeIntervalData()
                                {
                                    Start = baseTime + TimeSpan.FromSeconds(timeOn), End = baseTime + TimeSpan.FromSeconds(time), Category = cooldownList[cooldown].Name
                                });
                            }
                        }
                        else if (!on && sequence[i].CastingState.EffectsActive(cooldownList[cooldown]))
                        {
                            on     = true;
                            timeOn = time;
                        }
                        time += duration;
                    }
                    if (on)
                    {
                        if (time - timeOn > 0)
                        {
                            data.Add(new TimeIntervalData()
                            {
                                Start = baseTime + TimeSpan.FromSeconds(timeOn), End = baseTime + TimeSpan.FromSeconds(time), Category = cooldownList[cooldown].Name
                            });
                        }
                    }
                    if (data.Count > 0)
                    {
                        barCount++;
                        Style timeIntervalStyle = new Style(typeof(TimeIntervalDataPoint));
                        timeIntervalStyle.Setters.Add(new Setter(TimeIntervalDataPoint.BackgroundProperty, new SolidColorBrush(cooldownList[cooldown].Color)));
                        Chart.Series.Add(new TimeIntervalSeries()
                        {
                            Title                = cooldownList[cooldown].Name,
                            ItemsSource          = data,
                            IndependentValuePath = "Category",
                            DependentValuePath   = "End",
                            StartTimePath        = "Start",
                            EndTimePath          = "End",
                            DataPointStyle       = timeIntervalStyle,
                            DependentRangeAxis   = timeAxis,
                            IndependentAxis      = categoryAxis
                        });
                    }
                }

                if (calculationOptions.DisplaySegmentCooldowns && calculationOptions.BossHandler)
                {
                    foreach (var buffState in calculationOptions.Character.BossOptions.BuffStates)
                    {
                        if (buffState.Chance > 0 && buffState.Stats.BonusDamageMultiplier > 0)
                        {
                            List <TimeIntervalData> data = new List <TimeIntervalData>();

                            foreach (var phase in buffState.PhaseTimes)
                            {
                                data.Add(new TimeIntervalData()
                                {
                                    Start = baseTime + TimeSpan.FromSeconds(phase.Value[0]), End = baseTime + TimeSpan.FromSeconds(phase.Value[1]), Category = buffState.Name
                                });
                            }
                            if (data.Count > 0)
                            {
                                barCount++;
                                Style timeIntervalStyle = new Style(typeof(TimeIntervalDataPoint));
                                timeIntervalStyle.Setters.Add(new Setter(TimeIntervalDataPoint.BackgroundProperty, new SolidColorBrush(Color.FromArgb(255, 0, 0, 0))));
                                Chart.Series.Add(new TimeIntervalSeries()
                                {
                                    Title                = buffState.Name,
                                    ItemsSource          = data,
                                    IndependentValuePath = "Category",
                                    DependentValuePath   = "End",
                                    StartTimePath        = "Start",
                                    EndTimePath          = "End",
                                    DataPointStyle       = timeIntervalStyle,
                                    DependentRangeAxis   = timeAxis,
                                    IndependentAxis      = categoryAxis
                                });
                            }
                        }
                    }
                }

                Style hiddenNumericLabelStyle = new Style(typeof(NumericAxisLabel));
                hiddenNumericLabelStyle.Setters.Add(new Setter(NumericAxisLabel.VisibilityProperty, Visibility.Collapsed));

                Chart.Series.Add(new AreaSeries()
                {
                    Title                = "Mana",
                    ItemsSource          = manaList,
                    IndependentValuePath = "Time",
                    DependentValuePath   = "Value",
                    DataPointStyle       = (Style)Resources["ManaStyle"],
                    Background           = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0xFF, 0xFF)),
                    DependentRangeAxis   = new OffsetLinearAxis()
                    {
                        Minimum            = 0,
                        Offset             = barCount * 10.0,
                        Orientation        = AxisOrientation.Y,
                        AxisLabelStyle     = hiddenNumericLabelStyle,
                        MajorTickMarkStyle = null,
                        MinorTickMarkStyle = null,
                    },
                    IndependentAxis = timeAxis,
                    LegendItemStyle = null,
                });

                maxDps *= 1.1f;
                List <TimeData> list = new List <TimeData>();
                time = 0.0f;
                for (int i = 0; i < sequence.Count; i++)
                {
                    int          index    = sequence[i].Index;
                    VariableType type     = sequence[i].VariableType;
                    float        duration = (float)sequence[i].Duration;
                    Cycle        cycle    = sequence[i].Cycle;
                    CastingState state    = sequence[i].CastingState;
                    float        mps      = (float)sequence[i].Mps;
                    if (sequence[i].IsManaPotionOrGem)
                    {
                        duration = 0;
                    }
                    float dps = 0;
                    if (cycle != null)
                    {
                        dps = (float)cycle.DamagePerSecond;
                    }
                    if (duration > 0)
                    {
                        if (calculations.ManaAdeptBonus > 0)
                        {
                            for (int t = 1; t < 10; t++)
                            {
                                DateTime timet = baseTime + TimeSpan.FromSeconds(time + 0.1f * t * duration);
                                if (cycle != null)
                                {
                                    dps = (float)cycle.GetDamagePerSecond(calculations.ManaAdeptBonus, GetManaAtTime(manaList, timet) / maxMana);
                                }
                                // apply state multipliers
                                if (calculationOptions.DisplaySegmentCooldowns)
                                {
                                    dps *= calculationOptions.GetDamageMultiplier(time, time + duration);
                                }
                                list.Add(new TimeData()
                                {
                                    Time = timet, Value = dps
                                });
                            }
                        }
                        else
                        {
                            // apply state multipliers
                            if (calculationOptions.DisplaySegmentCooldowns)
                            {
                                dps *= calculationOptions.GetDamageMultiplier(time, time + duration);
                            }
                            list.Add(new TimeData()
                            {
                                Time = baseTime + TimeSpan.FromSeconds(time + 0.1f * duration), Value = dps
                            });
                            list.Add(new TimeData()
                            {
                                Time = baseTime + TimeSpan.FromSeconds(time + 0.9f * duration), Value = dps
                            });
                        }
                    }
                    time += duration;
                }

                Chart.Series.Add(new LineSeries()
                {
                    Title                = "Dps",
                    ItemsSource          = list,
                    IndependentValuePath = "Time",
                    DependentValuePath   = "Value",
                    DataPointStyle       = (Style)Resources["DpsStyle"],
                    DependentRangeAxis   = new OffsetLinearAxis()
                    {
                        Offset             = barCount * 10.0,
                        Minimum            = 0,
                        Orientation        = AxisOrientation.Y,
                        AxisLabelStyle     = hiddenNumericLabelStyle,
                        MajorTickMarkStyle = null,
                        MinorTickMarkStyle = null,
                    },
                    IndependentAxis = timeAxis,
                });

                if (zeroLineCanvas == null)
                {
                    zeroLineCanvas          = new ZeroLineCanvas(categoryAxis);
                    zeroLineCanvas.BarCount = barCount;
                }
                else
                {
                    zeroLineCanvas.BarCount = barCount;
                    zeroLineCanvas.Axis     = categoryAxis;
                }

                ISeriesHost host = (ISeriesHost)Chart;
                if (!host.BackgroundElements.Contains(zeroLineCanvas))
                {
                    host.BackgroundElements.Add(zeroLineCanvas);
                }
            }
        }
Exemplo n.º 10
0
 private void cleanup()
 {
     castingState = CastingState.None;
     paidCost     = Cost.Zero;
     currentCost  = Cost.Zero;
 }
Exemplo n.º 11
0
 public CastEventArgs(CastingState castingState)
 {
     skill      = castingState.ActiveSkill;
     targetInfo = castingState.TargetInfo;
 }