Beispiel #1
0
        /// <summary>
        /// 그리드에 데이터를 출력합니다.
        /// </summary>
        /// <param name="style">프로그램인지/ 레벨인지.</param>
        /// <param name="iRow">해당 포커스가 가 있는 GridIndex.</param>
        private void SetGridInfomationDisplay(LevelStyle style, int iRow)
        {
            string projectid = (string)this.gridViewProject.GetRowCellValue(iRow, "PROJECT_ID");

            if (style == LevelStyle.Level)
            {
                dtLevel.Clear();
                dtProgram.Clear();
                dtProgram.AcceptChanges();
                dtLevel.AcceptChanges();

                try
                {
                    DataRow[] rowLevel = dsinfo.Tables[0].Select("PROJECT_ID = '" + projectid + "'", "PROJECT_LEVEL ASC");
                    for (int i = 0; i < rowLevel.Length; i++)
                    {
                        string levelname = rowLevel[i]["PROJECT_LEVEL_NAME"].ToString().Trim();
                        string levelid   = rowLevel[i]["PROJECT_LEVEL"].ToString().Trim();
                        dtLevel.Rows.Add(new object[] { projectid, levelid, levelname, "N" });
                    }



                    dtLevel.AcceptChanges();
                    gridLevel.Refresh();
                }
                catch (Exception ex)
                {
                    dtProject.RejectChanges();
                    throw ex;
                }
            }
            else
            {
                /*
                 * PROJECT_ID ,
                 * PROGRAM_ID
                 */
                try
                {
                    //string projectid = (string)this.gridViewLevel.GetRowCellValue(iRow, "PROJECT_ID");



                    DataRow[] rowProgram = dsinfo.Tables[1].Select("PROJECT_ID = '" + projectid + "'", "MENU_DISPLAY_SEQ ASC, PROGRAM_DISPLAY_SEQ ASC");
                    for (int j = 0; j < rowProgram.Length; j++)
                    {
                        dtProgram.ImportRow(rowProgram[j]);
                    }
                    dtProgram.AcceptChanges();
                    gridProgram.Refresh();
                    this.gridViewProgram.OptionsBehavior.AutoExpandAllGroups = true;
                }
                catch (Exception ex)
                {
                    dtProgram.RejectChanges();
                    throw ex;
                }
            }
        }
