Esempio n. 1
0
    void OnGUI()
    {
        if (Selection.activeGameObject == null)
        {
            return;
        }
        MapEditorConverter data = Selection.activeGameObject.GetComponent <MapEditorConverter>();

        if (data != null)
        {
            GUILayout.BeginHorizontal();
            Vector2 screenPos = Event.current.mousePosition;
            for (int x = 0; x < data.mapSize.x; x++)
            {
                GUILayout.BeginVertical();
                for (int y = 0; y < data.mapSize.y; y++)
                {
                    Rect rect = new Rect(x * data.gridSize, y * data.gridSize, data.gridSize, data.gridSize);
                    GUILayout.BeginArea(rect);
                    GUIStyle style = new GUIStyle();
                    if (data.tiles[x, y] == 'G')
                    {
                        style.normal.background = data.grassTex;
                    }
                    else if (data.tiles[x, y] == 'W')
                    {
                        style.normal.background = data.waterTex;
                    }
                    if (GUILayout.Button("", style, GUILayout.Width(data.gridSize), GUILayout.Height(data.gridSize), GUILayout.ExpandWidth(false)))
                    {
                        data.ChangeMapTile(x, y);
                    }
                    GUILayout.EndArea();
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }
    }
Esempio n. 2
0
 // Start is called before the first frame update
 void Start()
 {
     editorMap = gameObject.GetComponent <MapEditorConverter>();
     TempTile[] newTiles = new TempTile[0];
     if (useEditorMap)
     {
         mapWidth              = (int)editorMap.mapSize.x;
         mapHeight             = (int)editorMap.mapSize.y;
         MAP_CORRECTION_WIDTH  = mapWidth / 2;
         MAP_CORRECTION_HEIGHT = mapHeight / 2;
         editorMap.GetArchivedMaps();
         //  newTiles = editorMap.GetTilesFromMapEditor();
         //  SetTileIDs(newTiles);
     }
     else
     {
         mapWidth              = generatedMapWidth;
         mapHeight             = generatedMapHeight;
         MAP_CORRECTION_WIDTH  = mapWidth / 2;
         MAP_CORRECTION_HEIGHT = mapWidth / 2;
         newTiles              = ProceduralGenerateMapArray(mapWidth, mapHeight);
     }
     CreateMapFromTiles(newTiles);
 }
Esempio n. 3
0
 void OnEnable()
 {
     mapData = target as MapEditorConverter;
 }