1 (edited by YumChaGames 2014-08-18 10:58:16)

Topic: Dynamic Special Commands Display & Custom Button names

I've recently enabled a basic dynamic special command display which gets all non-normal attacks of both players and puts them into a string.  While making this, I also decided to create options for my own names for the buttons should I need them elsewhere (like a button config).  This way, Button1 appears as Light Punch.  You can edit the button names in Global Input Options.

My method below only covers charge attacks and quarter circle commands, but it should be simple enough to add support for other command types if you have them. 

Something else that might be worth adding is a way to minimise multiple commands for different strengths (so you only have one Flash Kick command instead of one for each button strength).  One way I can think of is creating a bool in the Move's General section, where if checked it won't come up in command lists.  Then just check for that bool in the GUIScript loops.

You'll need to modify 3 scripts: GlobalInfo.cs, GlobalEditorWindow.cs and GUIScript.cs (or your own GUI script).

In GlobalInfo.cs, find:

[System.Serializable]
public class InputOptions {

at the end of the class, add:

public InputNaming[] inputNaming;


then right below the class, create a new class:

[System.Serializable]
public class InputNaming {
    public ButtonPress UFEButton;
    public string displayName;
}


In GlobalEditorWindow.cs, find:

private bool player2InputOptions;

below, add:

private bool inputDisplayNames;


then find:

globalInfo.inputOptions.cancelButton = (ButtonPress) EditorGUILayout.EnumPopup("Cancel Button:", globalInfo.inputOptions.cancelButton, enumStyle);

below it, add:

// Button In-game Names
                        EditorGUILayout.Space();
                        //EditorGUIUtility.labelWidth = 180;

                        inputDisplayNames = EditorGUILayout.Foldout(inputDisplayNames, "Input Display Names", foldStyle);

                        if (inputDisplayNames) {
                            EditorGUIUtility.labelWidth = 180;
                            EditorGUILayout.BeginVertical(subGroupStyle);{
                                for (int i = 0; i < globalInfo.inputOptions.inputNaming.Length; i ++){
                                    EditorGUILayout.BeginVertical(arrayElementStyle);{    
                                        EditorGUILayout.Space();
                                        EditorGUILayout.BeginHorizontal();{
                                            globalInfo.inputOptions.inputNaming[i].UFEButton = (ButtonPress) EditorGUILayout.EnumPopup("UFE Input:", globalInfo.inputOptions.inputNaming[i].UFEButton, enumStyle);
                                            globalInfo.inputOptions.inputNaming[i].displayName = EditorGUILayout.TextField("Display Name:", globalInfo.inputOptions.inputNaming[i].displayName);    
                                            if (GUILayout.Button("", removeButtonStyle)){
                                                globalInfo.inputOptions.inputNaming = RemoveElement<InputNaming>(globalInfo.inputOptions.inputNaming, globalInfo.inputOptions.inputNaming[i]);
                                                return;
                                            }
                                        }EditorGUILayout.EndHorizontal();
                                    }EditorGUILayout.EndVertical();
                                    EditorGUILayout.Space();
                                }

                                if (StyledButton("New Display Name")) {
                                    globalInfo.inputOptions.inputNaming = AddElement<InputNaming>(globalInfo.inputOptions.inputNaming, new InputNaming());
                                }

                            }EditorGUILayout.EndVertical();
                        }


In GUIScript.cs, above the Awake() add:

    // Command List stuff
    private string commandListP1;
    private string commandListP2;


then find:

isRunning = true;

and above it, add:

        // Command List GET!

        MoveSetData[] p1Moves = UFE.config.player1Character.moves;
        MoveSetData[] p2Moves = UFE.config.player2Character.moves;

        // P1
        for (var h=0;h<p1Moves.Length;h++) {
            for (var g=0;g<p1Moves[h].attackMoves.Length;g++) {
                if (p1Moves[h].attackMoves[g].attackType != AttackType.Regular) {
                    string moveCommand = "";
                    for (var i=0;i<p1Moves[h].attackMoves[g].buttonSequence.Length;i++) {
                        moveCommand += p1Moves[h].attackMoves[g].buttonSequence[i] + " ";
                    }

                    for (var j=0;j<p1Moves[h].attackMoves[g].buttonExecution.Length;j++) {
                        if (j<p1Moves[h].attackMoves[g].buttonExecution.Length-1) {
                            moveCommand += p1Moves[h].attackMoves[g].buttonExecution[j] + "+";
                        } else {
                            moveCommand += p1Moves[h].attackMoves[g].buttonExecution[j];
                        }
                    }

                    commandListP1 += p1Moves[h].attackMoves[g].moveName + ": " + moveCommand + "\n";

                }
            }
        }

        commandListP1 = commandListP1.Replace("Back Foward ", "b (hold), f+");
        commandListP1 = commandListP1.Replace("Down Up ", "d (hold), u+");
        commandListP1 = commandListP1.Replace("Down Foward ", "qcf+");
        commandListP1 = commandListP1.Replace("Down Back ", "qcb+");

        foreach (InputNaming inputName in UFE.config.inputOptions.inputNaming) {
            commandListP1 = commandListP1.Replace(inputName.UFEButton.ToString(), inputName.displayName);
        }

