예제 #1
0
        private Cell[] GetAroundCells(uint l)
        {
            var result = new List <Cell>();

            if (LayerCount == 2)
            {
                result.Add(Location.UpCell);
            }
            else if (LayerCount > 2)
            {
                result.Add(Location.UpCell);
                result.Add(Location.DownCell);
            }
            if (Location.I + Location.J == 0)
            {
                result.AddRange(CellMap[l, 1]);
                return(result.ToArray());
            }
            var 象限      = Location.Quadrant;
            var outSide = new CellLocation(l, Location.I + 1, Location.J + 象限);

            result.Add(Location.PreviousCell);
            result.Add(Location.NextCell);
            if (Location.Position == 0)
            {
                result.Add(CellMap[l, Location.I - 1][Location.J - 象限]);

                if (Location.I + 1 < SizeCount)
                {
                    result.Add(outSide.Cell);
                    result.Add(outSide.PreviousCell);
                    result.Add(outSide.NextCell);
                }
            }
            else
            {
                var inSide = new CellLocation(l, Location.I - 1, Location.J - 象限 - 1);
                result.Add(inSide.NextCell);
                result.Add(inSide.Cell);
                if (Location.I + 1 < SizeCount)
                {
                    result.Add(outSide.Cell);
                    result.Add(outSide.NextCell);
                }
            }
            //result.Sort(_sorter1);
            return(result.ToArray());
        }
예제 #2
0
        public Cell(uint l, uint x, uint y)
        {
            Location = new CellLocation(l, x, y);
            //Shape.Width = Size;
            //Shape.Height = Size;

            //for (var i = 0; i < 6; i++)
            //{
            //    var 弧度 = Math.PI * i / 3 + Math.PI / 6;
            //    Shape.Points.Add(new Point(Size * Math.Cos(弧度), Size * Math.Sin(弧度)));
            //}
            LifeBrush = new SolidColorBrush(Color.FromRgb((byte)(x * 15), (byte)(x * 15), (byte)(x * 15)));
            //Shape.Fill = new SolidColorBrush(Color.FromRgb((byte) (x*40),(byte) (y*40),(byte) (x*40)));
            //Shape.Fill = DeadBrush;
            Position = Location.I != 0 ? ToXY() : new Point(Size * SizeCount, Size * SizeCount);
            //Shape.SetValue(Canvas.LeftProperty,shapePosition.X);
            //Shape.SetValue(Canvas.TopProperty, shapePosition.Y);
            //Children.Add(new TextBlock(new Run( x + "," + y )) { Foreground = new SolidColorBrush(Colors.Gray), RenderTransform = new TranslateTransform(-Size+10, -Size+10) });
            // Shape.MouseDown += Cell_MouseDown;
        }