Beispiel #1
0
    // 보드 만들기 메뉴 함수
    void MakeMenu_Board()
    {
        GUILayout.Label("First, you need to set the board's width and height.", EditorStyles.helpBox);
        width  = EditorGUILayout.IntField("Width", width, GUILayout.Width(250.0f));
        height = EditorGUILayout.IntField("Height", height, GUILayout.Width(250.0f));
        GUILayout.Space(5.0f);
        if (GUILayout.Button("Create Board", GUILayout.Width(150.0f)))
        {
            MakeBoard(height, width);
        }

        GUILayout.Space(15.0f);
        GUILayout.Label("Choose a tile type, " +
                        "and Click the tile position button what you want to change a tile type.", EditorStyles.helpBox);
        GUILayout.Label("( Normal - black, Blank - red, Breakable - blue )", EditorStyles.helpBox);
        //GUILayout.Label("You don't need to choose 'normal'.", EditorStyles.helpBox);
        tileKind = (TileKind)EditorGUILayout.EnumPopup("Select Tile type", tileKind, GUILayout.Width(350.0f));
        for (int i = height - 1; i >= 0; i--)
        {
            EditorGUILayout.BeginHorizontal();
            for (int j = 0; j < width; j++)
            {
                if (GetTileKindWithPosition(j, i) == Normal.TileKind.Breakable)
                {
                    var style = new GUIStyle(GUI.skin.button);
                    style.normal.textColor = Color.blue;
                    style.fixedWidth       = 40.0f;

                    if (GUILayout.Button(j + ", " + i, style))
                    {
                        SetTileKindWithPosition(j, i, tileKind);
                    }
                }
                else if (GetTileKindWithPosition(j, i) == Normal.TileKind.Blank)
                {
                    var style = new GUIStyle(GUI.skin.button);
                    style.normal.textColor = Color.red;
                    style.fixedWidth       = 40.0f;

                    if (GUILayout.Button(j + ", " + i, style))
                    {
                        SetTileKindWithPosition(j, i, tileKind);
                    }
                }
                else
                {
                    var style = new GUIStyle(GUI.skin.button);
                    style.normal.textColor = Color.black;
                    style.fixedWidth       = 40.0f;

                    if (GUILayout.Button(j + ", " + i, style))
                    {
                        SetTileKindWithPosition(j, i, tileKind);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }
    }
Beispiel #2
0
    TileKind GetTileKindWithPosition(int x, int y)
    {
        TileKind tileKind = new Normal.TileKind();

        for (int i = 0; i < boardLayout.Count; i++)
        {
            if (boardLayout[i].x == x && boardLayout[i].y == y)
            {
                tileKind = boardLayout[i].tileKind;
                return(tileKind);
            }
        }

        return(TileKind.Normal);
    }