Beispiel #2
0
        private static void ReadStyles(XmlReader reader, OutlinerDocument rnl)
        {
            XmlReader subtree = reader.ReadSubtree();

            while (subtree.ReadToFollowing("Style"))
            {
                if (subtree.MoveToFirstAttribute())
                {
                    string type  = "Level";
                    int    level = -1;
                    if (subtree.Name == "Type")
                    {
                        type = subtree.Value;
                        if (type == "Level")
                        {
                            subtree.MoveToNextAttribute();
                        }
                    }

                    if (type == "Level")
                    {
                        if (subtree.Name != "Level")
                        {
                            continue;
                        }

                        try
                        {
                            level = int.Parse(subtree.Value);
                        }
                        catch
                        {
                            continue;
                        }
                    }

                    BaseStyle style;

                    if (type == "Inline")
                    {
                        style = rnl.Styles.InlineNoteStyle;
                    }
                    else
                    {
                        if (level <= 0)
                        {
                            style = rnl.Styles.WholeDocumentStyle;
                        }
                        else
                        {
                            style = rnl.Styles.GetStyleForLevel(level);
                        }
                    }

                    while (subtree.MoveToNextAttribute())
                    {
                        if (OutlinerStyles.StringToStylePropertyTypes.ContainsKey(subtree.Name))
                        {
                            StylePropertyType propertyType = OutlinerStyles.StringToStylePropertyTypes[subtree.Name];
                            object            value        = LevelStyle.GetValueFromString(propertyType, subtree.Value);

                            if (value != null)
                            {
                                style.AddProperty(propertyType, value);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 그리드에 데이터를 출력합니다.
        /// </summary>
        /// <param name="style">프로그램인지/ 레벨인지.</param>
        /// <param name="iRow">해당 포커스가 가 있는 GridIndex.</param>
        private void SetGridInfomationDisplay(LevelStyle style, int iRow)
        {
            if (style == LevelStyle.Level)
            {
                string projectid = (string)this.gridViewProject.GetRowCellValue(iRow, "PROJECT_ID");
                dtLevel.Clear();
                dtProgram.Clear();
                dtProgram.AcceptChanges();
                dtLevel.AcceptChanges();

                try
                {
                    /*
                     * T2.PROJECT_ID,
                     * T2.PROGRAM_ID,
                     * T2.PROGRAM_NAME
                     */
                    DataRow[] rowProgram = dsinfo.Tables[1].Select("PROJECT_ID = '" + projectid + "'", "MENU_DISPLAY_SEQ ASC , PROGRAM_DISPLAY_SEQ");
                    for (int j = 0; j < rowProgram.Length; j++)
                    {
                        string programid      = rowProgram[j]["PROGRAM_ID"].ToString().Trim();
                        string programname    = rowProgram[j]["PROGRAM_NAME"].ToString().Trim();
                        string menu           = rowProgram[j]["MENU"].ToString().Trim();
                        int    menudisplay    = int.Parse(rowProgram[j]["MENU_DISPLAY_SEQ"].ToString().Trim());
                        int    programdisplay = int.Parse(rowProgram[j]["PROGRAM_DISPLAY_SEQ"].ToString().Trim());
                        dtProgram.Rows.Add(new object[] { projectid, "", programid, programname, "N", menu, menudisplay, programdisplay });
                    }



                    dtProgram.AcceptChanges();
                    gridProgram.Refresh();

                    /*
                     *  T1.PROJECT_ID,
                     *  T1.PROJECT_LEVEL_NAME ,
                     *  T1.PROJECT_LEVEL
                     */
                    DataRow[] rowLevel = dsinfo.Tables[0].Select("PROJECT_ID = '" + projectid + "'", "PROJECT_LEVEL ASC");
                    for (int i = 0; i < rowLevel.Length; i++)
                    {
                        string levelname = rowLevel[i]["PROJECT_LEVEL_NAME"].ToString().Trim();
                        string levelid   = rowLevel[i]["PROJECT_LEVEL"].ToString().Trim();
                        dtLevel.Rows.Add(new object[] { projectid, levelid, levelname });
                    }



                    dtLevel.AcceptChanges();
                    gridLevel.Refresh();
                }
                catch (Exception ex)
                {
                    dtProject.RejectChanges();
                    throw ex;
                }
            }
            else
            {
                /*
                 * PROJECT_ID ,
                 * PROJECT_LEVEL ,
                 * PROGRAM_ID
                 */
                try
                {
                    string projectid = (string)this.gridViewLevel.GetRowCellValue(iRow, "PROJECT_ID");
                    string levelid   = (string)this.gridViewLevel.GetRowCellValue(iRow, "LEVEL");

                    //모든 프로그램에 레벨을 셋팅한다.


                    for (int i = 0; i < dtProgram.Rows.Count; i++)
                    {
                        dtProgram.Rows[i]["LEVEL"]  = levelid;
                        dtProgram.Rows[i]["USE_YN"] = "N";
                        string programid = dtProgram.Rows[i]["PROGRAM_ID"].ToString().Trim();

                        DataRow findRow = dsinfo.Tables[2].Rows.Find(new object[] { projectid, levelid, programid });
                        if (findRow != null)
                        {
                            dtProgram.Rows[i]["USE_YN"] = "Y";
                        }
                    }


                    dtProgram.AcceptChanges();
                    dtLevel.AcceptChanges();
                }
                catch (Exception ex)
                {
                    dtProgram.RejectChanges();
                    dtLevel.RejectChanges();
                    throw ex;
                }
            }
        }
Beispiel #4
0
        public void OnGUI()
        {
            // First, we create a GUI combo box element
            _currentLevelStyle = (LevelStyle)EditorGUILayout.EnumPopup("Level style", _currentLevelStyle);

            // Then, upon the button press we add all the assets in the "Auto setup" folder on our scene
            if (GUILayout.Button("Setup"))
            {
                // First, get an absolute path of our current project and an Auto setup folder in it
                var setupFilesRootPath = Application.dataPath + "/Prefabs/Auto setup";

                // For each file found in this folder
                foreach (var file in Directory.GetFiles(setupFilesRootPath))
                {
                    // We only get .prefab files, skipping the .meta ones
                    if (file.EndsWith(".prefab"))
                    {
                        // Simple regular expression to get relative path to the asset
                        var relativePathMatch = Regex.Match(file, @"(Assets/.+)");
                        // If the regular expression matching was successfull
                        if (relativePathMatch.Success)
                        {
                            // We extract matched value (it will be our asset path)
                            var relativePath = relativePathMatch.Groups[0].Value;
                            // Then we load that asset to the main memory, so we can Instantiate it later
                            var asset = AssetDatabase.LoadAssetAtPath(relativePath, typeof(GameObject));

                            // Helping object so we can replace the "(Clone)" in its name later
                            Object newAsset;

                            // Trying to find an object on the scene
                            var presentGameObject = GameObject.Find(asset.name);
                            // If there's one
                            if (presentGameObject != null)
                            {
                                // We destroy it first
                                DestroyImmediate(presentGameObject);
                            }
                            // And we create
                            newAsset = PrefabUtility.InstantiatePrefab(asset);

                            // Then we replace that nasty "(Clone)" string in it's name so we can find it later
                            newAsset.name = newAsset.name.Replace("(Clone)", "");
                        }
                    }
                }

                // Filling the level with Grid tile of selected style
                var gridPath = "Assets/Prefabs/Levels/" + _currentLevelStyle.ToString() + "/Grid.prefab";
                var gridAsset = AssetDatabase.LoadAssetAtPath(gridPath, typeof(GameObject));
                var halfLevelWidth = FindObjectOfType<AdjustCameraHeight>().ActiveZoneWidth / 2f;
                var halfLevelHeght = FindObjectOfType<Camera>().orthographicSize;

                var gridRoot = DestroyAndCreate("Grid root");

                // Generation our actual BG grid of the chosen theme
                for (int i = Mathf.FloorToInt(-halfLevelWidth); i <= halfLevelWidth + 1; i++)
                {
                    for (int j = Mathf.FloorToInt(-halfLevelHeght); j <= Mathf.CeilToInt(halfLevelHeght); j++)
                    {
                        var grid = Instantiate(gridAsset) as GameObject;
                        grid.transform.position = new Vector3(i, j);
                        grid.transform.SetParent(gridRoot.transform);
                    }
                }
            }
        }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        LevelStyle levelStyle = (LevelStyle)target;

        var centeredStyle = GUI.skin.GetStyle("Label");

        centeredStyle.alignment = TextAnchor.UpperCenter;
        centeredStyle.fontStyle = FontStyle.Bold;
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.Label("Level style configuration", centeredStyle);
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        GUILayout.Space(20);

        //Chunk size
        EditorGUILayout.PropertyField(serializedObject.FindProperty("chunkSize"));

        //Level size
        levelStyle.levelSizeSelector = (SizeSelector)EditorGUILayout.EnumPopup("Level Size Selector", levelStyle.levelSizeSelector);

        switch (levelStyle.levelSizeSelector)
        {
        default:
            break;

        case SizeSelector.Fixed:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("levelSize"));
            break;

        case SizeSelector.RandomRange:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("minLevelSize"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("maxLevelSize"));
            break;
        }

        //UseStartEndChunks
        EditorGUILayout.PropertyField(serializedObject.FindProperty("useStartChunks"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("useEndChunks"));
        if (levelStyle.randomChunkSprites != null && (levelStyle.randomChunkSprites.width % levelStyle.chunkSize.x != 0 || levelStyle.randomChunkSprites.height % levelStyle.chunkSize.y != 0))
        {
            EditorGUILayout.HelpBox("Random chunks texture size does not match the chunk size given.", MessageType.Error);
            GUILayout.Space(20);
        }
        else if (levelStyle.startChunkSprites != null && levelStyle.useStartChunks && (levelStyle.startChunkSprites.width % levelStyle.chunkSize.x != 0 || levelStyle.startChunkSprites.height % levelStyle.chunkSize.y != 0))
        {
            EditorGUILayout.HelpBox("Start chunks texture size does not match the chunk size given.", MessageType.Error);
            GUILayout.Space(20);
        }
        else if (levelStyle.endChunkSprites != null && levelStyle.useEndChunks && (levelStyle.endChunkSprites.width % levelStyle.chunkSize.x != 0 || levelStyle.endChunkSprites.height % levelStyle.chunkSize.y != 0))
        {
            EditorGUILayout.HelpBox("End chunks texture size does not match the chunk size given.", MessageType.Error);
            GUILayout.Space(20);
        }
        else
        {
            GUILayout.Space(40);
        }



        //Random Chunk Tile Library
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.Label("Chunks configuration", centeredStyle);
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.Space(20);



        //Start Chunk Tile Library
        if (((LevelStyle)target).useStartChunks)
        {
            displayStartLibrary = EditorGUILayout.Foldout(displayStartLibrary, "Start Chunk Tile Library", EditorStyles.foldoutHeader);
            if (displayStartLibrary)
            {
                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("startChunkSprites"), new GUIContent("Chunk atlas"));
                GUILayout.Space(5);
                SerializedProperty arrayProp = serializedObject.FindProperty("startChunkTileLibrary");
                if (arrayProp.arraySize > 0)
                {
                    EditorGUILayout.LabelField("Colors to tiles");
                }
                for (int i = 0; i < arrayProp.arraySize; ++i)
                {
                    SerializedProperty colorToTile = arrayProp.GetArrayElementAtIndex(i);
                    EditorGUILayout.PropertyField(colorToTile, new GUIContent(((LevelStyle)target).startChunkTileLibrary[i].Color.ToString("F2")));
                }
                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            }
        }
        GUILayout.Space(20);


        //Random Chunk Tile Library
        displayRandomLibrary = EditorGUILayout.Foldout(displayRandomLibrary, "Random Chunk Tile Library", EditorStyles.foldoutHeader);
        if (displayRandomLibrary)
        {
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            ((LevelStyle)target).levelChunkType = (LevelStyle.LevelChunkType)EditorGUILayout.EnumPopup("Chunk type", ((LevelStyle)target).levelChunkType);
            GUILayout.Space(5);

            switch (((LevelStyle)target).levelChunkType)
            {
            default:
                break;

            case LevelStyle.LevelChunkType.UseChunkAtlas:
                EditorGUILayout.PropertyField(serializedObject.FindProperty("randomChunkSprites"), new GUIContent("Chunk atlas"));
                SerializedProperty arrayProp = serializedObject.FindProperty("randomChunkTileLibrary");
                if (arrayProp.arraySize > 0)
                {
                    EditorGUILayout.LabelField("Colors to tiles");
                }
                for (int i = 0; i < arrayProp.arraySize; ++i)
                {
                    SerializedProperty colorToTile = arrayProp.GetArrayElementAtIndex(i);
                    EditorGUILayout.PropertyField(colorToTile, new GUIContent(((LevelStyle)target).randomChunkTileLibrary[i].Color.ToString("F2")));
                }
                break;

            case LevelStyle.LevelChunkType.GenerateRandomChunk:
                GUILayout.Label(" // Generation parameters // ", centeredStyle);
                break;
            }
            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        }
        GUILayout.Space(20);


        //End Chunk Tile Library
        if (((LevelStyle)target).useEndChunks)
        {
            displayEndLibrary = EditorGUILayout.Foldout(displayEndLibrary, "End Chunk Tile Library", EditorStyles.foldoutHeader);
            if (displayEndLibrary)
            {
                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("endChunkSprites"), new GUIContent("Chunk atlas"));
                GUILayout.Space(5);
                SerializedProperty arrayProp = serializedObject.FindProperty("endChunkTileLibrary");
                if (arrayProp.arraySize > 0)
                {
                    EditorGUILayout.LabelField("Colors to tiles");
                }
                for (int i = 0; i < arrayProp.arraySize; ++i)
                {
                    SerializedProperty colorToTile = arrayProp.GetArrayElementAtIndex(i);
                    EditorGUILayout.PropertyField(colorToTile, new GUIContent(((LevelStyle)target).endChunkTileLibrary[i].Color.ToString("F2")));
                }
                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            }
        }
        serializedObject.ApplyModifiedProperties();
    }