Example #1
0
        public override bool Apply(Fighter[] targets)
        {
            DirectionsEnum orientation = this.Source.Point.OrientationTo(CastPoint, true); //Source.Point=> this.TargetedPoint
            short          adjCellId   = this.Source.Point.GetCellInDirection(orientation, (short)1).CellId;

            Fighter target = this.Fight.GetFirstFighter <Fighter>(entry => (int)entry.CellId == adjCellId);

            if (target == null)
            {
                return(false);
            }
            else
            {
                MapPoint   startPoint         = target.Point;
                MapPoint   point              = CastPoint;
                MapPoint[] cellsOnLineBetween = startPoint.GetCellsOnLineBetween(CastPoint);
                for (int index = 0; index < cellsOnLineBetween.Length; ++index)
                {
                    MapPoint mapPoint = cellsOnLineBetween[index];
                    if (!this.Fight.IsCellFree(mapPoint.CellId))
                    {
                        point = index <= 0 ? startPoint : new MapPoint((short)cellsOnLineBetween[index - 1].CellId);
                    }
                    if (this.Fight.ShouldTriggerOnMove(mapPoint.CellId))
                    {
                        point = mapPoint;
                        break;
                    }
                }
                target.Slide(Source, point.CellId);
                return(true);
            }
        }