Пример #1
0
        public void UseOn(IActor actor, IAttackTarget target, ITacticalAct act)
        {
            //TODO реализовать возможность действовать на себя некоторыми скиллами.
            if (actor == target)
            {
                throw new ArgumentException("Актёр не может атаковать сам себя", nameof(target));
            }

            var currentCubePos = ((HexNode)actor.Node).CubeCoords;
            var targetCubePos  = ((HexNode)target.Node).CubeCoords;

            var isInDistance = act.CheckDistance(currentCubePos, targetCubePos);

            if (!isInDistance)
            {
                throw new InvalidOperationException("Попытка атаковать цель, находящуюся за пределами атаки.");
            }

            var tacticalActRoll = GetActEfficient(act);

            if (target is IActor targetActor)
            {
                UseOnActor(actor, targetActor, tacticalActRoll);
            }
            else
            {
                UseOnChest(target, tacticalActRoll);
            }
        }
        private void UseAct(IActor actor, IAttackTarget target, ITacticalAct act)
        {
            bool isInDistance;

            if ((act.Stats.Targets & TacticalActTargets.Self) > 0 && actor == target)
            {
                isInDistance = true;
            }
            else
            {
                var currentCubePos = ((HexNode)actor.Node).CubeCoords;
                var targetCubePos  = ((HexNode)target.Node).CubeCoords;

                isInDistance = act.CheckDistance(currentCubePos, targetCubePos);
            }

            if (!isInDistance)
            {
                throw new InvalidOperationException("Попытка атаковать цель, находящуюся за пределами атаки.");
            }

            var targetNode = target.Node;

            var targetIsOnLine = _sectorManager.CurrentSector.Map.TargetIsOnLine(
                actor.Node,
                targetNode);

            if (!targetIsOnLine)
            {
                throw new InvalidOperationException("Задачу на атаку нельзя выполнить сквозь стены.");
            }


            actor.UseAct(target, act);

            var tacticalActRoll = GetActEfficient(act);

            // Изъятие патронов
            if (act.Constrains?.PropResourceType != null)
            {
                RemovePropResource(actor, act);
            }

            if (target is IActor targetActor)
            {
                UseOnActor(actor, targetActor, tacticalActRoll);
            }
            else
            {
                UseOnChest(target, tacticalActRoll);
            }

            if (act.Equipment != null)
            {
                EquipmentDurableService?.UpdateByUse(act.Equipment, actor.Person);
            }
        }
Пример #3
0
        private static bool IsInDistance(IActor actor, IGraphNode targetNode, ITacticalAct act, ISectorMap map)
        {
            var actorNodes = GetActorNodes(actor.PhysicalSize, actor.Node, map);

            foreach (var node in actorNodes)
            {
                var isInDistanceInNode = act.CheckDistance(node, targetNode, map);
                if (isInDistanceInNode)
                {
                    return(true);
                }
            }

            return(false);
        }
        private bool IsInDistance(IActor actor, IAttackTarget target, ITacticalAct act)
        {
            var actorNodes  = GetActorNodes(actor.PhysicalSize, actor.Node, _sectorManager.CurrentSector.Map);
            var targetNodes = GetActorNodes(target.PhysicalSize, target.Node, _sectorManager.CurrentSector.Map);

            foreach (var node in actorNodes)
            {
                foreach (var targetNode in targetNodes)
                {
                    var isInDistanceInNode = act.CheckDistance(node, targetNode, _sectorManager.CurrentSector.Map);
                    if (isInDistanceInNode)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }