Advertisement
ItzEdInYourBed

CLONE! Paste/Au53X2m7

May 9th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 40.22 KB | None | 0 0
  1. // Copyright (C) 2018-2019 gamevanilla. All rights reserved.
  2. // This code can only be used under the standard Unity Asset Store End User License Agreement,
  3. // a copy of which is available at http://unity3d.com/company/legal/as_terms.
  4.  
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Linq;
  9. using Tutorial.Information;
  10. using UnityEditor;
  11. using UnityEditorInternal;
  12. using UnityEngine;
  13. using Object = UnityEngine.Object;
  14. using Random = UnityEngine.Random;
  15.  
  16. namespace BubbleShooterKit
  17. {
  18.     /// <summary>
  19.     /// The 'Level editor' tab in the editor.
  20.     /// </summary>
  21.     public class LevelEditorTab : EditorTab
  22.     {
  23.         private Object levelDbObj;
  24.         private LevelInfo currentLevelInfo;
  25.  
  26.         private Vector2 scrollPos;
  27.  
  28.         private const float LevelTileButtonSize = 40f;
  29.  
  30.         private enum BrushType
  31.         {
  32.             Bubble,
  33.             RandomBubble,
  34.             Booster,
  35.             Blocker,
  36.             Cover,
  37.             Collectable,
  38.             CollectableOldColor,
  39.             CollectableRandomColor,
  40.             Empty
  41.         }
  42.  
  43.         private BrushType currentBrushType;
  44.         private ColorBubbleType currentColorBubbleType;
  45.         private RandomBubbleType currentRandomBubbleType;
  46.         private BoosterBubbleType currentBoosterBubbleType;
  47.         private BlockerBubbleType currentBlockerBubbleType;
  48.         private CoverType currentCoverType;
  49.         private CollectableBubbleType currentCollectableBubbleType;
  50.  
  51.         private enum BrushMode
  52.         {
  53.             Tile,
  54.             Row,
  55.             Column,
  56.             Fill
  57.         }
  58.  
  59.         private BrushMode currentBrushMode;
  60.        
  61.         private readonly Dictionary<string, Texture> tileTextures = new Dictionary<string, Texture>();
  62.  
  63.         private int prevRows, precColumns;
  64.         private int tempRows, tempColumn;
  65.  
  66.         private ReorderableList availableColorsList;
  67.         private ColorBubbleType currentColor;
  68.  
  69.         private ReorderableList goalList;
  70.         private LevelGoal currentGoal;
  71.        
  72.         public LevelEditorTab(BubbleShooterKitEditor editor) : base(editor)
  73.         {
  74.             //var editorImagesPath = new DirectoryInfo(Application.dataPath + "/BubbleShooterKit/Editor/Resources");
  75.             var path = Application.dataPath + "/Editor/Resources";
  76.            
  77.            
  78.            
  79.             //Debug.LogError("Path: " + path);
  80.             var editorImagesPath = new DirectoryInfo(path);
  81.             var fileInfo = editorImagesPath.GetFiles("*.png", SearchOption.TopDirectoryOnly);
  82.             foreach (var file in fileInfo)
  83.             {
  84.                 var filename = Path.GetFileNameWithoutExtension(file.Name);
  85.                 tileTextures[filename] = Resources.Load(filename) as Texture;
  86.             }
  87.         }
  88.  
  89.         public void DebugLog()
  90.         {
  91.            
  92.         }
  93.         public override void Draw()
  94.         {
  95.             if (currentLevelInfo != null && currentLevelInfo.tutorialInfo == null) currentLevelInfo.tutorialInfo = new TutorialInfo();
  96.             scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
  97.  
  98.             var oldLabelWidth = EditorGUIUtility.labelWidth;
  99.             EditorGUIUtility.labelWidth = 90;
  100.  
  101.             GUILayout.Space(15);
  102.  
  103.             DrawMenu();
  104.  
  105.             if (currentLevelInfo != null)
  106.             {
  107.                 GUILayout.Space(15);
  108.                
  109.                 GUILayout.BeginHorizontal();
  110.  
  111.                 DrawLevel();
  112.                
  113.                 GUILayout.BeginVertical();
  114.                 if(currentLevelInfo.tutorialInfo.isNeedTutorial) currentLevelInfo.tutorialInfo.DrawReord(currentLevelInfo);
  115.                 DrawAvailableColors();
  116.                 if(currentLevelInfo.isSetColorList) currentLevelInfo.AvalibleColorsStack.Draw(currentLevelInfo);
  117.                 DrawGoals();
  118.                 DrawAvailableBoosters();
  119.                 EditorTabInformer.OnEnterInformation(currentLevelInfo);
  120.                
  121.                 GUILayout.EndVertical();
  122.                
  123.                 GUILayout.EndHorizontal();
  124.                
  125.             }
  126.  
  127.             EditorGUIUtility.labelWidth = oldLabelWidth;
  128.             EditorGUILayout.EndScrollView();
  129.  
  130.             if (GUI.changed && currentLevelInfo!=null)
  131.                 EditorUtility.SetDirty(currentLevelInfo);
  132.         }
  133.        
  134.         private void DrawMenu()
  135.         {
  136.             var oldDb = levelDbObj;
  137.             levelDbObj = EditorGUILayout.ObjectField("Asset", levelDbObj, typeof(LevelInfo), false, GUILayout.Width(340));
  138.             if (levelDbObj != oldDb)
  139.             {
  140.                
  141.                 currentLevelInfo = (LevelInfo)levelDbObj;
  142.                 if (currentLevelInfo.AvailableColors == null)
  143.                     currentLevelInfo.Initialize();
  144.                 tempRows = currentLevelInfo.Rows;
  145.                 tempColumn = currentLevelInfo.Columns;
  146.                 //currentLevelInfo.Columns = 10;
  147.                 CreateAvailableColorsList();
  148.                 CreateGoalsList();
  149.                 currentLevelInfo.AvalibleColorsStack.CreateBubbleList();
  150.                 if(currentLevelInfo.tutorialInfo==null) currentLevelInfo.tutorialInfo = new TutorialInfo();
  151.                 currentLevelInfo.tutorialInfo.DOList();
  152.             }
  153.         }
  154.  
  155.         private void DrawLevel()
  156.         {
  157.             GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(300));
  158.            
  159.             var style = new GUIStyle
  160.             {
  161.                 fontSize = 20,
  162.                 fontStyle = FontStyle.Bold,
  163.                 normal = { textColor = Color.white }
  164.             };
  165.             EditorGUILayout.LabelField("General", style);
  166.            
  167.             GUILayout.Space(10);
  168.            
  169.             GUILayout.BeginHorizontal(GUILayout.Width(300));
  170.             EditorGUILayout.HelpBox(
  171.                 "The general settings of this level.",
  172.                 MessageType.Info);
  173.             GUILayout.EndHorizontal();
  174.  
  175.             GUILayout.BeginHorizontal();
  176.             EditorGUILayout.LabelField(new GUIContent("Is hard level", "this level is hard."),
  177.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  178.             currentLevelInfo.isHardLevel = EditorGUILayout.Toggle(currentLevelInfo.isHardLevel, GUILayout.Width(30));
  179.             GUILayout.EndHorizontal();
  180.            
  181.             GUILayout.Space(10);
  182.             GUILayout.BeginHorizontal();
  183.             EditorGUILayout.LabelField(new GUIContent("Level number", "The number of this level."),
  184.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  185.             currentLevelInfo.Number = EditorGUILayout.IntField(currentLevelInfo.Number, GUILayout.Width(30));
  186.             GUILayout.EndHorizontal();
  187.            
  188.             GUILayout.Space(10);
  189.            
  190.            
  191.             GUILayout.BeginHorizontal();
  192.             EditorGUILayout.LabelField(new GUIContent("Level key", "The enum key of this level."),
  193.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  194.             currentLevelInfo.Levelkey = (SortedLevelInfoType)EditorGUILayout.EnumPopup( currentLevelInfo.Levelkey,GUILayout.ExpandWidth(false));
  195.             //currentLevelInfo.Number = EditorGUILayout.IntField(currentLevelInfo.Number, GUILayout.Width(30));
  196.             GUILayout.EndHorizontal();
  197.            
  198.             GUILayout.Space(10);
  199.            
  200.             prevRows = currentLevelInfo.Rows;
  201.             precColumns = currentLevelInfo.Columns;
  202.            
  203.             GUILayout.BeginHorizontal();
  204.             EditorGUILayout.LabelField(new GUIContent("Rows", "The number of rows of this level."),
  205.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  206.             tempRows = EditorGUILayout.IntField(tempRows, GUILayout.Width(30));
  207.             GUILayout.EndHorizontal();
  208.             GUILayout.BeginHorizontal();
  209.             EditorGUILayout.LabelField(new GUIContent("Columns", "The number of Columns of this level."),
  210.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  211.             tempColumn = EditorGUILayout.IntField(tempColumn, GUILayout.Width(30));
  212.             GUILayout.EndHorizontal();
  213.             if (GUILayout.Button("Set size",GUILayout.ExpandWidth(false)))
  214.             {
  215.                 currentLevelInfo.Rows = tempRows;
  216.                 currentLevelInfo.Columns = tempColumn;
  217.             }
  218.            
  219.             GUILayout.Space(10);
  220.            
  221.             GUILayout.BeginHorizontal();
  222.             EditorGUILayout.LabelField(new GUIContent("Tutorial ", "Enable tutorial?"),
  223.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  224.             currentLevelInfo.tutorialInfo.isNeedTutorial = EditorGUILayout.Toggle(currentLevelInfo.tutorialInfo.isNeedTutorial, GUILayout.Width(30));
  225.             GUILayout.EndHorizontal();
  226.  
  227.             GUILayout.Space(10);
  228.            
  229.             GUILayout.BeginHorizontal();
  230.             EditorGUILayout.LabelField(new GUIContent("Bubbles", "The number of bubbles that can be used in this level."),
  231.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  232.             currentLevelInfo.NumBubbles = EditorGUILayout.IntField(currentLevelInfo.NumBubbles, GUILayout.Width(30));
  233.             GUILayout.EndHorizontal();
  234.            
  235.             GUILayout.BeginHorizontal();
  236.             EditorGUILayout.LabelField(new GUIContent("Need time to level", "If need time in level to game over."),
  237.                 GUILayout.Width(150));
  238.             currentLevelInfo.IsNeedTime = EditorGUILayout.Toggle(currentLevelInfo.IsNeedTime);
  239.             if (currentLevelInfo.IsNeedTime)
  240.             {
  241.                 EditorGUILayout.LabelField(new GUIContent("Time at level", "Level time in seconds."),
  242.                     GUILayout.Width(140));
  243.                 currentLevelInfo.TimeToLevel =
  244.                     EditorGUILayout.FloatField(currentLevelInfo.TimeToLevel, GUILayout.Width(70));
  245.             }
  246.             GUILayout.EndHorizontal();
  247.            
  248.            
  249.             GUILayout.BeginHorizontal();
  250.             EditorGUILayout.LabelField(new GUIContent("Need left bubble stack"),GUILayout.Width(140));
  251.            
  252.             currentLevelInfo.isSetColorList = EditorGUILayout.Toggle(currentLevelInfo.isSetColorList);
  253.            /* if (currentLevelInfo.isSetColorList)
  254.             {
  255.                 EditorGUILayout.LabelField(new GUIContent("Bubble stack", "Bullet bubble stack"),
  256.                     GUILayout.Width(EditorGUIUtility.labelWidth));
  257.                 SerializedObject so = new SerializedObject(currentLevelInfo);
  258.                 var prop = so.FindProperty("leftBubleColors");
  259.                 so.Update();
  260.                 EditorGUILayout.PropertyField(prop, true);
  261.                 so.ApplyModifiedProperties();
  262.             }*/
  263.             GUILayout.EndHorizontal();
  264.            
  265.            
  266.            
  267.            
  268.            
  269.  
  270.             GUILayout.BeginHorizontal();
  271.             EditorGUILayout.LabelField(new GUIContent("Star 1 score", "The number of points needed to obtain the first star."),
  272.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  273.             currentLevelInfo.Star1Score = EditorGUILayout.IntField(currentLevelInfo.Star1Score, GUILayout.Width(70));
  274.             GUILayout.EndHorizontal();
  275.            
  276.             GUILayout.BeginHorizontal();
  277.             EditorGUILayout.LabelField(new GUIContent("Star 2 score", "The number of points needed to obtain the second star."),
  278.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  279.             currentLevelInfo.Star2Score = EditorGUILayout.IntField(currentLevelInfo.Star2Score, GUILayout.Width(70));
  280.             GUILayout.EndHorizontal();
  281.            
  282.             GUILayout.BeginHorizontal();
  283.             EditorGUILayout.LabelField(new GUIContent("Star 3 score", "The number of points needed to obtain the third star."),
  284.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  285.             currentLevelInfo.Star3Score = EditorGUILayout.IntField(currentLevelInfo.Star3Score, GUILayout.Width(70));
  286.             GUILayout.EndHorizontal();
  287.            
  288.             GUILayout.Space(10);
  289.            
  290.            
  291.            
  292.             GUILayout.BeginHorizontal();
  293.             EditorGUILayout.LabelField(new GUIContent("Brush type", "The type of brush to paint the level."),
  294.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  295.             currentBrushType = (BrushType)EditorGUILayout.EnumPopup(currentBrushType, GUILayout.Width(100));
  296.             GUILayout.EndHorizontal();
  297.  
  298.             switch (currentBrushType)
  299.             {
  300.                 case BrushType.Bubble:
  301.                 {
  302.                     GUILayout.BeginHorizontal();
  303.                     EditorGUILayout.LabelField(new GUIContent("Bubble type", "The bubble type to use."),
  304.                         GUILayout.Width(EditorGUIUtility.labelWidth));
  305.                     currentColorBubbleType = (ColorBubbleType)EditorGUILayout.EnumPopup(currentColorBubbleType, GUILayout.Width(100));
  306.                     GUILayout.EndHorizontal();
  307.                     currentCoverType = CoverType.None;
  308.                     break;
  309.                 }
  310.  
  311.                 case BrushType.RandomBubble:
  312.                 {
  313.                     GUILayout.BeginHorizontal();
  314.                     EditorGUILayout.LabelField(new GUIContent("Random bubble type", "The random bubble type to use."),
  315.                         GUILayout.Width(EditorGUIUtility.labelWidth));
  316.                     currentRandomBubbleType = (RandomBubbleType)EditorGUILayout.EnumPopup(currentRandomBubbleType, GUILayout.Width(100));
  317.                     GUILayout.EndHorizontal();
  318.                     currentCoverType = CoverType.None;
  319.                     break;
  320.                 }
  321.                
  322.                 case BrushType.Booster:
  323.                 {
  324.                     GUILayout.BeginHorizontal();
  325.                     EditorGUILayout.LabelField(new GUIContent("Booster type", "The booster type to use."),
  326.                         GUILayout.Width(EditorGUIUtility.labelWidth));
  327.                     currentBoosterBubbleType = (BoosterBubbleType)EditorGUILayout.EnumPopup(currentBoosterBubbleType, GUILayout.Width(100));
  328.                     GUILayout.EndHorizontal();
  329.                     currentCoverType = CoverType.None;
  330.                     break;
  331.                 }
  332.                
  333.                 case BrushType.Blocker:
  334.                 {
  335.                     GUILayout.BeginHorizontal();
  336.                     EditorGUILayout.LabelField(new GUIContent("Blocker type", "The blocker type to use."),
  337.                         GUILayout.Width(EditorGUIUtility.labelWidth));
  338.                     currentBlockerBubbleType = (BlockerBubbleType)EditorGUILayout.EnumPopup(currentBlockerBubbleType, GUILayout.Width(100));
  339.                     GUILayout.EndHorizontal();
  340.                     break;
  341.                 }
  342.                
  343.                 case BrushType.Cover:
  344.                 {
  345.                     GUILayout.BeginHorizontal();
  346.                     EditorGUILayout.LabelField(new GUIContent("Cover type", "The cover type to use."),
  347.                         GUILayout.Width(EditorGUIUtility.labelWidth));
  348.                     currentCoverType = (CoverType)EditorGUILayout.EnumPopup(currentCoverType, GUILayout.Width(100));
  349.                     GUILayout.EndHorizontal();
  350.                     break;
  351.                 }
  352.                
  353.                 case BrushType.Collectable:
  354.                 {
  355.                     GUILayout.BeginHorizontal();
  356.                     EditorGUILayout.LabelField(new GUIContent("Collectable type", "The collectable type to use."),
  357.                         GUILayout.Width(EditorGUIUtility.labelWidth));
  358.                     currentCollectableBubbleType = (CollectableBubbleType)EditorGUILayout.EnumPopup(currentCollectableBubbleType, GUILayout.Width(100));
  359.                     if(currentCollectableBubbleType == CollectableBubbleType.Crystal || currentCollectableBubbleType == CollectableBubbleType.Reward)
  360.                     {
  361.                             currentColorBubbleType = (ColorBubbleType)EditorGUILayout.EnumPopup(currentColorBubbleType, GUILayout.Width(100));
  362.                     }
  363.                     GUILayout.EndHorizontal();
  364.                     break;
  365.                 }
  366.                 case BrushType.CollectableOldColor:
  367.                 {
  368.                     GUILayout.BeginHorizontal();
  369.                     EditorGUILayout.LabelField(new GUIContent("Collectable type", "The collectable type to use."),
  370.                         GUILayout.Width(EditorGUIUtility.labelWidth));
  371.                     currentCollectableBubbleType = (CollectableBubbleType)EditorGUILayout.EnumPopup(currentCollectableBubbleType, GUILayout.Width(100));
  372.                     if (currentCollectableBubbleType == CollectableBubbleType.Crystal || currentCollectableBubbleType == CollectableBubbleType.Reward)
  373.                     {
  374.                         currentColorBubbleType = (ColorBubbleType)EditorGUILayout.EnumPopup(currentColorBubbleType, GUILayout.Width(100));
  375.                     }
  376.                     GUILayout.EndHorizontal();
  377.                     break;
  378.                 }case BrushType.CollectableRandomColor:
  379.                 {
  380.                     GUILayout.BeginHorizontal();
  381.                     EditorGUILayout.LabelField(new GUIContent("Collectable type", "The collectable type to use."),
  382.                         GUILayout.Width(EditorGUIUtility.labelWidth));
  383.                     currentCollectableBubbleType = (CollectableBubbleType)EditorGUILayout.EnumPopup(currentCollectableBubbleType, GUILayout.Width(100));
  384.                     if (currentCollectableBubbleType == CollectableBubbleType.Crystal || currentCollectableBubbleType == CollectableBubbleType.Reward)
  385.                     {
  386.                         currentRandomBubbleType = (RandomBubbleType)EditorGUILayout.EnumPopup(currentRandomBubbleType, GUILayout.Width(100));
  387.                     }
  388.                     GUILayout.EndHorizontal();
  389.                     break;
  390.                 }
  391.             }
  392.            
  393.             GUILayout.BeginHorizontal();
  394.             EditorGUILayout.LabelField(new GUIContent("Brush mode", "The brush mode to paint the level."),
  395.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  396.             currentBrushMode = (BrushMode)EditorGUILayout.EnumPopup(currentBrushMode, GUILayout.Width(100));
  397.             GUILayout.EndHorizontal();
  398.  
  399.             if (GUILayout.Button("Randomize", GUILayout.Width(100)))
  400.                 RandomizeLevel();
  401.            
  402.             GUILayout.Space(10);
  403.  
  404.  
  405.            
  406.            
  407.            
  408.             if (currentLevelInfo.Rows != prevRows || currentLevelInfo.Columns!= precColumns)
  409.             {
  410.                 /*if (currentLevelInfo.Tiles != null)
  411.                 {
  412.                     foreach (var row in currentLevelInfo.Tiles)
  413.                         foreach (var tile in row.Tiles)
  414.                             Object.DestroyImmediate(tile, true);
  415.                    
  416.                     foreach (var row in currentLevelInfo.Tiles)
  417.                         Object.DestroyImmediate(row, true);
  418.                 }*/
  419.  
  420.                 /*if (currentLevelInfo.Rows > 0 && currentLevelInfo.Columns > 0)
  421.                 {
  422.                     currentLevelInfo.Tiles = new List<LevelRow>();
  423.                     var evenWidth = currentLevelInfo.Columns;
  424.                     var oddWidth = currentLevelInfo.Columns - 1;
  425.                     for (var i = 0; i < currentLevelInfo.Rows; i++)
  426.                     {
  427.                         if (i % 2 == 0)
  428.                         {
  429.                             var row = ScriptableObject.CreateInstance<LevelRow>();
  430.                             row.hideFlags = HideFlags.HideInHierarchy;
  431.                             AssetDatabase.AddObjectToAsset(row, currentLevelInfo);
  432.                             row.Tiles = new List<TileInfo>(evenWidth);
  433.                             row.Tiles.AddRange(Enumerable.Repeat<TileInfo>(null, evenWidth));
  434.                             currentLevelInfo.Tiles.Add(row);
  435.                         }
  436.                         else
  437.                         {
  438.                             var row = ScriptableObject.CreateInstance<LevelRow>();
  439.                             row.hideFlags = HideFlags.HideInHierarchy;
  440.                             AssetDatabase.AddObjectToAsset(row, currentLevelInfo);
  441.                             row.Tiles = new List<TileInfo>(oddWidth);
  442.                             row.Tiles.AddRange(Enumerable.Repeat<TileInfo>(null, oddWidth));
  443.                             currentLevelInfo.Tiles.Add(row);
  444.                         }
  445.                     }
  446.                 }*/
  447.                 UpdatePrewAndCurrentSize();
  448.             }
  449.  
  450.             /*if (currentLevelInfo.Tiles != null)
  451.             {
  452.                 GUILayout.BeginVertical();
  453.                 for (var i = 0; i < currentLevelInfo.Tiles.Count; i++)
  454.                 {
  455.                     GUILayout.BeginHorizontal();
  456.                     if (i % 2 == 1) GUILayout.Space(LevelTileButtonSize * 0.65f);
  457.                     var row = currentLevelInfo.Tiles[i];
  458.                     if(row!=null && row.Tiles!=null)
  459.                     for (var j = 0; j < row.Tiles.Count; j++)
  460.                     {
  461.                         CreateButton(i, j);
  462.                     }
  463.  
  464.                     GUILayout.EndHorizontal();
  465.                 }
  466.  
  467.                 GUILayout.EndVertical();
  468.             }*/
  469.  
  470.             GUILayout.EndVertical();
  471.         }
  472.  
  473.         public void UpdatePrewAndCurrentSize()
  474.         {
  475.             var evenWidth = currentLevelInfo.Columns;
  476.             var oddWidth = currentLevelInfo.Columns - 1;
  477.             if (currentLevelInfo.Rows != prevRows)
  478.             {
  479.                 List<LevelRow> TilesTemp = new List<LevelRow>();
  480.  
  481.                
  482.                 if (currentLevelInfo.Rows < prevRows)
  483.                 {
  484.                     for (int i = 0; i < prevRows; i++)
  485.                     {
  486.                         if(i<currentLevelInfo.Rows) TilesTemp.Add(currentLevelInfo.Tiles[i]);
  487.                         else
  488.                         {
  489.                             foreach (var tile in currentLevelInfo.Tiles[i].Tiles)
  490.                             {
  491.                                 Object.DestroyImmediate(tile, true);
  492.                             }
  493.                             Object.DestroyImmediate(currentLevelInfo.Tiles[i], true);
  494.                         }
  495.                     }
  496.                 }
  497.                 else
  498.                 {
  499.                     for (int i = 0; i < currentLevelInfo.Rows; i++)
  500.                     {
  501.                         if(i<prevRows) TilesTemp.Add(currentLevelInfo.Tiles[i]);
  502.                         else
  503.                         {
  504.                             if (i % 2 == 0)
  505.                             {
  506.                                 var row = ScriptableObject.CreateInstance<LevelRow>();
  507.                                 row.hideFlags = HideFlags.HideInHierarchy;
  508.                                 AssetDatabase.AddObjectToAsset(row, currentLevelInfo);
  509.                                 row.Tiles = new List<TileInfo>(evenWidth);
  510.                                 row.Tiles.AddRange(Enumerable.Repeat<TileInfo>(null, evenWidth));
  511.                                 TilesTemp.Add(row);
  512.                             }
  513.                             else
  514.                             {
  515.                                 var row = ScriptableObject.CreateInstance<LevelRow>();
  516.                                 row.hideFlags = HideFlags.HideInHierarchy;
  517.                                 AssetDatabase.AddObjectToAsset(row, currentLevelInfo);
  518.                                 row.Tiles = new List<TileInfo>(oddWidth);
  519.                                 row.Tiles.AddRange(Enumerable.Repeat<TileInfo>(null, oddWidth));
  520.                                 TilesTemp.Add(row);
  521.                             }
  522.                         }
  523.                     }
  524.                 }
  525.  
  526.                 currentLevelInfo.Tiles = TilesTemp;
  527.             }
  528.  
  529.             if (currentLevelInfo.Columns != precColumns)
  530.             {
  531.                 List<LevelRow> TilesTemp = new List<LevelRow>();
  532.                 for (int i = 0; i < currentLevelInfo.Tiles.Count(); i++)
  533.                 {
  534.                     var lst = new List<TileInfo>();
  535.                     var currentTile = currentLevelInfo.Tiles[i];
  536.                     bool isOdd = i % 2 != 0;
  537.                     if (currentLevelInfo.Columns < precColumns)
  538.                     {
  539.                         for (int j = 0; j < currentTile.Tiles.Count; j++)
  540.                         {
  541.                             if (j < (isOdd ? currentLevelInfo.Columns - 1 : currentLevelInfo.Columns))
  542.                             {
  543.                                 lst.Add(currentTile.Tiles[j]);
  544.                             }
  545.                             else
  546.                             {
  547.                                 Object.DestroyImmediate(currentTile.Tiles[j], true);
  548.                             }
  549.                         }
  550.                     }
  551.                     else
  552.                     {
  553.                         for (int j = 0; j < (isOdd ? currentLevelInfo.Columns-1 : currentLevelInfo.Columns); j++)
  554.                         {
  555.                             if (j < currentTile.Tiles.Count())
  556.                             {
  557.                                 lst.Add(currentTile.Tiles[j]);
  558.                             }
  559.                             else
  560.                             {
  561.                                 lst.Add(null);
  562.                             }
  563.                         }
  564.                     }
  565.  
  566.                     currentTile.Tiles = lst;
  567.  
  568.                     TilesTemp.Add(currentTile);
  569.  
  570.                 }
  571.                 currentLevelInfo.Tiles = TilesTemp;
  572.             }
  573.         }
  574.        
  575.         private void CreateGoalsList()
  576.         {
  577.             goalList = SetupReorderableList("Goals", currentLevelInfo.Goals, ref currentGoal, (rect, x) =>
  578.                 {
  579.                     EditorGUI.LabelField(new Rect(rect.x, rect.y, 200, EditorGUIUtility.singleLineHeight),
  580.                         x.ToString());
  581.                 },
  582.                 (x) =>
  583.                 {
  584.                     currentGoal = x;
  585.                 },
  586.                 () =>
  587.                 {
  588.                     var menu = new GenericMenu();
  589.                     menu.AddItem(new GUIContent("Collect bubbles"), false, CreateGoalCallback, typeof(CollectBubblesGoal));
  590.                     menu.AddItem(new GUIContent("Collect random bubbles"), false, CreateGoalCallback, typeof(CollectRandomBubblesGoal));
  591.                     menu.AddItem(new GUIContent("Collect collectables"), false, CreateGoalCallback, typeof(CollectCollectablesGoal));
  592.                     menu.AddItem(new GUIContent("Collect leaves"), false, CreateGoalCallback, typeof(CollectLeavesGoal));
  593.                     menu.ShowAsContext();
  594.                 },
  595.                 (x) =>
  596.                 {
  597.                     Object.DestroyImmediate(currentGoal, true);
  598.                     currentGoal = null;
  599.                 });
  600.         }
  601.  
  602.         private void DrawGoals()
  603.         {
  604.             GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(300));
  605.            
  606.             var style = new GUIStyle
  607.             {
  608.                 fontSize = 20,
  609.                 fontStyle = FontStyle.Bold,
  610.                 normal = { textColor = Color.white }
  611.             };
  612.             EditorGUILayout.LabelField("Goals", style);
  613.            
  614.             GUILayout.Space(10);
  615.            
  616.             GUILayout.BeginHorizontal(GUILayout.Width(300));
  617.             EditorGUILayout.HelpBox(
  618.                 "This list defines the goals needed to be achieved by the player in order to complete this level.",
  619.                 MessageType.Info);
  620.             GUILayout.EndHorizontal();
  621.  
  622.             GUILayout.BeginHorizontal();
  623.  
  624.             GUILayout.BeginVertical(GUILayout.Width(300));
  625.             goalList?.DoLayoutList();
  626.             GUILayout.EndVertical();
  627.  
  628.             if (currentGoal != null)
  629.                 DrawGoal(currentGoal);
  630.  
  631.             GUILayout.EndHorizontal();
  632.            
  633.             GUILayout.EndVertical();
  634.         }
  635.  
  636.         private void DrawGoal(LevelGoal goal)
  637.         {
  638.             var oldLabelWidth = EditorGUIUtility.labelWidth;
  639.             EditorGUIUtility.labelWidth = 60;
  640.  
  641.             switch (goal)
  642.             {
  643.                 case CollectBubblesGoal collectBubblesGoal:
  644.                     goal.Draw();
  645.                     break;
  646.                 case CollectCollectablesGoal collectCollectablesGoal:
  647.                     int CountGoal = 0;
  648.                     foreach (var row_ in currentLevelInfo.Tiles)
  649.                     {
  650.                         if(row_!=null)
  651.                             foreach (var column in row_.Tiles)
  652.                             {
  653.                                 if(column!=null)
  654.                                     switch (column)
  655.                                     {
  656.                                         case CollectableTileInfo collectableTileInfo:
  657.                                             if (collectCollectablesGoal.Type == collectableTileInfo.Type) CountGoal++;
  658.                                             break;
  659.                                         case ColectableRandomBubbleTileInfo colectableRandomBubbleTileInfo:
  660.                                             if (collectCollectablesGoal.Type == colectableRandomBubbleTileInfo.Type) CountGoal++;
  661.                                             break;
  662.                                     }
  663.                             }
  664.                     }
  665.                     goal.Draw(CountGoal);
  666.                     break;
  667.                 case CollectLeavesGoal collectLeavesGoal:
  668.                     var firstRow = currentLevelInfo.Tiles[0];
  669.                     int CountLeaves = 0;
  670.                     if(firstRow!=null)
  671.                         foreach (var item in firstRow.Tiles)
  672.                         {
  673.                             if(item!=null)
  674.                                 switch (item)
  675.                                 {
  676.                                     case BlockerTileInfo blockerTileInfo:
  677.                                         CountLeaves++;
  678.                                         break;
  679.                                     case BoosterTileInfo boosterTileInfo:
  680.                                         CountLeaves++;
  681.                                         break;
  682.                                     case BubbleTileInfo bubbleTileInfo:
  683.                                         CountLeaves++;
  684.                                         break;
  685.                                     case CollectableTileInfo collectableTileInfo:
  686.                                         CountLeaves++;
  687.                                         break;
  688.                                     case RandomBubbleTileInfo randomBubbleTileInfo:
  689.                                         CountLeaves++;
  690.                                         break;
  691.                                     case ColectableRandomBubbleTileInfo colectableRandomBubbleTileInfo:
  692.                                         CountLeaves++;
  693.                                         break;
  694.                                     case EnemyTileInfo enemyTileInfo:
  695.                                         CountLeaves++;
  696.                                         break;
  697.                                 }
  698.                         }
  699.                     goal.Draw(CountLeaves);
  700.                     break;
  701.                 case CollectRandomBubblesGoal collectRandomBubblesGoal:
  702.                     goal.Draw();
  703.                     break;
  704.                 case KillEnimyGoal killEnimyGoal:
  705.                     goal.Draw();
  706.                     break;
  707.             }
  708.            
  709.  
  710.             EditorGUIUtility.labelWidth = oldLabelWidth;
  711.         }
  712.        
  713.         private void CreateGoalCallback(object obj)
  714.         {
  715.             var goal = ScriptableObject.CreateInstance(((Type) obj).Name) as LevelGoal;
  716.             if (goal != null)
  717.             {
  718.                 goal.hideFlags = HideFlags.HideInHierarchy;
  719.                 currentLevelInfo.Goals.Add(goal);
  720.                 AssetDatabase.AddObjectToAsset(goal, currentLevelInfo);
  721.             }
  722.         }
  723.        
  724.         private void CreateAvailableColorsList()
  725.         {
  726.             availableColorsList = SetupReorderableList("Available colors", currentLevelInfo.AvailableColors, ref currentColor, (rect, x) =>
  727.                 {
  728.                     EditorGUI.LabelField(new Rect(rect.x, rect.y, 200, EditorGUIUtility.singleLineHeight),
  729.                         x.ToString());
  730.                 },
  731.                 (x) => { currentColor = x; },
  732.                 () =>
  733.                 {
  734.                     var menu = new GenericMenu();
  735.                     foreach (var color in Enum.GetValues(typeof(ColorBubbleType)))
  736.                     {
  737.                         var isUsed = currentLevelInfo.AvailableColors.Contains((ColorBubbleType)color);
  738.                         if (isUsed)
  739.                             menu.AddDisabledItem(new GUIContent(color.ToString()));
  740.                         else
  741.                             menu.AddItem(new GUIContent(color.ToString()), false, CreateColorCallback, color);
  742.                     }
  743.                     menu.ShowAsContext();
  744.                 },
  745.                 (x) => { currentColor = ColorBubbleType.Black; });
  746.         }
  747.        
  748.         private void CreateColorCallback(object obj)
  749.         {
  750.             currentLevelInfo.AvailableColors.Add((ColorBubbleType)obj);
  751.         }
  752.        
  753.         private void DrawAvailableColors()
  754.         {
  755.             GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(300));
  756.            
  757.             var style = new GUIStyle
  758.             {
  759.                 fontSize = 20,
  760.                 fontStyle = FontStyle.Bold,
  761.                 normal = { textColor = Color.white }
  762.             };
  763.             EditorGUILayout.LabelField("Available colors", style);
  764.            
  765.             GUILayout.Space(10);
  766.            
  767.             GUILayout.BeginHorizontal(GUILayout.Width(300));
  768.             EditorGUILayout.HelpBox(
  769.                 "This list defines the available bubble colors in this level.",
  770.                 MessageType.Info);
  771.             GUILayout.EndHorizontal();
  772.  
  773.             GUILayout.BeginHorizontal();
  774.  
  775.             GUILayout.BeginVertical(GUILayout.Width(300));
  776.             availableColorsList?.DoLayoutList();
  777.             GUILayout.EndVertical();
  778.  
  779.             GUILayout.EndHorizontal();
  780.            
  781.             GUILayout.EndVertical();
  782.         }
  783.  
  784.         private void DrawAvailableBoosters()
  785.         {
  786.             GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(300));
  787.            
  788.             var style = new GUIStyle
  789.             {
  790.                 fontSize = 20,
  791.                 fontStyle = FontStyle.Bold,
  792.                 normal = { textColor = Color.white }
  793.             };
  794.             EditorGUILayout.LabelField("Available boosters", style);
  795.            
  796.             GUILayout.Space(10);
  797.            
  798.             GUILayout.BeginHorizontal(GUILayout.Width(300));
  799.             EditorGUILayout.HelpBox(
  800.                 "Cumulative booster.",
  801.                 MessageType.Info);
  802.             GUILayout.EndHorizontal();
  803.            
  804.             GUILayout.BeginHorizontal();
  805.             EditorGUILayout.LabelField(new GUIContent("Left enable", "Left cumulative booster enable state"),
  806.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  807.             currentLevelInfo.isLeftBoosterEnabled = EditorGUILayout.Toggle(currentLevelInfo.isLeftBoosterEnabled);
  808.             GUILayout.EndHorizontal();
  809.            
  810.             GUILayout.BeginHorizontal();
  811.             EditorGUILayout.LabelField(new GUIContent("Right enable", "Right cumulative booster enable state"),
  812.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  813.             currentLevelInfo.isRightBoosterEnabled = EditorGUILayout.Toggle(currentLevelInfo.isRightBoosterEnabled);
  814.             GUILayout.EndHorizontal();
  815.            
  816.            
  817.             GUILayout.BeginHorizontal(GUILayout.Width(300));
  818.             EditorGUILayout.HelpBox(
  819.                 "Here you can specify the available purchasable boosters for this level.",
  820.                 MessageType.Info);
  821.             GUILayout.EndHorizontal();
  822.  
  823.             GUILayout.BeginHorizontal();
  824.             EditorGUILayout.LabelField(new GUIContent("Super aim", "Super aim."),
  825.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  826.             currentLevelInfo.IsSuperAimAvailable = EditorGUILayout.Toggle(currentLevelInfo.IsSuperAimAvailable);
  827.             GUILayout.EndHorizontal();
  828.            
  829.             GUILayout.BeginHorizontal();
  830.             EditorGUILayout.LabelField(new GUIContent("Rainbow bomb", "Rainbow bomb."),
  831.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  832.             currentLevelInfo.IsRainbowBombAvailable = EditorGUILayout.Toggle(currentLevelInfo.IsRainbowBombAvailable);
  833.             GUILayout.EndHorizontal();
  834.            
  835.             GUILayout.BeginHorizontal();
  836.             EditorGUILayout.LabelField(new GUIContent("undone", "Endone."),
  837.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  838.             currentLevelInfo.IsHorizontalBombAvailable = EditorGUILayout.Toggle(currentLevelInfo.IsHorizontalBombAvailable);
  839.             GUILayout.EndHorizontal();
  840.            
  841.             GUILayout.BeginHorizontal();
  842.             EditorGUILayout.LabelField(new GUIContent("Sun super bomb", "Sun super bomb."),
  843.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  844.             currentLevelInfo.IsCircleBombAvailable = EditorGUILayout.Toggle(currentLevelInfo.IsCircleBombAvailable);
  845.             GUILayout.EndHorizontal();
  846.            
  847.             GUILayout.BeginHorizontal();
  848.             EditorGUILayout.LabelField(new GUIContent("Show 3 bubble", "3 bubble."),
  849.                 GUILayout.Width(EditorGUIUtility.labelWidth));
  850.             currentLevelInfo.Is3BubbleAvailable = EditorGUILayout.Toggle(currentLevelInfo.Is3BubbleAvailable);
  851.             GUILayout.EndHorizontal();
  852.            
  853.             GUILayout.EndVertical();
  854.         }
  855.  
  856.         private void CreateButton(int row, int column)
  857.         {
  858.             var tileTypeName = string.Empty;
  859.             if (currentLevelInfo.Tiles.Count == 0) return;
  860.             var tile = currentLevelInfo.Tiles[row].Tiles[column];
  861.             if (tile != null)
  862.             {
  863.                 var bubbleTile = tile as BubbleTileInfo;
  864.                 if (bubbleTile != null)
  865.                 {
  866.                     tileTypeName = $"{bubbleTile.Type.ToString()}Bubble";
  867.                     if (bubbleTile.CoverType != CoverType.None)
  868.                         tileTypeName += "_" + bubbleTile.CoverType;
  869.                 }
  870.  
  871.                 var randomBubbleTile = tile as RandomBubbleTileInfo;
  872.                 if (randomBubbleTile != null)
  873.                 {
  874.                     tileTypeName = $"{randomBubbleTile.Type.ToString()}";
  875.                     if (randomBubbleTile.CoverType != CoverType.None)
  876.                         tileTypeName += "_" + randomBubbleTile.CoverType;
  877.                 }
  878.  
  879.                 var blockerTile = tile as BlockerTileInfo;
  880.                 if (blockerTile != null)
  881.                     tileTypeName = $"{blockerTile.BubbleType.ToString()}";
  882.  
  883.                 var boosterTile = tile as BoosterTileInfo;
  884.                 if (boosterTile != null)
  885.                     tileTypeName = $"{boosterTile.BubbleType.ToString()}";
  886.                
  887.                 var collectableTile = tile as CollectableTileInfo;
  888.                 if (collectableTile != null)
  889.                 {
  890.                     tileTypeName = $"{collectableTile.Type.ToString()}";
  891.                     var inImage =  $"{collectableTile.colorType.ToString()}Bubble";
  892.                     var color = collectableTile.colorType.ToString();
  893.                     var inText = "C " + color[0] + color[1] + color[2];
  894.                     DrawButton(tileTextures[tileTypeName], tileTextures[inImage], "", () => { DrawTile(row, column); });
  895.                     /*if (GUILayout.Button(tileTextures[tileTypeName], inText, GUILayout.Width(LevelTileButtonSize),GUILayout.Height(LevelTileButtonSize)))
  896.                         DrawTile(row, column);*/
  897.                     return;
  898.                 }
  899.                 var collectableRandom = tile as ColectableRandomBubbleTileInfo;
  900.                 if (collectableRandom != null)
  901.                 {
  902.                     tileTypeName = $"{collectableRandom.Type.ToString()}";
  903.                     var inImage = $"{collectableRandom.TypeRandom.ToString()}";
  904.                     //GUILayout.Box(tileTextures[inImage], GUILayout.Width(LevelTileButtonSize),GUILayout.Height(LevelTileButtonSize));
  905.                     //GUI.DrawTexture(new Rect(0, 0, LevelTileButtonSize, LevelTileButtonSize), );
  906.                     var inText = "R" + ((int)collectableRandom.TypeRandom+1);
  907.                     var content = new GUIContent();
  908.                     content.text = inText;
  909.                     content.image = tileTextures[tileTypeName];
  910.                     DrawButton(tileTextures[tileTypeName], tileTextures[inImage], "", () => { DrawTile(row, column); });
  911.                     /*if (GUILayout.Button(content ,GUILayout.Width(LevelTileButtonSize),GUILayout.Height(LevelTileButtonSize)))
  912.                         DrawTile(row, column);*/
  913.                    
  914.                     return;
  915.                 }
  916.  
  917.                 if (GUILayout.Button(tileTextures[tileTypeName], GUILayout.Width(LevelTileButtonSize),GUILayout.Height(LevelTileButtonSize)))
  918.                     DrawTile(row, column);
  919.             }
  920.             else
  921.             {
  922.                 if (GUILayout.Button("", GUILayout.Width(LevelTileButtonSize),
  923.                     GUILayout.Height(LevelTileButtonSize)))
  924.                     DrawTile(row, column);
  925.             }
  926.         }
  927.  
  928.         private void DrawButton(Texture t1, Texture t2, string text, Action action)
  929.         {
  930.             var content = new GUIContent();
  931.            
  932.             var btn = new GUIStyle(GUI.skin.button);
  933.             btn.normal.background = (Texture2D)t2;
  934.             btn.hover.background = (Texture2D)t2;
  935.             btn.active.background = (Texture2D)t2;
  936.             btn.stretchHeight = false;
  937.             btn.stretchWidth = false;
  938.             content.image = t1;
  939.             content.text = text;
  940.            
  941.             if (GUILayout.Button(content, btn, GUILayout.Width(LevelTileButtonSize),
  942.                 GUILayout.Height(LevelTileButtonSize)))
  943.             {
  944.                 if(action!=null) action.Invoke();
  945.             }
  946.  
  947.         }
  948.         private void DrawTile(int row, int column)
  949.         {
  950.             switch (currentBrushMode)
  951.             {
  952.                 case BrushMode.Tile:
  953.                     currentLevelInfo.Tiles[row].Tiles[column] = DrawTile(currentLevelInfo.Tiles[row].Tiles[column], row);
  954.                     break;
  955.  
  956.                 case BrushMode.Row:
  957.                 {
  958.                     var currentRow = currentLevelInfo.Tiles[row];
  959.                     for (var i = 0; i < currentRow.Tiles.Count; i++)
  960.                     {
  961.                         currentRow.Tiles[i] = DrawTile(currentRow.Tiles[i], row);
  962.                     }
  963.                 }
  964.                     break;
  965.  
  966.                 case BrushMode.Column:
  967.                     for (var i = 0; i < currentLevelInfo.Rows; i++)
  968.                     {
  969.                         if (column < currentLevelInfo.Tiles[i].Tiles.Count)
  970.                             currentLevelInfo.Tiles[i].Tiles[column] = DrawTile(currentLevelInfo.Tiles[i].Tiles[column], row);
  971.                     }
  972.                     break;
  973.  
  974.                 case BrushMode.Fill:
  975.                     for (var j = 0; j < currentLevelInfo.Rows; j++)
  976.                     {
  977.                         var currentRow = currentLevelInfo.Tiles[j];
  978.                         for (var i = 0; i < currentRow.Tiles.Count; i++)
  979.                         {
  980.                             currentLevelInfo.Tiles[j].Tiles[i] = DrawTile(currentLevelInfo.Tiles[j].Tiles[i], row);
  981.                         }
  982.                     }
  983.                     break;
  984.             }
  985.         }
  986.  
  987.         public bool isRandom = false;
  988.         public RandomBubbleType randomType;
  989.         private TileInfo DrawTile(TileInfo tile, int row)
  990.         {
  991.             if (currentBrushType == BrushType.Cover)
  992.             {
  993.                 var info = tile as BubbleTileInfo;
  994.                 if (info != null)
  995.                 {
  996.                     info.CoverType = currentCoverType;
  997.                     return info;
  998.                 }
  999.  
  1000.                 var bubbleTileInfo = tile as RandomBubbleTileInfo;
  1001.                 if (bubbleTileInfo != null)
  1002.                 {
  1003.                     bubbleTileInfo.CoverType = currentCoverType;
  1004.                     return bubbleTileInfo;
  1005.                 }
  1006.             }
  1007.  
  1008.             var bc = tile as BubbleTileInfo;
  1009.             var bcr = tile as RandomBubbleTileInfo;
  1010.            
  1011.            
  1012.            
  1013.             if (bcr != null && currentBrushType == BrushType.CollectableOldColor)
  1014.             {
  1015.                 currentRandomBubbleType = bcr.Type;
  1016.                 isRandom = true;
  1017.             }
  1018.             if (bc != null && currentBrushType == BrushType.CollectableOldColor)
  1019.             {
  1020.                
  1021.                 var color = bc.Type;
  1022.                 currentColorBubbleType = color;
  1023.                 Debug.LogError("Get Color " + color);
  1024.             }
  1025.             Object.DestroyImmediate(tile, true);
  1026.  
  1027.             var tileInfo = GetTileInfo();
  1028.  
  1029.             if (tileInfo != null && !AssetDatabase.IsSubAsset(tileInfo))
  1030.                 AssetDatabase.AddObjectToAsset(tileInfo, currentLevelInfo.Tiles[row]);
  1031.            
  1032.             return tileInfo;
  1033.         }
  1034.        
  1035.         private TileInfo GetTileInfo()
  1036.         {
  1037.             switch (currentBrushType)
  1038.             {
  1039.                 case BrushType.Bubble:
  1040.                 {
  1041.                     var tileInfo = ScriptableObject.CreateInstance<BubbleTileInfo>();
  1042.                     tileInfo.hideFlags = HideFlags.HideInHierarchy;
  1043.                     tileInfo.Type = currentColorBubbleType;
  1044.                     tileInfo.CoverType = currentCoverType;
  1045.                     return tileInfo;
  1046.                 }
  1047.  
  1048.                 case BrushType.RandomBubble:
  1049.                 {
  1050.                     var tileInfo = ScriptableObject.CreateInstance<RandomBubbleTileInfo>();
  1051.                     tileInfo.hideFlags = HideFlags.HideInHierarchy;
  1052.                     tileInfo.Type = currentRandomBubbleType;
  1053.                     tileInfo.CoverType = currentCoverType;
  1054.                     return tileInfo;
  1055.                 }
  1056.  
  1057.                 case BrushType.Blocker:
  1058.                 {
  1059.                     var tileInfo = ScriptableObject.CreateInstance<BlockerTileInfo>();
  1060.                     tileInfo.hideFlags = HideFlags.HideInHierarchy;
  1061.                     tileInfo.BubbleType = currentBlockerBubbleType;
  1062.                     return tileInfo;
  1063.                 }
  1064.  
  1065.                 case BrushType.Booster:
  1066.                 {
  1067.                     var tileInfo = ScriptableObject.CreateInstance<BoosterTileInfo>();
  1068.                     tileInfo.hideFlags = HideFlags.HideInHierarchy;
  1069.                     tileInfo.BubbleType = currentBoosterBubbleType;
  1070.                     return tileInfo;
  1071.                 }
  1072.  
  1073.                 case BrushType.Collectable:
  1074.                 {
  1075.                     var tileInfo = ScriptableObject.CreateInstance<CollectableTileInfo>();
  1076.                     tileInfo.hideFlags = HideFlags.HideInHierarchy;
  1077.                     tileInfo.Type = currentCollectableBubbleType;
  1078.                     tileInfo.colorType = currentColorBubbleType;
  1079.                     return tileInfo;
  1080.                 }
  1081.                 case BrushType.CollectableOldColor:
  1082.                 {
  1083.                     var tileInfo = ScriptableObject.CreateInstance<CollectableTileInfo>();
  1084.                     tileInfo.hideFlags = HideFlags.HideInHierarchy;
  1085.                     tileInfo.Type = currentCollectableBubbleType;
  1086.                     tileInfo.colorType = currentColorBubbleType;
  1087.                     Debug.LogError("Set Color " + currentColorBubbleType);
  1088.                         return tileInfo;
  1089.                 }
  1090.                 case BrushType.CollectableRandomColor:
  1091.                 {
  1092.                     var tileInfo = ScriptableObject.CreateInstance<ColectableRandomBubbleTileInfo>();
  1093.                     tileInfo.hideFlags = HideFlags.HideInHierarchy;
  1094.                     tileInfo.Type = currentCollectableBubbleType;
  1095.                     tileInfo.TypeRandom = currentRandomBubbleType;
  1096.                     Debug.LogError("Set Color " + currentColorBubbleType);
  1097.                         return tileInfo;
  1098.                 }
  1099.  
  1100.                 default:
  1101.                     return null;
  1102.             }
  1103.         }
  1104.  
  1105.         private void RandomizeLevel()
  1106.         {
  1107.             for (var j = 0; j < currentLevelInfo.Rows; j++)
  1108.             {
  1109.                 for (var i = 0; i < currentLevelInfo.Tiles[j].Tiles.Count; i++)
  1110.                 {
  1111.                     var rndIdx = Random.Range(0, currentLevelInfo.AvailableColors.Count);
  1112.                     var tileInfo = ScriptableObject.CreateInstance<RandomBubbleTileInfo>();
  1113.                     tileInfo.hideFlags = HideFlags.HideInHierarchy;
  1114.                     tileInfo.Type = (RandomBubbleType)rndIdx;
  1115.                     currentLevelInfo.Tiles[j].Tiles[i] = tileInfo;
  1116.                     if (!AssetDatabase.IsSubAsset(tileInfo))
  1117.                         AssetDatabase.AddObjectToAsset(tileInfo, currentLevelInfo.Tiles[j]);
  1118.                 }
  1119.             }
  1120.         }
  1121.     }
  1122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement