Пример #1
0
        protected override void addTile(int x, int y, int id, ulong flags)
        {
            int listTileId = id - 1;

            if (listTileId > tiles.Count - 1)
            {
                string error = String.Format("Unknown tile id {0}, last id is {1}.\nForgot to load a tileset in the linker?\nUnsuported tiled param?\n Used time : ", id, tiles.Count);
                statistics.addError(error);
                return;
            }

            TiledTileData tileData = tiles[id - 1];

            if (tileData == null)
            {
                Debug.Log("Tile " + id + " is nulll !?!?");
            }
            else if (tileData.prefab == null)
            {
                makeWarningForMissingTile(id, tileData.id);
            }
            else
            {
                //Debug.Log("fake on rajoute " + tileData.prefab.name + " (" + (id-1) + ")");

                GameObject original = tileData.prefab;
                Vector3    position = new Vector3(x, y, original.transform.position.z);
                GameObject go       = (GameObject)UnityEngine.Object.Instantiate(original);
                go.name = original.name;
                go.transform.position = position;
                go.transform.parent   = tileParent;
                applyFlipFlags(go, flags);
            }
        }
Пример #2
0
        void showTileButton(TiledTileData tile)
        {
            if (buttonsIcons != null && buttonsIcons.Count > tile.id)
            {
                GUIStyle labelStyle;
                if (selectedTile != null && tile.id == selectedTile.id)
                {
                    labelStyle        = new GUIStyle("TL SelectionButton PreDropGlow");
                    labelStyle.border = new RectOffset(10, 10, 10, 10);
                }
                else
                {
                    labelStyle        = GUI.skin.label;
                    labelStyle.border = new RectOffset(0, 0, 0, 0);
                }
                labelStyle.margin       = new RectOffset(1, 1, 1, 1);
                labelStyle.padding      = new RectOffset(0, 0, 0, 0);
                labelStyle.stretchWidth = false;

                Texture2D texture = getTextureFor(tile);
                if (GUILayout.Button(texture, labelStyle))
                {
                    buttonClick(tile.id);
                }
            }
            else
            {
                if (GUILayout.Button(tile.id + ""))
                {
                    buttonClick(tile.id);
                }
            }
        }
Пример #3
0
        protected override void addTile(int x, int y, int id)
        {
            int listTileId = id - 1;

            if (listTileId > tiles.Count - 1)
            {
                Debug.LogError("The tile id " + id + " is too far, last id is " + (tiles.Count) + ".");
                return;
            }

            TiledTileData tileData = tiles[id - 1];

            if (tileData == null)
            {
                Debug.Log("Tile " + id + " is nulll !?!?");
            }
            else if (tileData.prefab == null)
            {
                statistics.addWarning("Tile " + tileData.id + " missing, used times");
            }
            else
            {
                //Debug.Log("fake on rajoute " + tileData.prefab.name + " (" + (id-1) + ")");

                Vector3    position = new Vector3(x, y);
                GameObject original = tileData.prefab;
                GameObject go       = (GameObject)Object.Instantiate(original);
                go.name = original.name;
                go.transform.position = position;
                go.transform.parent   = parent;
            }
        }
Пример #4
0
 void showTileset()
 {
     for (int row = 0; row < selectedTileset.nbTileY; row++)
     {
         EditorGUILayout.BeginHorizontal();
         for (int col = 0; col < selectedTileset.nbTileX; col++)
         {
             TiledTileData tile = selectedTileset.getTile(row, col);
             showTileButton(tile);
         }
         EditorGUILayout.EndHorizontal();
     }
 }
Пример #5
0
 Texture2D getTextureFor(TiledTileData tile)
 {
     if (selectedTile != null && tile.id == selectedTile.id)
     {
         return(buttonsIcons[tile.id]);
     }
     else
     {
         if (tile.prefab != null)
         {
             return(buttonsIconsGray[tile.id]);
         }
         else
         {
             return(buttonsIconsInverted[tile.id]);
         }
     }
 }
Пример #6
0
        protected override void loadTile(int id, Dictionary <string, string> properties)
        {
            TiledTileData tile = tileset.tiles[id];

            tile.properties = properties;
        }
Пример #7
0
 void buttonClick(int id)
 {
     selectedTile = selectedTileset.tiles[id];
 }
Пример #8
0
 Texture2D getTextureFor(TiledTileData tile)
 {
     if(selectedTile != null && tile.id == selectedTile.id){
         return buttonsIcons[tile.id];
     }else{
         if(tile.prefab != null){
             return buttonsIconsGray[tile.id];
         }else{
             return buttonsIconsInverted[tile.id];
         }
     }
 }
Пример #9
0
 void buttonClick(int id)
 {
     selectedTile = selectedTileset.tiles[id];
 }
Пример #10
0
        void showTileButton(TiledTileData tile)
        {
            if(buttonsIcons != null && buttonsIcons.Count > tile.id){
                GUIStyle labelStyle;
                if(selectedTile != null && tile.id == selectedTile.id){
                    labelStyle = new GUIStyle("TL SelectionButton PreDropGlow");
                    labelStyle.border = new RectOffset(10,10,10,10);
                }else{
                    labelStyle = new GUIStyle();
                    labelStyle.border = new RectOffset(0,0,0,0);
                }
                labelStyle.margin = new RectOffset(1,1,1,1);
                labelStyle.padding = new RectOffset(0,0,0,0);
                labelStyle.stretchWidth = false;

                Texture2D texture = getTextureFor(tile);
                if (GUILayout.Button(texture,labelStyle)) {
                    buttonClick(tile.id);
                }
            }else{
                if (GUILayout.Button(tile.id + "")) {
                    buttonClick(tile.id);
                }
            }
        }