Ejemplo n.º 1
0
        /// <summary>
        /// 设置地图的星星内容,附带移动过程
        /// </summary>
        public void SetMapContent(NPCStar p, int i, int j, bool withMove, MazeMapPoint initCoord)
        {
            MMap.setMap(p, i, j);

            if (p == null)
            {
                return;
            }

            p.Point = new MazeMapPoint()
            {
                x = i, y = j
            };
            p.transform.localPosition = GetMapCoordPosition(initCoord.x, initCoord.y);

            if (withMove)
            {
                p.BeforeOnMove();
                p.transform.DOLocalMove(GetMapCoordPosition(i, j), 0.35f).OnComplete(() => {
                    p.AfterOnMove();
                });
            }
            else
            {
                p.transform.localPosition = GetMapCoordPosition(i, j);
            }
        }
Ejemplo n.º 2
0
        public List <T> OnSearchMap(int pointx, int pointy, System.Func <T, bool> IsSearchPass)
        {
            List <T> list = new List <T> ();

            queue.Reset();
            mapflag.ClearMapFlag();

            queue.AddTail(new MazeMapPoint()
            {
                x = pointx, y = pointy
            });
            mapflag.SetMapFlag(pointx, pointy);
            list.Add(getMap(pointx, pointy));

            int[] tx = new int[] { -1, 0, 0, 1 };
            int[] ty = new int[] { 0, -1, 1, 0 };

            while (queue.IsNotEmpty())
            {
                MazeMapPoint head = queue.GetHead();

                for (int i = 0; i < 4; ++i)
                {
                    int dx = head.x + tx [i];
                    int dy = head.y + ty [i];

                    // 已经过界
                    if (dx < 0 || dx >= maxMapLine ||
                        dy < 0 || dy >= maxMapCell)
                    {
                        continue;
                    }

                    // 已经访问过了
                    if (mapflag.IsMapFlag(dx, dy))
                    {
                        continue;
                    }

                    T ptr = getMap(dx, dy);
                    // 没有存在星星
                    if (ptr == null)
                    {
                        continue;
                    }

                    // 星星是否通过搜索
                    if (IsSearchPass(ptr))
                    {
                        queue.AddTail(new MazeMapPoint()
                        {
                            x = dx, y = dy
                        });
                        mapflag.SetMapFlag(dx, dy);

                        list.Add(ptr);
                    }
                }

                queue.Next();
            }

            return(list);
        }
Ejemplo n.º 3
0
 public void InitUsed(MazeMapPoint point)
 {
     transform.localPosition = new Vector3(PixelUtil * point.y, PixelUtil * point.x, 0);
     Point = point;
 }