Beispiel #1
0
        public SpellHandler(Spell spell, Target source, Target castTarget, int stacks)
        {
            Assert.IsNotNull(spell, "spell != null");
            Assert.IsTrue(source.IsValid, "source.IsValid");
            Assert.IsTrue(castTarget.IsValid, "castTarget.IsValid");
            Assert.IsTrue(castTarget.Type == spell.TargetType, "castTarget.Type == spell.TargetType");

            Spell           = spell;
            Source          = source;
            _originalTarget = castTarget;
            _minRange       = spell.MinRange.GetValue(Stacks);
            _maxRange       = spell.MaxRange.GetValue(Stacks);

#if DEBUG
            // Draw debug info
            if (spell.TargetType != TargetType.None)
            {
                Debugger.Default.DrawCircle(source.OffsettedPosition, Vector3.up, _minRange, Color.yellow, 1f);
                Debugger.Default.DrawCircle(source.OffsettedPosition, Vector3.up, _maxRange, Color.yellow, 1f);
            }
            TargetUtility.DebugDrawSourceAndTarget(source, castTarget);
#endif

            // Create target proxy if we need to retarget
            if (spell.RangeBehaviour == Spell.TargetRangeBehaviour.RetargetClampToRange ||
                spell.RangeBehaviour == Spell.TargetRangeBehaviour.RetargetSetMaxRange)
            {
                if (castTarget.Type == TargetType.Location || castTarget.Type == TargetType.LocationProvider)
                {
                    CastTarget = new Target(_locationTargetProxy);
                }
                else
                {
                    Debug.LogWarning($"Can't create proxy target for target of type {castTarget.Type}");
                }
            }
            else
            {
                CastTarget = castTarget;
            }

            Stacks = stacks;
            _state = SpellState.Started;
        }
        public SubSpellHandler(
            SpellHandler spellHandler,
            SubSpell subSpell,
            Target source,
            Target target)
        {
            Assert.IsTrue(source.IsValid);
            Assert.IsTrue(target.IsValid);
            Assert.IsNotNull(subSpell);
            Assert.IsNotNull(spellHandler);

            SubSpell      = subSpell;
            _spellHandler = spellHandler;
            Source        = source;
            Target        = target;
            _state        = SubSpellState.Started;

            #if DEBUG
            TargetUtility.DebugDrawSourceAndTarget(source, target);
            #endif
        }