Beispiel #1
0
    /// <summary>
    /// Generates a Dialog code.
    /// </summary>
    /// <param name='byteList'>
    /// Byte list.
    /// </param>
    /// <param name='isName'>
    /// Is name.
    /// </param>
    /// <param name='isClearMessageAfter'>
    /// Is clear message after.
    /// </param>
    /// <param name='textNameHndStr'>
    /// Text name hnd string.
    /// </param>
    /// <param name='nameText'>
    /// Name text.
    /// </param>
    /// <param name='textDialogHndStr'>
    /// Text dialog hnd string.
    /// </param>
    /// <param name='dialogText'>
    /// Dialog text.
    /// </param>
    public static void GenerateADialogCode( 
		List<byte> byteList , DialogPartData data , string textNameHndStr , string textDialogHndStr )
    {
        // Currently not show.
        #if false
        if( data.isClearScene ){
            // Clear Current Shown Scene.
            byteList.Add( Opcode.CLEAR_SCENE );
        }

        if( ! string.IsNullOrEmpty( data.sceneFilePath ) ){
            AddSceneAdditiveCode( byteList , data.sceneFilePath , data.isFadeInStart );
        }
        #endif
        /*		else{
            Debug.LogWarning( "Action:Scene data.sceneFilePath must not be null or empty." );
        }
        //*/
        switch( data.actionID ){
            case DialogPartNodeActionType.EnterActor:
                for( int i=0;i<data.enterActorEntries.Length;i++){
                    DialogPartData.ActorEntry entry= data.enterActorEntries[ i ];
        //					Debug.Log ( "ADDCODE ACTOR:" + entry.actorName );
                    Hashtable args = new Hashtable();
                    args[ "eventType" ] = data.actionID.ToString().ToLower();
                    args[ "name" ] = entry.actorName;
                    args[ "position" ] = entry.position.ToString();
                    args[ "fade" ] = entry.withFade.ToString().ToLower();
                    ByteCodeScriptTools.AddTablePairsCode( byteList , args );
                    ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
                }
                break;

            case DialogPartNodeActionType.MoveActor:
                for( int i=0;i<data.enterActorEntries.Length;i++){
                    DialogPartData.ActorEntry entry= data.enterActorEntries[ i ];
                    Hashtable args = new Hashtable();
                    args[ "eventType" ] = data.actionID.ToString().ToLower();
                    args[ "name" ] = entry.actorName;
                    args[ "position" ] = entry.position.ToString();
                    ByteCodeScriptTools.AddTablePairsCode( byteList , args );
                    ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
                }
                break;

            case DialogPartNodeActionType.ExitActor:
                for( int i=0;i<data.exitActorEntries.Length;i++){
                    DialogPartData.ActorEntry entry= data.exitActorEntries[ i ];
                    Hashtable args = new Hashtable();
                    args[ "eventType" ] = data.actionID.ToString().ToLower();
                    args[ "name" ] = entry.actorName;
                    args[ "fade" ] = entry.withFade.ToString().ToLower();
                    ByteCodeScriptTools.AddTablePairsCode( byteList , args );
                    ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
                }
                break;

            case DialogPartNodeActionType.Dialog:
                AddAudioCode( byteList , data );

                if( data.isName ){
                    AddSetTextCode( byteList , data.nameText , textNameHndStr );
                }
                else{
                    AddHideMessageCode( byteList , textNameHndStr );
                }

                AddCurrentCode( byteList ,  textDialogHndStr );
                string str = data.dialogText;
                if( ! data.isClearMessageAfter ){
                    str += System.Environment.NewLine;
                }
                ByteCodeScriptTools.AddStringCode( byteList , str );
                byteList.Add( Opcode.PRINT );
                byteList.Add( Opcode.WAIT_TOUCH );

                if( data.isClearMessageAfter ){
                    byteList.Add( Opcode.CM );
                }
                break;

        /*			case DialogPartNodeActionType.ChangeState:
                for( int i=0;i<data.exitActorEntries.Length;i++){
                    DialogPartData.ActorEntry entry= data.exitActorEntries[ i ];
                    Hashtable args = new Hashtable();
                    args[ "eventType" ] = data.actionID.ToString().ToLower();
                    args[ "name" ] = entry.actorName;
                    args[ "state" ] = entry.state;
                    args[ "fade" ] = entry.withFade.ToString().ToLower();
                    ByteCodeScriptTools.AddTablePairsCode( byteList , args );
                    ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
                }
                break;

            case DialogPartNodeActionType.Shake:
                for( int i=0;i<data.exitActorEntries.Length;i++){
                    DialogPartData.ActorEntry entry= data.exitActorEntries[ i ];
                    Hashtable args = new Hashtable();
                    args[ "eventType" ] = data.actionID.ToString().ToLower();
                    args[ "name" ] = entry.actorName;
                    ByteCodeScriptTools.AddTablePairsCode( byteList , args );
                    ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
                }
                break;
            case DialogPartNodeActionType.EnterScene:
                Hashtable args = new Hashtable();
                args[ "eventType" ] = data.actionID.ToString().ToLower();
                args[ "name" ] = data.scene.sceneName;
                args[ "fade" ] = data.scene.withFade.ToString().ToLower();
                ByteCodeScriptTools.AddTablePairsCode( byteList , args );
                ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
                break;

            case DialogPartNodeActionType.ExitScene:
                 args = new Hashtable();
                args[ "eventType" ] = data.actionID.ToString().ToLower();
                args[ "name" ] = data.scene.sceneName;
                args[ "fade" ] = data.scene.withFade.ToString().ToLower();
                ByteCodeScriptTools.AddTablePairsCode( byteList , args );
                ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
                break;
        //*/

        // Show later update...
        #if false
            case DialogPartNodeActionType.Scene:
                break;

            case DialogPartNodeActionType.ClearScene:
                byteList.Add( Opcode.CLEAR_SCENE );
                break;

            case DialogPartNodeActionType.PlayAnimation:
                if( data.isAnim ){
                    byteList.Add( Opcode.PLAY_ANIMATION );
                    byteList.Add( (byte)data.animationID );
                }
                break;

            case DialogPartNodeActionType.ClearScene:
                byteList.Add( Opcode.CLEAR_SCENE );
                break;

            case DialogPartNodeActionType.EnterActor:

                break;

            case "Scenario Script":
                AddAudioCode( byteList , data );
                AddCurrentCode( byteList ,  textDialogHndStr );
                KAGInterpreter ip = new KAGInterpreter();
                List<byte> temp = ip.Interpret( data.dialogText );
                for( int i=0;i<temp.Count;i++){
                    byteList.Add( temp[ i ] );
                }
                temp = null;
                break;

            case "Selections":
        //				if( data.isSelections ){
                    ByteCodeScriptTools.AddMessagingCode( byteList , "_" , OpcodeMessaging.SELECTIONS );
                    ByteCodeScriptTools.AddTextLiteralCode( byteList , "_" );
                    byteList.Add( Opcode.SELECTIONS );
        //			for( int i=0;i<units.Length;i++){
        //				SelectionsNode1.SelectUnit unit = units[ i ];
        //				CodeGenerator.GenerateASelection( byteList , i , data.targetNodeName , unit.text , false , "_" );
        //			}
                        CodeGenerator.GenerateASelection( byteList , 0 , data.selection.targetNodeName , data.selection.text , false , "_" );

                    byteList.Add( Opcode.STOP );
        //				}
                break;
        #endif
        }
    }
