Ejemplo n.º 1
0
        private void CreateAsset()
        {
            Grid2DNavData nav = ScriptableObject.CreateInstance <Grid2DNavData>();

            ushort[,] maskList = new ushort[width, height];
            byte[,] terrain    = new byte[width, height];
            for (int x = 0; x < width; ++x)
            {
                for (int y = 0; y < height; ++y)
                {
                    maskList[x, y] = gridList[x, y].mask;
                    terrain[x, y]  = gridList[x, y].terrain;
                }
            }
            nav._setData(maskList, terrain, width, height,
                         (int)(gridSize * Int3.Precision), (int)(minX * Int3.Precision), (int)(minZ * Int3.Precision),
                         (int)(agentRadius * Int3.Precision), slope);
            navData = nav;
        }
Ejemplo n.º 2
0
        public override void Init(INavData data)
        {
            navData       = data as Grid2DNavData;
            nodeIdCounter = 0;
            this.width    = navData.Width;
            this.height   = navData.Height;

            nodes = new Grid2DNode[width, height];

            for (int x = 0; x < width; ++x)
            {
                for (int y = 0; y < height; ++y)
                {
                    Grid2DNode node = new Grid2DNode(nodeIdCounter++);
                    nodes[x, y]      = node;
                    node.x           = (ushort)x;
                    node.y           = (ushort)y;
                    node.blockValue  = navData.GetMask(x, y);
                    node.terrainType = navData.GetTerrain(x, y);
                }
            }
        }