Ejemplo n.º 1
0
        public List <CoordinatePoint> LeftIndex(List <BaseFigure> othereFigures)
        {
            var arr   = new List <CoordinatePoint>();
            int sub   = this.Coordinate.X - this.Coordinate.Y;
            var model = othereFigures.Where(c => c != this).ToList();

            for (int i = downPoint; i <= topPoint; i++)
            {
                for (int j = downPoint; j <= topPoint; j++)
                {
                    if (i - j == sub)
                    {
                        var coordinatPointTemp = new CoordinatePoint(i, j);
                        arr.Add(coordinatPointTemp);
                    }
                }
            }
            foreach (var item in model)
            {
                if (arr.Contains(item.Coordinate))
                {
                    if (item.Color == this.Color)
                    {
                        if (arr.IndexOf(this.Coordinate) < arr.IndexOf(item.Coordinate))
                        {
                            arr = arr.Where(c => arr.IndexOf(c) < arr.IndexOf(item.Coordinate)).ToList();
                        }
                        else
                        {
                            arr = arr.Where(c => arr.IndexOf(c) > arr.IndexOf(item.Coordinate)).ToList();
                        }
                    }
                    else
                    {
                        if (item is King)
                        {
                            continue;
                        }
                        if (arr.IndexOf(this.Coordinate) < arr.IndexOf(item.Coordinate))
                        {
                            arr = arr.Where(c => arr.IndexOf(c) <= arr.IndexOf(item.Coordinate)).ToList();
                        }
                        else
                        {
                            arr = arr.Where(c => arr.IndexOf(c) >= arr.IndexOf(item.Coordinate)).ToList();
                        }
                    }
                }
            }
            return(arr);
        }
Ejemplo n.º 2
0
        public List <CoordinatePoint> Horizontal(List <BaseFigure> othereFigures)
        {
            var arr   = new List <CoordinatePoint>();
            var model = othereFigures.Where(c => c != this).ToList();

            for (int i = downPoint; i <= topPoint; i++)
            {
                var coordinatPointTemp = new CoordinatePoint(i, this.Coordinate.Y);
                arr.Add(coordinatPointTemp);
            }
            foreach (var item in model)
            {
                if (arr.Contains(item.Coordinate))
                {
                    if (item.Color == this.Color)
                    {
                        if (this.Coordinate.X < item.Coordinate.X)
                        {
                            arr = arr.Where(c => c.X < item.Coordinate.X).ToList();
                        }
                        else
                        {
                            arr = arr.Where(c => c.X > item.Coordinate.X).ToList();
                        }
                    }
                    else
                    {
                        if (item is King)
                        {
                            continue;
                        }
                        if (this.Coordinate.X < item.Coordinate.X)
                        {
                            arr = arr.Where(c => c.X <= item.Coordinate.X).ToList();
                        }
                        else
                        {
                            arr = arr.Where(c => c.X >= item.Coordinate.X).ToList();
                        }
                    }
                }
            }
            arr.Remove(this.Coordinate);
            return(arr);
        }