/// <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); }
private bool IsInStone(Point cellPt) { return(StoneCells.FindIndex(record => record.Location.Equals(cellPt)) != -1); }