        // P2
        for (var k=0;k<p2Moves.Length;k++) {
            for (var l=0;l<p2Moves[k].attackMoves.Length;l++) {
                if (p2Moves[k].attackMoves[l].attackType != AttackType.Regular) {
                    string moveCommand = "";
                    for (var m=0;m<p2Moves[k].attackMoves[l].buttonSequence.Length;m++) {
                        moveCommand += p2Moves[k].attackMoves[l].buttonSequence[m] + " ";
                    }

                    for (var n=0;n<p2Moves[k].attackMoves[l].buttonExecution.Length;n++) {
                        if (n<p2Moves[k].attackMoves[l].buttonExecution.Length-1) {
                            moveCommand += p2Moves[k].attackMoves[l].buttonExecution[n] + "+";
                        } else {
                            moveCommand += p2Moves[k].attackMoves[l].buttonExecution[n];
                        }
                    }
                    
                    commandListP2 += p2Moves[k].attackMoves[l].moveName + ": " + moveCommand + "\n";
                    
                }
            }
        }
        
        commandListP2 = commandListP2.Replace("Back Foward ", "b (hold), f+");
        commandListP2 = commandListP2.Replace("Down Up ", "d (hold), u+");
        commandListP2 = commandListP2.Replace("Down Foward ", "qcf+");
        commandListP2 = commandListP2.Replace("Down Back ", "qcb+");
        
        foreach (InputNaming inputName in UFE.config.inputOptions.inputNaming) {
            commandListP2 = commandListP2.Replace(inputName.UFEButton.ToString(), inputName.displayName);
        }

        // end Command List GET!


then, find the 2nd instance of:

if (showSpecials){

Inside here, you can remove everything before the else statement, or comment it out.  Then add:

                        GUILayout.BeginHorizontal();{
                            GUILayout.Label(player1.characterName);
                            GUILayout.FlexibleSpace();
                            GUILayout.Label(player2.characterName);
                        }GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();{
                            GUILayout.Label(commandListP1);
                            GUILayout.FlexibleSpace();
                            GUILayout.Label(commandListP2);
                        }GUILayout.EndHorizontal();

I think that's all of it.  If I missed anything, or if you get errors let me know and I'll fix it up.

Share

Thumbs up +2 Thumbs down

2 (edited by YumChaGames 2014-08-21 11:10:10)

Re: Dynamic Special Commands Display & Custom Button names

Whelp!  Just realised I wasn't correctly checking for charge attacks.  It's a simple enough fix.  After doing all of the above, go back into GUIScript.cs and look for:

moveCommand += p1Moves[h].attackMoves[g].buttonSequence[i] + " ";

and replace with:

                        if (p1Moves[h].attackMoves[g].chargeMove && i==0) {
                            moveCommand += p1Moves[h].attackMoves[g].buttonSequence[i] + " (hold) ";
                        } else {
                            moveCommand += p1Moves[h].attackMoves[g].buttonSequence[i] + " ";
                        }

… then look for:

moveCommand += p2Moves[k].attackMoves[l].buttonSequence[m] + " ";

and replace with:

                        if (p2Moves[k].attackMoves[l].chargeMove && m==0) {
                            moveCommand += p2Moves[k].attackMoves[l].buttonSequence[m] + " (hold) ";
                        } else {
                            moveCommand += p2Moves[k].attackMoves[l].buttonSequence[m] + " ";
                        }

Also you'll need to fix up 4 lines of string replacements (commandListP1.Replace and commandListP2.Replace) to suit.

If it still doesn't work, let me know and I'll post corrections.

* EDIT: forgot to check only first sequence button has charge

Share

Thumbs up Thumbs down

Re: Dynamic Special Commands Display & Custom Button names

I've got 1.6 would this work for the updated version

Share

Thumbs up Thumbs down

Re: Dynamic Special Commands Display & Custom Button names

Conceptually, yes.  You would only need to alter how it displays (last section in first post), since it's not using the new Unity UI system.

Share

Thumbs up Thumbs down

Re: Dynamic Special Commands Display & Custom Button names

How do I alter the 1.6 display script

Share

Thumbs up Thumbs down

6 (edited by acidfmhq 2017-10-16 15:48:38)

Re: Dynamic Special Commands Display & Custom Button names

So I got this working by making a text component and then send the strings to textcomponet.text. Also changed how moves are displayed on the screen by making a bool and a enum that goes specialmoves,combo strings,supers.

Then I duplicated the code block and changed the if statement to the bool and then use the enum to find what type of moves it's looking for.

Then made 3 different string varaibles with 3 text components on the screens script.

To get the Screen script just duplicate UFEScreen.cs and DefaultUFEScreen.cs and rename them to CommandsScreen.cs and DefaultCommandsScreen.cs. Then you may have to remove some lines of code in the CommandsScreen.cs then just pause the code block in to the OnShow function in DefaultCommandsScreen.cs

Terrordrome Development Team Member

Re: Dynamic Special Commands Display & Custom Button names

Can you update this tutorial for the new UI system?

Share

Thumbs up Thumbs down