// Use this for initialization
    void Start()
    {
        if (m_DataSource == null)
        {
            return;
        }

        m_TileMat = Material.Instantiate(m_TileMatResource) as Material;
        m_TileMat.SetVector("_TileOffset", new Vector4(m_Pos.x * RSTile.TILE_SIZEF, 0, m_Pos.y * RSTile.TILE_SIZEF, 1));
        m_TileMat.SetFloat("_TileSize", RSTile.TILE_SIZEF);
        m_TileMat.SetFloat("_MaxHeight", RSTile.MAX_HEIGHTF);
        m_TileMat.SetTexture("_xzMask", m_RoadGraph);
        m_TileMat.SetTexture("_y0Mask", m_HeightGraph0);
        m_TileMat.SetTexture("_y1Mask", m_HeightGraph1);
        m_Projector.nearClipPlane           = 0;
        m_Projector.farClipPlane            = RSTile.MAX_HEIGHTF + RSTile.CELL_SIZEF;
        m_Projector.orthographicSize        = RSTile.TILE_SIZEF * 0.5f;
        m_Projector.material                = m_TileMat;
        m_Projector.transform.localPosition = new Vector3(RSTile.TILE_SIZEF * 0.5f, RSTile.MAX_HEIGHTF, RSTile.TILE_SIZEF * 0.5f);

        RSTile TileData = m_DataSource.GetTile(m_Pos);

        if (TileData != null)
        {
            TileData.OnTileDot     = DotTextures;
            TileData.OnTileRefresh = RefreshTextures;
            TileData.Data          = TileData.CacheData;
        }
        m_Started = true;
    }
 private void WriteTileToTextures(RSTile tile)
 {
     foreach (KeyValuePair <int, RoadCell> kvp in tile.Road)
     {
         WriteRoadCellToTextures(kvp.Key, kvp.Value);
     }
 }
Example #3
0
    public void AlterRoadCell(Vector3 world_pos, RoadCell rc)
    {
        int tile_hash = RSTile.QueryTile(world_pos).hash;
        int cell_hash = RSTile.WorldPosToRoadCellPos_s(tile_hash, world_pos).hash;

        AlterRoadCell(tile_hash, cell_hash, rc);
    }
Example #4
0
    public RoadCell GetRoadCell(Vector3 world_pos)
    {
        int tile_hash = RSTile.QueryTile(world_pos).hash;

        if (m_Tiles.ContainsKey(tile_hash))
        {
            return(m_Tiles[tile_hash].GetRoadCell(world_pos));
        }
        return(new RoadCell(0));
    }
    public void BeforeDestroy()
    {
        RSTile TileData = m_DataSource.GetTile(m_Pos);

        if (TileData != null)
        {
            TileData.OnTileDot     = null;
            TileData.OnTileRefresh = null;
            TileData.CacheData     = TileData.Data;
            TileData.Clear();
        }
    }
Example #6
0
    void OnTileCreate(RSTile tile)
    {
        int hash = tile.Hash;

        if (m_Renderers.ContainsKey(hash))
        {
            tile.OnTileRefresh = m_Renderers[hash].RefreshTextures;
            tile.OnTileDot     = m_Renderers[hash].DotTextures;
        }
        else
        {
            tile.OnTileRefresh = null;
            tile.OnTileDot     = null;
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (m_DataSource == null)
        {
            return;
        }
        RSTile TileData = m_DataSource.GetTile(m_Pos);

        if (TileData != null)
        {
            m_Projector.gameObject.SetActive(true);
        }
        else
        {
            m_Projector.gameObject.SetActive(false);
        }
    }
Example #8
0
 public void AlterRoadCell(int tile_hash, int cell_hash, RoadCell rc)
 {
     if (rc.type > 0)
     {
         if (!m_Tiles.ContainsKey(tile_hash))
         {
             m_Tiles.Add(tile_hash, new RSTile(tile_hash, true));
         }
         m_Tiles[tile_hash].SetRoadCell(cell_hash, rc);
     }
     else
     {
         if (m_Tiles.ContainsKey(tile_hash))
         {
             RSTile tile = m_Tiles[tile_hash];
             tile.SetRoadCell(cell_hash, rc);
             if (tile.Road.Count == 0)
             {
                 tile.Destroy();
                 m_Tiles.Remove(tile_hash);
             }
         }
     }
 }
 public void RefreshTextures(RSTile tile)
 {
     ClearTextures();
     WriteTileToTextures(tile);
     ApplyTexturesChange();
 }
Example #10
0
 void OnTileDestroy(RSTile tile)
 {
     tile.OnTileRefresh = null;
     tile.OnTileDot     = null;
 }