Ejemplo n.º 1
0
        private void OnItemClick(object sender, int iconPosition)
        {
            var eventArgs = new IconSelectedEventArgs(_position, _iconSource.Get(iconPosition).Key);

            IconSelect?.Invoke(this, eventArgs);
        }
Ejemplo n.º 2
0
    private void OnGUI()
    {
        //scroll pos
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, false);

        //vertical space
        GUILayout.Space(30);

        #region display match data
        GUILayout.FlexibleSpace();
        GUILayout.Label("Print Match Data", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        EditorGUILayout.HelpBox("Print specified match data (zero index) or all match data into the console. ", MessageType.Info);
        EditorGUILayout.Space();
        matchToLoad = EditorGUILayout.IntField("Enter a match number:", matchToLoad);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Print Single Match Data", GUILayout.MaxWidth(150), GUILayout.MinHeight(40)))
        {
            PrintMatchData(matchToLoad);
        }
        //column test
        if (GUILayout.Button("Print All Matches", GUILayout.MaxWidth(150), GUILayout.MinHeight(40)))
        {
            PrintAllMatches();
        }
        GUILayout.EndHorizontal();
        #endregion

        /**divider line for spacing**/

        //vertical space
        GUILayout.Space(15);
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.FlexibleSpace();
        /**end divider line **/

        #region New Board Generation
        /**Section for generating new board **/
        EditorGUILayout.Space();
        GUILayout.Label("Generate a New Board", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        EditorGUILayout.HelpBox("Generate a new board. Functions similarly to starting a new game. " +
                                "Enter play mode, select settings, and press the button to generate a new board. Can generate at any time during the game but will end any match being played.", MessageType.Info);
        EditorGUILayout.Space();
        //Enter data
        newGridSize   = (GridSelect)EditorGUILayout.EnumPopup("New Board Dimensions: ", newGridSize);
        PlayerOne     = (IconSelect)EditorGUILayout.EnumPopup("Player 1 Icon: ", PlayerOne);
        PlayerTwo     = (IconSelect)EditorGUILayout.EnumPopup("Player 2 Icon: ", PlayerTwo);
        playerToStart = (Player)EditorGUILayout.EnumPopup("Player to Start: ", playerToStart);
        //Generate Button
        if (GUILayout.Button("Generate New Board"))
        {
            //check if game manager exists
            if (GameManager.instance == null)
            {
                Debug.LogError("Error: Game Manager not detected. Perhaps you need to start a game first?");
                return;
            }
            //check if icons are different
            if (PlayerOne == PlayerTwo)
            {
                Debug.LogError("Error: Cannot set both player icons to the same icon");
                return;
            }
            else
            {
                BoardGenerator();
            }
        }
        GUILayout.FlexibleSpace();
        /**end section**/
        #endregion


        /**divider line for spacing**/

        //vertical space
        GUILayout.Space(15);
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.FlexibleSpace();
        /**end divider line **/


        #region Board State testing
        /**Section for testing board states **/
        //vertical space
        GUILayout.Space(15);
        GUILayout.Label("Board State Tester", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        EditorGUILayout.HelpBox("Test different board states. Select which player should win. Use the slider to select a specific row or column to test. Use the drop down to select which diagonal to check for. You can also set the speed between test moves" +
                                " Board must be generated before using. Will end any match currently being played or exit out of menu", MessageType.Info);

        //Test Settings
        playerToWin       = (Player)EditorGUILayout.EnumPopup("Player to Win: ", playerToWin);
        dimensionToSelect = EditorGUILayout.IntSlider("Row/Column to Test: ", dimensionToSelect, 0, BoardState.BoardDimension - 1);
        SelectDiag        = (DiagSelect)EditorGUILayout.EnumPopup("Diagonal: ", SelectDiag);
        betweenMoves      = EditorGUILayout.FloatField("Time Between Moves: ", betweenMoves);

        EditorGUILayout.Space();
        //row test
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Test Row", GUILayout.MaxWidth(150), GUILayout.MinHeight(40)))
        {
            TestRows();
        }
        //column test
        if (GUILayout.Button("Test Column", GUILayout.MaxWidth(150), GUILayout.MinHeight(40)))
        {
            TestColumns();
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.Space();
        GUILayout.BeginHorizontal();
        //diagonal test
        if (GUILayout.Button("Test Diagonal", GUILayout.MaxWidth(150), GUILayout.MinHeight(40)))
        {
            TestDiagonal();
        }
        //draw test
        if (GUILayout.Button("Test Draw", GUILayout.MaxWidth(150), GUILayout.MinHeight(40)))
        {
            TestDraw();
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.Space(); EditorGUILayout.Space();

        EditorGUILayout.HelpBox("Pressing any UI buttons, generating a map from the debug window , or starting a new test will immediately end any test. When testing all, just simply let it run through. Set the time between test either here or in the BoardStateTester inspector to set the speed between tests", MessageType.Warning);
        betweenReset = EditorGUILayout.FloatField("Time between tests: ", betweenReset);

        GUILayout.BeginHorizontal();
        //test all rows
        if (GUILayout.Button("Test All Rows", GUILayout.MaxWidth(150), GUILayout.MinHeight(40)))
        {
            TestAllRows();
        }
        //test all columns
        if (GUILayout.Button("Test All Columns", GUILayout.MaxWidth(150), GUILayout.MinHeight(40)))
        {
            TestAllCols();
        }

        //all diag test
        if (GUILayout.Button("Test ALL Diags", GUILayout.MaxWidth(150), GUILayout.MinHeight(40)))
        {
            TestAllDiags();
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("TEST ALL", GUILayout.MinHeight(40)))
        {
            TestAll();
        }


        //vertical space
        GUILayout.Space(30);


        EditorGUILayout.EndScrollView();
        #endregion
    }