Ejemplo n.º 1
0
 public void UpdateTileDigMarker(LevelTile tile)
 {
     // If there is a marker already...
     if (tile.DigMarker != null)
     {
         // and the tile isn't marked for digging, or it's opened now - then remove it
         if (!tile.MarkedForDigging || tile.Opened)
         {
             GameObject.Destroy(tile.DigMarker);
         }
     }
     // If there is no marker yet...
     else
     {
         // and the tile is marked for digging - the add it
         if (tile.MarkedForDigging)
         {
             tile.DigMarker = GameObject.Instantiate(DigMarkerPrefab);
             tile.DigMarker.transform.position = LevelHelpers.WorldPosFromTilePosSetY(
                 tile.X,
                 tile.Z,
                 LevelHelpers.TileDigMarkerPositionY);
             tile.DigMarker.transform.parent = transform;
         }
     }
 }
Ejemplo n.º 2
0
    private GameObject CreateObjectOnTile(LevelTile tile, GameObject prefab, Transform parent = null, bool isWall = false)
    {
        GameObject created = GameObject.Instantiate(prefab);

        Vector3 worldPosition = isWall ?
                                LevelHelpers.WorldPosFromTilePosSetY(tile.X, tile.Z, LevelHelpers.WallPositionY)
            : LevelHelpers.WorldPosFromTilePos(tile.X, tile.Z);

        created.transform.position = worldPosition;
        created.transform.parent   = (parent == null) ? transform : parent;

        return(created);
    }