Esempio n. 1
0
        /// <summary>
        /// 重置
        /// </summary>
        public void ReSet()
        {
            if (StartCell != null)
            {
                MapBmpFillRectangle(StartCell, this._whiteSmoke);
                StartCell = null;
            }
            if (GoalCell != null)
            {
                MapBmpFillRectangle(GoalCell, this._whiteSmoke);
                GoalCell = null;
            }

            MapBmpFillRectangles(StoneCells, this._whiteSmoke);
            StoneCells.Clear();

            MapBmpFillRectangles(ClosedList, this._whiteSmoke);
            ClosedList.Clear();

            MapBmpFillRectangles(OpenList, this._whiteSmoke);
            OpenList.Clear();
        }
Esempio n. 2
0
        /// <summary>
        /// 生成随机障碍
        /// </summary>
        public void RandStoneCell()
        {
            Random        rd  = new Random();
            IList <Point> pts = new List <Point>();

            for (int i = 0; i < (this.CELL_WIDTH_COUNT * this.CELL_HEIGHT_COUNT / 100); i++)
            {
                int   j  = rd.Next(this.CELL_WIDTH_COUNT);
                int   k  = rd.Next(this.CELL_HEIGHT_COUNT);
                Point pt = new Point
                {
                    X = j * this.CELL_WIDTH,
                    Y = k * this.CELL_WIDTH
                };

                if (StoneCells.FindIndex(record => record.Location.Equals(pt)) == -1)
                {
                    pts.Add(pt);
                }
            }
            this.DrawStones(pts);
        }
Esempio n. 3
0
 private bool IsInStone(Point cellPt)
 {
     return(StoneCells.FindIndex(record => record.Location.Equals(cellPt)) != -1);
 }