Example #1
0
        /// <summary>
        /// Draws the line shape.
        /// </summary>
        /// <param name="surface">The cell surface to draw on.</param>
        public void Draw(CellSurface surface)
        {
            List <Cell> cells = new List <Cell>();

            Algorithms.Line(StartingLocation.X, StartingLocation.Y, EndingLocation.X, EndingLocation.Y, (x, y) => { cells.Add(surface[x, y]); return(true); });

            if (cells.Count > 1)
            {
                if (UseStartingCell)
                {
                    StartingCellAppearance.Copy(cells[0]);
                    surface.SetEffect(cells[0], StartingCellAppearance.Effect);
                }
                else
                {
                    CellAppearance.Copy(cells[0]);
                    surface.SetEffect(cells[0], CellAppearance.Effect);
                }

                if (UseEndingCell)
                {
                    EndingCellAppearance.Copy(cells[cells.Count - 1]);
                    surface.SetEffect(cells[cells.Count - 1], EndingCellAppearance.Effect);
                }
                else
                {
                    CellAppearance.Copy(cells[cells.Count - 1]);
                    surface.SetEffect(cells[cells.Count - 1], CellAppearance.Effect);
                }

                for (int i = 1; i < cells.Count - 1; i++)
                {
                    CellAppearance.Copy(cells[i]);
                    surface.SetEffect(cells[i], CellAppearance.Effect);
                }
            }
            else if (cells.Count == 1)
            {
                CellAppearance.Copy(cells[0]);
                surface.SetEffect(cells[0], CellAppearance.Effect);
            }
        }
Example #2
0
        /// <summary>
        /// Draws the line shape.
        /// </summary>
        /// <param name="surface">The cell surface to draw on.</param>
        public void Draw(CellSurface surface)
        {
            List<Cell> cells = new List<Cell>();

            Algorithms.Line(StartingLocation.X, StartingLocation.Y, EndingLocation.X, EndingLocation.Y, (x, y) => { cells.Add(surface[x, y]); return true; });

            if (cells.Count > 1)
            {
                if (UseStartingCell)
                {
                    StartingCellAppearance.Copy(cells[0]);
                    surface.SetEffect(cells[0], StartingCellAppearance.Effect);
                }
                else
                {
                    CellAppearance.Copy(cells[0]);
                    surface.SetEffect(cells[0], CellAppearance.Effect);
                }

                if (UseEndingCell)
                {
                    EndingCellAppearance.Copy(cells[cells.Count - 1]);
                    surface.SetEffect(cells[cells.Count - 1], EndingCellAppearance.Effect);
                }
                else
                {
                    CellAppearance.Copy(cells[cells.Count - 1]);
                    surface.SetEffect(cells[cells.Count - 1], CellAppearance.Effect);
                }

                for (int i = 1; i < cells.Count - 1; i++)
                {
                    CellAppearance.Copy(cells[i]);
                    surface.SetEffect(cells[i], CellAppearance.Effect);
                }
            }
            else if (cells.Count == 1)
            {
                CellAppearance.Copy(cells[0]);
                surface.SetEffect(cells[0], CellAppearance.Effect);
            }
        }