コード例 #1
0
        public static IEnumerable <Vector3> Flood(AbstractMap map, Vector3 location)
        {
            Type            targetType = map.GetSafeSquare(location).GetType();
            Queue <Vector3> candidates = new Queue <Vector3>();

            candidates.Enqueue(location);
            while (candidates.Count > 0)
            {
                Vector3 n     = candidates.Dequeue();
                Vector3 delta = Vector3.West;
                Vector3 w     = n;
                for (int x = 0; x < 2; ++x)
                {
                    bool ok = false;
                    do
                    {
                        AbstractSquare sq = map.GetSafeSquare(w);
                        ok = (sq != null && sq.GetType().Equals(targetType));
                        if (ok)
                        {
                            yield return(w);

                            candidates.Enqueue(w + Vector3.North);
                            candidates.Enqueue(w + Vector3.South);
                        }
                        w = w + delta;
                    } while (ok);

                    delta = Vector3.East;
                    w     = n + delta;
                }
            }
        }
コード例 #2
0
        void Main_DragOver(object sender, DragEventArgs e)
        {
            Point          tile = ScreenToTile(SharplikeView.PointToClient(new Point(e.X, e.Y)));
            AbstractSquare sq   = Map.GetSafeSquare(new Vector3(tile.X + Map.View.X, tile.Y + Map.View.Y, Map.View.Z));

            if (sq != null && sq.IsPassable(Direction.Here))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }