Ejemplo n.º 1
0
    protected virtual void OnGUI()
    {
        generate_sprite_sheet_image = GUILayout.Toggle(generate_sprite_sheet_image, "Generate Sprite Sheet Image");
        Select_Image();

        if (img == null)
        {
            return;
        }

        if (GUILayout.Button("Generate Tiles"))
        {
            //generate the floating tile. They are A2 style tile
            A2_Tiles_Importer_Window.Generate_Tiles(path, sub_blocks_floating, sub_blocks_floating_to_import,
                                                    mini_tile_w, mini_tile_h, wBlock, hBlock, generate_sprite_sheet_image);

            //generate waterfall tile style
            Generate_Twister_Tiles(path, sub_blocks_twister, sub_blocks_twister_to_import,
                                   mini_tile_w, mini_tile_h, wBlock, hBlock, generate_sprite_sheet_image);

            //generate the animated A1 style tile
            Generate_Water_Tiles(path, sub_blocks_water, sub_blocks_water_to_import,
                                 mini_tile_w, mini_tile_h, wBlock, hBlock, generate_sprite_sheet_image);
        }
        GUILayout.Label("Select the tile you want to import, then click the 'Generate Tiles' Button");
        //can select or deselect all
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Select All"))
        {
            if (sub_blocks_floating_to_import != null)
            {
                for (int i = 0; i < sub_blocks_floating_to_import.Count; i++)
                {
                    sub_blocks_floating_to_import[i] = true;
                }
            }

            if (sub_blocks_twister_to_import != null)
            {
                for (int i = 0; i < sub_blocks_twister_to_import.Count; i++)
                {
                    sub_blocks_twister_to_import[i] = true;
                }
            }

            if (sub_blocks_water_to_import != null)
            {
                for (int i = 0; i < sub_blocks_water_to_import.Count; i++)
                {
                    sub_blocks_water_to_import[i] = true;
                }
            }
        }
        if (GUILayout.Button("Select None"))
        {
            if (sub_blocks_floating_to_import != null)
            {
                for (int i = 0; i < sub_blocks_floating_to_import.Count; i++)
                {
                    sub_blocks_floating_to_import[i] = false;
                }
            }

            if (sub_blocks_twister_to_import != null)
            {
                for (int i = 0; i < sub_blocks_twister_to_import.Count; i++)
                {
                    sub_blocks_twister_to_import[i] = false;
                }
            }

            if (sub_blocks_water_to_import != null)
            {
                for (int i = 0; i < sub_blocks_water_to_import.Count; i++)
                {
                    sub_blocks_water_to_import[i] = false;
                }
            }
        }
        GUILayout.EndHorizontal();
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, true, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar);
        GUILayout.BeginVertical();
        if (sub_blocks_water != null && sub_blocks_water.Count != 0)
        {
            int frame = (frameCount / 100) % animFrame;
            frame = (animFrame == 4) ? (frame < 3 ? frame : 1) : ((frameCount / 100) % 4);
            GUILayout.Space(10);
            GUILayout.Label("Animated Water Tile");
            GUILayout.BeginHorizontal();
            for (int i = 0; i < sub_blocks_water.Count; i += (animFrame - 1))
            {
                Texture2D sub_water = sub_blocks_water[i + frame];
                sub_blocks_water_to_import[i / (animFrame - 1)] = GUILayout.Toggle(sub_blocks_water_to_import[i / (animFrame - 1)], sub_water);
            }
            GUILayout.EndHorizontal();
        }

        if (sub_blocks_twister != null && sub_blocks_twister.Count != 0)
        {
            GUILayout.Label("Animated Water fall/twister Tile");
            GUILayout.BeginHorizontal();
            for (int i = 0; i < sub_blocks_twister.Count; i += 1)
            {
                //Texture2D sub_twister = sub_blocks_twister[i];
                int ff = (frameCount / 30) % 3;
                if (waterFallFrame_Animation != null && waterFallFrame_Animation.Count != 0)
                {
                    Texture2D sub_twister = waterFallFrame_Animation[i][ff];
                    sub_blocks_twister_to_import[i] = GUILayout.Toggle(sub_blocks_twister_to_import[i], sub_twister);
                }
            }
            GUILayout.EndHorizontal();
        }

        if (sub_blocks_floating != null && sub_blocks_floating.Count != 0)
        {
            GUILayout.Label("Floating element Tile");
            GUILayout.BeginHorizontal();
            for (int i = 0; i < sub_blocks_floating.Count; i += 1)
            {
                Texture2D sub_float = sub_blocks_floating[i];
                sub_blocks_floating_to_import[i] = GUILayout.Toggle(sub_blocks_floating_to_import[i], sub_float);
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.EndVertical();
        GUILayout.EndScrollView();
    }
Ejemplo n.º 2
0
    void OnGUI()
    {
        generate_sprite_sheet_image = GUILayout.Toggle(generate_sprite_sheet_image, "Generate Sprite Sheet Image");
        if (GUILayout.Button("Load Image"))
        {
            path = EditorUtility.OpenFilePanel("Load Tile Set", ".", "*.*");
            if (path != null && path != "" && File.Exists(path) && path.Contains("A1"))
            {
                img = new Texture2D(1, 1);
                byte[] bytedata = File.ReadAllBytes(path);
                img.LoadImage(bytedata);

                //get the sliced part
                Tiles_A1_Utility.A1_Tile_Slice_File(img, out wBlock, out hBlock, out mini_tile_w, out mini_tile_h, out sub_blocks_water, out sub_blocks_twister, out sub_blocks_floating);
                sub_blocks_water_to_import = new List <bool>();
                for (int i = 0; i < sub_blocks_water.Count / 3; i++)
                {
                    sub_blocks_water_to_import.Add(false);
                }

                sub_blocks_floating_to_import = new List <bool>();
                for (int i = 0; i < sub_blocks_floating.Count; i++)
                {
                    sub_blocks_floating_to_import.Add(false);
                }

                sub_blocks_twister_to_import = new List <bool>();
                foreach (var t in sub_blocks_twister)
                {
                    sub_blocks_twister_to_import.Add(false);
                }
            }
            else
            {
                if (path != null && path != "")
                {
                    EditorUtility.DisplayDialog("Selection error!", "You have to select a file or an A1 file compatibile with RPG MAKER tile set", "OK");
                }
            }
        }

        if (img == null)
        {
            return;
        }

        if (GUILayout.Button("Generate Tiles"))
        {
            //generate the floating tile. They are A2 style tile
            A2_Tiles_Importer_Window.Generate_Tiles(path, sub_blocks_floating, sub_blocks_floating_to_import,
                                                    mini_tile_w, mini_tile_h, wBlock, hBlock, generate_sprite_sheet_image);

            //generate waterfall tile style
            Generate_Twister_Tiles(path, sub_blocks_twister, sub_blocks_twister_to_import,
                                   mini_tile_w, mini_tile_h, wBlock, hBlock, generate_sprite_sheet_image);

            //generate the animated A1 style tile
            Generate_Water_Tiles(path, sub_blocks_water, sub_blocks_water_to_import,
                                 mini_tile_w, mini_tile_h, wBlock, hBlock, generate_sprite_sheet_image);
        }
        GUILayout.Label("Select the tile you want to import, then click the 'Generate Tiles' Button");
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, true, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar);
        GUILayout.BeginVertical();
        GUILayout.Space(10);
        GUILayout.Label("Animated Water Tile");
        GUILayout.BeginHorizontal();
        for (int i = 0; i < sub_blocks_water.Count; i += 3)
        {
            Texture2D sub_water = sub_blocks_water[i];
            sub_blocks_water_to_import[i / 3] = GUILayout.Toggle(sub_blocks_water_to_import[i / 3], sub_water);
        }
        GUILayout.EndHorizontal();

        GUILayout.Label("Animated Water fall/twister Tile");
        GUILayout.BeginHorizontal();
        for (int i = 0; i < sub_blocks_twister.Count; i += 1)
        {
            Texture2D sub_twister = sub_blocks_twister[i];
            sub_blocks_twister_to_import[i] = GUILayout.Toggle(sub_blocks_twister_to_import[i], sub_twister);
        }
        GUILayout.EndHorizontal();

        GUILayout.Label("Floating element Tile");
        GUILayout.BeginHorizontal();
        for (int i = 0; i < sub_blocks_floating.Count; i += 1)
        {
            Texture2D sub_float = sub_blocks_floating[i];
            sub_blocks_floating_to_import[i] = GUILayout.Toggle(sub_blocks_floating_to_import[i], sub_float);
        }
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();
        GUILayout.EndScrollView();
    }