Beispiel #1
0
    public Tile GetTile(TileVec vec)
    {
        Tile t;

        if (tiles.TryGetValue(vec, out t))
        {
            return(t);
        }
        //Debug.LogWarning("Could not find Tile at position "+vec.ToString()+" "+t);
        return(null);
    }
Beispiel #2
0
 public void InitTile(TileVec vec)
 {
     this.positionVector = vec;
     this.gameObject.transform.localRotation = Quaternion.Euler(0, 90, 0);
     this.tileRenderer    = gameObject.GetComponent <MeshRenderer>();
     tileRenderer.enabled = false;
     if (tileRenderer == null)
     {
         Debug.LogWarning("No MeshRenderer found for Tile " + gameObject.name);
     }
     this.environment = gameObject.GetComponent <Environment>();
     if (environment == null)
     {
         Debug.LogWarning("No Environment found for Tile " + gameObject.name);
     }
 }
Beispiel #3
0
    private void GenerateMapFromPrefab(GameObject gameObj)
    {
        GameObject level = Instantiate <GameObject>(gameObj);

        Tile[] newTiles = level.GetComponentsInChildren <Tile>();
        foreach (Tile tile in newTiles)
        {
            tile.InitTile(TileVec.FromTransform(tile.transform));
            this.AddExistingTile(tile);
            if (tile.gameObject.tag == "Respawn")
            {
                this.rootTile = tile;
            }
            if (tile.macroEnvironment != null)
            {
                tile.macroEnvironment.SetActive(false);
            }
            tile.Environment.ApplySettings(EnvironmentManager.Instance.GetEnvironmentByType(tile.Environment.type));
        }
    }