예제 #1
0
        public void Init()
        {
            grid = GridBase.singleton;
            Vector3 worldPos = grid.GetWorldCoordinatesFromTile(2, 2 / 2, 4);

            curUnit.transform.position = worldPos;

            GameObject go = new GameObject();

            go.name            = "line vis";
            pathVis            = go.AddComponent <LineRenderer>();
            pathVis.startWidth = 0.2f;
            pathVis.endWidth   = 0.2f;
        }
예제 #2
0
        private void Update()
        {
            if (GridBase.singleton.isInit == false)
            {
                return;
            }

            FindTile();
            if (unitTile == null && curUnit != null)
            {
                //unitTile = grid.GetTileFromWorldPosition(curUnit.transform.position);
            }
            if (unitTile == null)
            {
                return;
            }

            if (prevTile != curTile)
            {
                //PathfindMaster.GetInstance().RequestPathFind(unitTile,curTile,PathFinderCallback);
            }

            prevTile = curTile;

            if (hasPath && path != null)
            {
                if (path.Count > 0)
                {
                    pathVis.positionCount = path.Count;

                    for (int i = 0; i < path.Count; i++)
                    {
                        Tile    n = path[i];
                        Vector3 p = grid.GetWorldCoordinatesFromTile(n.x, n.y, n.z);
                        pathVis.SetPosition(i, p);
                    }
                }
            }
        }