예제 #1
0
        public void CastGroundTarget(Vector3 worldPos)
        {
            var origin      = Self.transform.position;
            var boxBaseSize = new Vector2(_pathWidth, 2);
            var length      = AbilityHelper.GetLineLength(origin, worldPos);

            length = Mathf.Min(length, CurrentCastRange);
            var boxHalfExtents = new Vector3(boxBaseSize.x, boxBaseSize.y, length) / 2;
            var rotation       = AbilityHelper.GetRotation(origin, worldPos);
            var center         = AbilityHelper.GetBoxCenter(origin, boxHalfExtents, rotation);
            var colliders      = Physics.OverlapBox(center, boxHalfExtents, rotation, (int)LayerMaskFlag.Entity);
            var dmg            = new Damage(_damage, DamageType.Magical, DamageFlags.Ability);

            foreach (var col in colliders)
            {
                if (!AbilityHelper.TryGetActor(col, out var actor))
                {
                    continue; //Not an actor, ignore
                }
                if (!CheckBuilder.AllowTarget(actor))
                {
                    continue; //Ignore if allies
                }
                if (!actor.TryGetModule <IDamageable>(out var damageTarget))
                {
                    continue; //Ignore if cant damage
                }
                damageTarget.TakeDamage(Self, dmg);
            }
        }
예제 #2
0
        public void CastGroundTarget(Vector3 worldPos)
        {
            var origin         = Self.transform.position;
            var length         = AbilityHelper.GetLineLength(origin, worldPos);
            var boxHalfExtents = new Vector3(_pathWidth, 2f, length);
            var rotation       = AbilityHelper.GetRotation(origin, worldPos);
            var center         = AbilityHelper.GetBoxCenter(origin, boxHalfExtents, rotation);

            var colliders = Physics.OverlapBox(center, boxHalfExtents, rotation, (int)LayerMaskFlag.Entity);

            var atkDamage = Modules.Attackerable.Damage;

            var dmg = new Damage(_bonusDamage + atkDamage, DamageType.Physical,
                                 DamageFlags.Ability | DamageFlags.Attack);

            foreach (var col in colliders)
            {
                if (!AbilityHelper.TryGetActor(col, out var actor))
                {
                    continue;
                }
                if (!Checker.AllowTarget(actor))
                {
                    continue;
                }
                Modules.Attackerable.RawAttack(actor, dmg);
            }

            Modules.Movable.WarpTo(worldPos);
            Modules.Commandable.ClearCommands();
        }