Ejemplo n.º 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>
    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
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    ///
    /// </summary>
    /// <param name='sb'>
    /// Sb.
    /// </param>
    public override void ToScenarioScript(ref System.Text.StringBuilder sb)
    {
        base.ToScenarioScript(ref sb);

        // set current messagelayer name.
//		Dictionary<string,string> actorNameDict = new Dictionary<string,string>();

        sb.Append("[cm]");
        sb.Append(System.Environment.NewLine);
        sb.Append("[current layer=" + m_DialogHndName + "]");
        sb.Append(System.Environment.NewLine);
        sb.Append(System.Environment.NewLine);

        // DEFINE MACRO !
        int msgNum = GetMessageNum();

#if false
        for (int i = 0; i < msgNum; i++)
        {
            string actorName = GetNameBy(i);
            if (!actorNameDict.ContainsKey(actorName) && !string.IsNullOrEmpty(actorName))
            {
                actorNameDict[actorName] = "[" + actorName + "]";
                sb.Append("#" + actorNameDict[actorName] + ",[settext text=" + actorName + " textbox=" + m_NameHndName + "]");
                sb.Append(System.Environment.NewLine);
            }
        }

        sb.Append(System.Environment.NewLine);
#endif
        for (int i = 0; i < msgNum; i++)
        {
            DialogPartData data = dlgDataList[i];
            string         tag  = data.actionID.ToString().ToLower();
            if (data.actionID == DialogPartNodeActionType.Dialog)
            {
                string dialogText = GetMessageBy(i);
                if (data.isName)
                {
                    string actorName = GetNameBy(i);
//				    Debug.Log( "actorName:" + actorName );
                    if (!string.IsNullOrEmpty(actorName))
                    {
#if false
                        sb.Append(actorNameDict[actorName]);
#else
                        sb.Append("[settext text=" + actorName + " textbox=" + m_NameHndName + "]");
#endif
                        sb.Append(System.Environment.NewLine);
                    }
                }
//				sb.Append( " voiceAudioID=" + data.voiceAudioID.ToString() );
//				sb.Append( dialogText + "[l][cm]" );
                sb.Append(dialogText);
                if (data.isClearMessageAfter)
                {
                    sb.Append("[p]");
                }
                else
                {
                    sb.Append("[r]");
                }
            }
            else if (data.actionID == DialogPartNodeActionType.EnterActor || data.actionID == DialogPartNodeActionType.MoveActor)
            {
                for (int k = 0; k < data.enterActorEntries.Length; k++)
                {
                    DialogPartData.ActorEntry actorEnt = data.enterActorEntries[k];
                    string actorName = actorEnt.actorName;
                    if (!string.IsNullOrEmpty(actorName))
                    {
                        sb.Append("[" + tag + " name=" + actorName + " position=" + actorEnt.position.ToString() + " ");
                        if (actorEnt.withFade)
                        {
                            sb.Append("fade=true");
                        }
                        sb.Append("]");
                        sb.Append(System.Environment.NewLine);
                    }
                }
            }
            else if (data.actionID == DialogPartNodeActionType.ExitActor)
            {
                for (int k = 0; k < data.exitActorEntries.Length; k++)
                {
                    DialogPartData.ActorEntry actorEnt = data.exitActorEntries[k];
                    string actorName = actorEnt.actorName;
                    if (!string.IsNullOrEmpty(actorName))
                    {
                        sb.Append("[" + tag + " name=" + actorName + " ");
                        if (actorEnt.withFade)
                        {
                            sb.Append("fade=true");
                        }
                        sb.Append("]");
                        sb.Append(System.Environment.NewLine);
                    }
                }
            }

/*			else if( data.actionID == DialogPartNodeActionType.ChangeState ){
 *                              for(int k=0;k<data.exitActorEntries.Length;k++){
 *                                      DialogPartData.ActorEntry actorEnt = data.exitActorEntries[ k ];
 *                                      string actorName = actorEnt.actorName;
 *                                      if( ! string.IsNullOrEmpty( actorName ) ){
 *                                              sb.Append( "[" + tag + " name=" + actorName + " state=" + actorEnt.state + " " );
 *                                              if( actorEnt.withFade ){
 *                                                      sb.Append( "fade=true" );
 *                                              }
 *                                              sb.Append( "]" );
 *                                              sb.Append( System.Environment.NewLine );
 *                                      }
 *                              }
 *                      }
 *                      else if( data.actionID == DialogPartNodeActionType.Shake ){
 *                              for(int k=0;k<data.exitActorEntries.Length;k++){
 *                                      DialogPartData.ActorEntry actorEnt = data.exitActorEntries[ k ];
 *                                      string actorName = actorEnt.actorName;
 *                                      if( ! string.IsNullOrEmpty( actorName ) ){
 *                                              sb.Append( "[" + tag + " name=" + actorName + "]" );
 *                                              sb.Append( System.Environment.NewLine );
 *                                      }
 *                              }
 *                      }
 *                      else if( data.actionID == DialogPartNodeActionType.EnterScene ){
 *                              sb.Append( "[" + tag + " name=" + data.scene.sceneName + " fade=" + data.scene.withFade.ToString().ToLower() + "]" );
 *                              sb.Append( System.Environment.NewLine );
 *                      }
 *                      else if( data.actionID == DialogPartNodeActionType.ExitScene ){
 *                              sb.Append( "[" + tag + " fade=" + data.scene.withFade.ToString().ToLower() + "]" );
 *                              sb.Append( System.Environment.NewLine );
 *                      }
 * //*/

            sb.Append(System.Environment.NewLine);
            sb.Append(System.Environment.NewLine);
        }
    }