internal MapTileNode(int idx, MapPathFinding owner) { m_owner = owner; TileIdx = idx; TileX = idx % AutoTileMap.Instance.MapTileWidth; TileY = idx / AutoTileMap.Instance.MapTileWidth; Position = RpgMapHelper.GetTileCenterPosition(TileX, TileY); // get all neighbors row by row, neighIdx will be the idx of left most tile per each row int neighIdx = (idx-1)-AutoTileMap.Instance.MapTileWidth; for (int i = 0; i < 3; ++i, neighIdx += AutoTileMap.Instance.MapTileWidth) { for (int j = 0; j < 3; ++j) { if (i != 1 || j != 1) // skip this node { m_neighborIdxList.Add(neighIdx + j); } } } }
internal MapTileNode(int idx, MapPathFinding owner) { m_owner = owner; TileIdx = idx; TileX = idx % AutoTileMap.Instance.MapTileWidth; TileY = idx / AutoTileMap.Instance.MapTileWidth; Position = RpgMapHelper.GetTileCenterPosition(TileX, TileY); // get all neighbors row by row, neighIdx will be the idx of left most tile per each row int neighIdx = (idx-1)-AutoTileMap.Instance.MapTileWidth; for (int i = 0; i < 3; ++i, neighIdx += AutoTileMap.Instance.MapTileWidth) { for (int j = 0; j < 3; ++j) { if (i != 1 || j != 1) // skip this node { m_neighborIdxList.Add(neighIdx + j); } } } }