Exemplo n.º 1
0
    Tile GetTopTile(Vector2 pTileWorldPos)
    {
        if (OccupiedLayer == null)
        {
            return(null);
        }
        TilemapGroup group = OccupiedLayer.transform.parent.GetComponent <TilemapGroup>();

        if (group == null)
        {
            return(null);
        }
        //       print(group.name);
        if (group.Tilemaps.Count < 1)
        {
            return(null);
        }
        for (int i = group.Tilemaps.Count - 1; i > 0; i--)
        {
            Tile tile = group.Tilemaps[i].GetTile(pTileWorldPos);

            if (tile != null)
            {
                return(tile);
            }
        }
        return(null);
    }
Exemplo n.º 2
0
        public SpaceShipEnvironmentTicker(TilemapGroup shipTilemapGroup)
        {
            _doodadsBackgroundTilemap = shipTilemapGroup.Tilemaps.First(tilemap => tilemap.name == "DoodadsBackground");

            _shipBackgroundTilemap = shipTilemapGroup.Tilemaps.First(tilemap => tilemap.name == "ShipBackground");

            SetDirtiableTiles();
        }
Exemplo n.º 3
0
 void Awake()
 {
     compteur = FindObjectOfType <Compteur>();
     Debug.Log(compteur);
     compteur.enabled = true;
     compteur.DesactiveText();
     _tilemapGroup = GetComponentInChildren <TilemapGroup>();
     Debug.Log(_tilemapGroup);
     allRooms.Add(this);
     Debug.Log(allRooms);
 }
Exemplo n.º 4
0
    protected virtual void GetLayers()
    {
        TilemapGroup CurrentMap = GameManager.Instance.LevelInfo.CurrentMap;

        AffectedLayers.Clear();
        foreach (STETilemap layer in CurrentMap.Tilemaps)
        {
            foreach (AffectedLayer layerName in AffectedLayerNames)
            {
                if (layer.gameObject.name == layerName.Name)
                {
                    AffectedLayers.Add(layer);
                }
            }
        }
    }
Exemplo n.º 5
0
    protected override void GetLayers()
    {
        TilemapGroup CurrentMap = GameManager.Instance.LevelInfo.CurrentMap;

        AffectedLayers.Clear();
        foreach (STETilemap layer in CurrentMap.Tilemaps)
        {
            foreach (AffectedTerrain terrain in AffectedTerrains)
            {
                if (layer.gameObject.name == terrain.LayerName)
                {
                    AffectedLayers.Add(layer);
                }
            }
        }
    }
Exemplo n.º 6
0
    STETilemap GetLowerLayer(STETilemap affectedLayer)
    {
        TilemapGroup CurrentMap     = GameManager.Instance.LevelInfo.CurrentMap;
        string       lowerLayerName = string.Empty;

        foreach (AffectedTerrain terrain in AffectedTerrains)
        {
            if (terrain.LayerName == affectedLayer.name)
            {
                lowerLayerName = terrain.LowerLayerName;
                break;
            }
        }
        foreach (STETilemap layer in CurrentMap.Tilemaps)
        {
            if (layer.name == lowerLayerName)
            {
                return(layer);
            }
        }
        return(null);
    }
Exemplo n.º 7
0
 void Awake()
 {
     _tilemapGroup = GetComponentInChildren <TilemapGroup>();
     allRooms.Add(this);
     connectedDoors.AddRange(GetComponentsInChildren <Door>());
 }
Exemplo n.º 8
0
 private void Awake()
 {
     _tilemapGroup = GetComponentInChildren <TilemapGroup>();
     allRooms.Add(this);
 }
Exemplo n.º 9
0
 void Awake()
 {
     _tilemapGroup = GetComponentInChildren <TilemapGroup>();
     _anim         = GetComponent <Animator>();
     allRooms.Add(this);
 }
Exemplo n.º 10
0
        public static void ImportTmxIntoTheScene(string tmxFilePath, Tileset tileset)
        {
            string     tmxFileName = Path.GetFileNameWithoutExtension(tmxFilePath);
            TmxTilemap tilemap     = TmxTilemap.LoadFromFile(tmxFilePath);

            if (tilemap.DicTilesetTex2D.Values.Count == 0)
            {
                return;
            }

            GameObject   tilemapGroupObj = new GameObject(tmxFileName);
            TilemapGroup tilemapGroup    = tilemapGroupObj.AddComponent <TilemapGroup>();
            int          orderInLayer    = 0;

            foreach (TmxLayer layer in tilemap.Map.Layers)
            {
                GameObject tilemapObj = new GameObject(layer.Name);
                tilemapObj.transform.SetParent(tilemapGroupObj.transform);
                STETilemap tilemapBhv = tilemapObj.AddComponent <STETilemap>();
                tilemapBhv.Tileset      = tileset;
                tilemapBhv.OrderInLayer = orderInLayer++;
                tilemapBhv.IsVisible    = layer.Visible;
                tilemapBhv.TintColor    = new Color(1f, 1f, 1f, layer.Opacity);
                for (int gx = 0; gx < layer.Width; gx++)
                {
                    for (int gy = 0; gy < layer.Height; gy++)
                    {
                        int          tileIdx = gy * layer.Width + gx;
                        TmxLayerTile tile    = layer.Tiles[tileIdx];

                        //skip non valid tiles
                        if (tile.GId == 0)
                        {
                            continue;
                        }

                        int  tileId   = tilemap.GetTileAbsoluteId(tile);
                        uint tileData = tileId >= 0 ? (uint)tileId : Tileset.k_TileData_Empty;
                        if (tileData != Tileset.k_TileData_Empty)
                        {
                            // add tile flags
                            if ((tile.GId & k_FLIPPED_HORIZONTALLY_FLAG) != 0)
                            {
                                tileData |= Tileset.k_TileFlag_FlipH;
                            }
                            if ((tile.GId & k_FLIPPED_VERTICALLY_FLAG) != 0)
                            {
                                tileData |= Tileset.k_TileFlag_FlipV;
                            }
                            if ((tile.GId & k_FLIPPED_DIAGONALLY_FLAG) != 0)
                            {
                                tileData |= Tileset.k_TileFlag_Rot90;
                            }
                            //convert from tiled flip diagonal to rot90
                            if ((tileData & Tileset.k_TileFlag_Rot90) != 0)
                            {
                                if (((tile.GId & k_FLIPPED_HORIZONTALLY_FLAG) != 0) != ((tile.GId & k_FLIPPED_VERTICALLY_FLAG) != 0))
                                {
                                    tileData ^= Tileset.k_TileFlag_FlipH;
                                }
                                else
                                {
                                    tileData ^= Tileset.k_TileFlag_FlipV;
                                }
                            }
                        }
                        tilemapBhv.SetTileData(gx, layer.Height - gy - 1, tileData);
                    }
                }
                tilemapBhv.UpdateMesh();
            }
            tilemapGroup.Refresh();
        }
Exemplo n.º 11
0
 void Start()
 {
     TilemapGroup = GetComponent <TilemapGroup>();
 }
Exemplo n.º 12
0
    private Vector3 NodeToWorldPosition(Node node, Room room)
    {
        TilemapGroup tmg = room.gameObject.GetComponent <TilemapGroup>();

        return(new Vector3(node.position.x * tmg.Tilemaps[0].MapBounds.size.x, node.position.y * tmg.Tilemaps[0].MapBounds.size.y));
    }