Beispiel #2
0
    /// <summary>
    /// Generates a Dialog code.
    /// </summary>
    /// <param name='byteList'>
    /// Byte list.
    /// </param>
    /// <param name='isName'>
    /// Is name.
    /// </param>
    /// <param name='isClearMessageAfter'>
    /// Is clear message after.
    /// </param>
    /// <param name='textNameHndStr'>
    /// Text name hnd string.
    /// </param>
    /// <param name='nameText'>
    /// Name text.
    /// </param>
    /// <param name='textDialogHndStr'>
    /// Text dialog hnd string.
    /// </param>
    /// <param name='dialogText'>
    /// Dialog text.
    /// </param>
    static public void GenerateADialogCode(
        List <byte> byteList, DialogPartData data, string textNameHndStr, string textDialogHndStr)
    {
// Currently not show.
#if false
        if (data.isClearScene)
        {
            // Clear Current Shown Scene.
            byteList.Add(Opcode.CLEAR_SCENE);
        }

        if (!string.IsNullOrEmpty(data.sceneFilePath))
        {
            AddSceneAdditiveCode(byteList, data.sceneFilePath, data.isFadeInStart);
        }
#endif

/*		else{
 *                      Debug.LogWarning( "Action:Scene data.sceneFilePath must not be null or empty." );
 *              }
 * //*/
        switch (data.actionID)
        {
        case DialogPartNodeActionType.EnterActor:
            for (int i = 0; i < data.enterActorEntries.Length; i++)
            {
                DialogPartData.ActorEntry entry = data.enterActorEntries[i];
//					Debug.Log ( "ADDCODE ACTOR:" + entry.actorName );
                Hashtable args = new Hashtable();
                args["eventType"] = data.actionID.ToString().ToLower();
                args["name"]      = entry.actorName;
                args["position"]  = entry.position.ToString();
                args["fade"]      = entry.withFade.ToString().ToLower();
                ByteCodeScriptTools.AddTablePairsCode(byteList, args);
                ByteCodeScriptTools.AddMessagingCode(byteList, " ", OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS);
            }
            break;

        case DialogPartNodeActionType.MoveActor:
            for (int i = 0; i < data.enterActorEntries.Length; i++)
            {
                DialogPartData.ActorEntry entry = data.enterActorEntries[i];
                Hashtable args = new Hashtable();
                args["eventType"] = data.actionID.ToString().ToLower();
                args["name"]      = entry.actorName;
                args["position"]  = entry.position.ToString();
                ByteCodeScriptTools.AddTablePairsCode(byteList, args);
                ByteCodeScriptTools.AddMessagingCode(byteList, " ", OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS);
            }
            break;

        case DialogPartNodeActionType.ExitActor:
            for (int i = 0; i < data.exitActorEntries.Length; i++)
            {
                DialogPartData.ActorEntry entry = data.exitActorEntries[i];
                Hashtable args = new Hashtable();
                args["eventType"] = data.actionID.ToString().ToLower();
                args["name"]      = entry.actorName;
                args["fade"]      = entry.withFade.ToString().ToLower();
                ByteCodeScriptTools.AddTablePairsCode(byteList, args);
                ByteCodeScriptTools.AddMessagingCode(byteList, " ", OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS);
            }
            break;

        case DialogPartNodeActionType.Dialog:
            AddAudioCode(byteList, data);

            if (data.isName)
            {
                AddSetTextCode(byteList, data.nameText, textNameHndStr);
            }
            else
            {
                AddHideMessageCode(byteList, textNameHndStr);
            }

            AddCurrentCode(byteList, textDialogHndStr);
            string str = data.dialogText;
            if (!data.isClearMessageAfter)
            {
                str += System.Environment.NewLine;
            }
            ByteCodeScriptTools.AddStringCode(byteList, str);
            byteList.Add(Opcode.PRINT);
            byteList.Add(Opcode.WAIT_TOUCH);

            if (data.isClearMessageAfter)
            {
                byteList.Add(Opcode.CM);
            }
            break;

/*			case DialogPartNodeActionType.ChangeState:
 *                              for( int i=0;i<data.exitActorEntries.Length;i++){
 *                                      DialogPartData.ActorEntry entry= data.exitActorEntries[ i ];
 *                                      Hashtable args = new Hashtable();
 *                                      args[ "eventType" ] = data.actionID.ToString().ToLower();
 *                                      args[ "name" ] = entry.actorName;
 *                                      args[ "state" ] = entry.state;
 *                                      args[ "fade" ] = entry.withFade.ToString().ToLower();
 *                                      ByteCodeScriptTools.AddTablePairsCode( byteList , args );
 *                                      ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
 *                              }
 *                              break;
 *
 *                      case DialogPartNodeActionType.Shake:
 *                              for( int i=0;i<data.exitActorEntries.Length;i++){
 *                                      DialogPartData.ActorEntry entry= data.exitActorEntries[ i ];
 *                                      Hashtable args = new Hashtable();
 *                                      args[ "eventType" ] = data.actionID.ToString().ToLower();
 *                                      args[ "name" ] = entry.actorName;
 *                                      ByteCodeScriptTools.AddTablePairsCode( byteList , args );
 *                                      ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
 *                              }
 *                              break;
 *                      case DialogPartNodeActionType.EnterScene:
 *                              Hashtable args = new Hashtable();
 *                              args[ "eventType" ] = data.actionID.ToString().ToLower();
 *                              args[ "name" ] = data.scene.sceneName;
 *                              args[ "fade" ] = data.scene.withFade.ToString().ToLower();
 *                              ByteCodeScriptTools.AddTablePairsCode( byteList , args );
 *                              ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
 *                              break;
 *
 *                      case DialogPartNodeActionType.ExitScene:
 *                               args = new Hashtable();
 *                              args[ "eventType" ] = data.actionID.ToString().ToLower();
 *                              args[ "name" ] = data.scene.sceneName;
 *                              args[ "fade" ] = data.scene.withFade.ToString().ToLower();
 *                              ByteCodeScriptTools.AddTablePairsCode( byteList , args );
 *                              ByteCodeScriptTools.AddMessagingCode( byteList , " " , OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS );
 *                              break;
 * //*/


// Show later update...
#if false
        case DialogPartNodeActionType.Scene:
            break;

        case DialogPartNodeActionType.ClearScene:
            byteList.Add(Opcode.CLEAR_SCENE);
            break;

        case DialogPartNodeActionType.PlayAnimation:
            if (data.isAnim)
            {
                byteList.Add(Opcode.PLAY_ANIMATION);
                byteList.Add((byte)data.animationID);
            }
            break;

        case DialogPartNodeActionType.ClearScene:
            byteList.Add(Opcode.CLEAR_SCENE);
            break;

        case DialogPartNodeActionType.EnterActor:

            break;

        case "Scenario Script":
            AddAudioCode(byteList, data);
            AddCurrentCode(byteList, textDialogHndStr);
            KAGInterpreter ip   = new KAGInterpreter();
            List <byte>    temp = ip.Interpret(data.dialogText);
            for (int i = 0; i < temp.Count; i++)
            {
                byteList.Add(temp[i]);
            }
            temp = null;
            break;

        case "Selections":
//				if( data.isSelections ){
            ByteCodeScriptTools.AddMessagingCode(byteList, "_", OpcodeMessaging.SELECTIONS);
            ByteCodeScriptTools.AddTextLiteralCode(byteList, "_");
            byteList.Add(Opcode.SELECTIONS);
            //			for( int i=0;i<units.Length;i++){
            //				SelectionsNode1.SelectUnit unit = units[ i ];
            //				CodeGenerator.GenerateASelection( byteList , i , data.targetNodeName , unit.text , false , "_" );
            //			}
            CodeGenerator.GenerateASelection(byteList, 0, data.selection.targetNodeName, data.selection.text, false, "_");

            byteList.Add(Opcode.STOP);
//				}
            break;
#endif
        }
    }