Пример #1
0
    /// <summary>
    /// Loads the board named by 'levelName'
    /// </summary>
    bool LoadBoard()
    {
        loadingBoard = true;
        allowInput   = false;
        bool success = false;

        if (TiledImporter.LevelExists(levelName))
        {
            ClearBoard();
            success = TiledImporter.Import(levelName);
            if (success)
            {
                _playerRow = startRow;
                allowInput = true;

                if (!HasMoveables(playerRow))
                {
                    Debug.LogError("Board was won with no moves. " +
                                   "Did you forget to set the 'Start Row' property? Currently " + startRow);
                }
            }
        }
        loadingBoard = false;
        return(success);
    }
Пример #2
0
 private void OnDestroy()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
Пример #3
0
 private void Awake()
 {
     if (Instance)
     {
         Debug.LogWarning("TiledImporter already in scene! Deleting myself!");
         Destroy(this);
         return;
     }
     Instance = this;
 }
Пример #4
0
        public override void OnInspectorGUI()
        {
            // Allows for default fields to be drawn
            DrawDefaultInspector();

            TiledImporter importer = (TiledImporter)target;
            GUIStyle      style    = new GUIStyle {
                richText = true
            };

            LabelField("Cell Size");
            BeginHorizontal();
            float originalWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 8f;
            PropertyField(gridX, new GUIContent("x"));
            PropertyField(gridY, new GUIContent("y"));
            PropertyField(gridZ, new GUIContent("z"));
            EditorGUIUtility.labelWidth = originalWidth;
            EndHorizontal();

            DrawLineAndHeader(style, "<b>Overwrite Flags</b>");
            DrawUILine(1);

            PropertyField(overwriteLevelGrid, new GUIContent("Overwrite Grid"));
            PropertyField(overwriteTilesetAssets, new GUIContent("Overwrite Tiles"));
            PropertyField(overwriteSpritesheetSlice, new GUIContent("Re-slice Spritesheet"));

            DrawLineAndHeader(style, $"<b>Tiled Tilemap JSON Processing - {importer.Json}.json</b>");

            if (GUILayout.Button("Process JSON and Build"))
            {
                importer.ProcessJsonThenBuild();
            }

            DrawLineAndHeader(style, "<b>Individual Processing</b>");

            ButtonGroup(("JSON", importer.ProcessJSON),
                        ("Tiles", importer.ProcessSpritesFromSheetIfNecessary),
                        ("Build", importer.BuildTileset));

            serializedObject.ApplyModifiedProperties();
        }
Пример #5
0
        private void MiMapImport_Click(object sender, EventArgs e)
        {
            if (OfMapImport.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Size size;

            try
            {
                size = TiledImporter.ImportTmx(OfMapImport.FileName, currentProject.Directory);
            } catch (Exception ex)
            {
                MessageBox.Show(this, "An error occured while importing Tiled map. Please check the file", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Debug.WriteLine(ex.StackTrace);
                return;
            }
            currentProject.Project.Maps.Add(new Map(OfMapImport.SafeFileName, size));
            LoadMaps();
        }
Пример #6
0
 void LoadBoardByAdding(int add)
 {
     LoadBoard(TiledImporter.GetLevelByAdding(levelName, add));
 }
Пример #7
0
 void LoadBoardByNumber(int num)
 {
     LoadBoard(TiledImporter.GetLevelByNumber(levelName, num));
 }