Beispiel #1
0
    static public void GenerateSelections(List <byte> byteList, SelectionsNode.SelectUnit[] units, string title)
    {
        if (ISelectionsCtrl.Instance == null)
        {
            ISelectionsCtrl selObj = GameObject.FindObjectOfType(typeof(ISelectionsCtrl)) as ISelectionsCtrl;
            if (selObj == null)
            {
                Debug.LogError("ISelectionsCtrl Not Exists.");
                return;
            }
        }
        if (!SelectionsNode.IsTargetSet(units))
        {
            return;
        }

        ByteCodeScriptTools.AddMessagingCode(byteList, "Dialog", OpcodeMessaging.SELECTIONS);
        ByteCodeScriptTools.AddTextLiteralCode(byteList, title);
        byteList.Add(Opcode.SELECTIONS);
        for (int i = 0; i < units.Length; i++)
        {
            if (units[i].targetNode != null)
            {
                SelectionsNode.SelectUnit unit = units[i];

                string targetFunc = units[i].targetNode.GetNodeLabel();                  //Tag(  unit.targetNode.name );
                CodeGenerator.GenerateASelection(byteList, i, targetFunc, unit.text, unit.checkFlag, unit.flagName);
            }
        }
        byteList.Add(Opcode.STOP);
    }
Beispiel #2
0
    /// <summary>
    /// Tos the byte code.
    /// </summary>
    public override void ToByteCode(ByteCodes code)
    {
        List <byte> byteList = new List <byte>();

        AddNodeCode(byteList);

        string nameHndName   = (m_NameTextBox != null) ? m_NameTextBox.name : "";
        string dialogHndName = (m_ViNoTextBox != null) ? m_ViNoTextBox.name : "";

        for (int i = 0; i < dlgDataList.Count; i++)
        {
            DialogPartData dlgData = dlgDataList[i];

// if a item is not Checked , the item is shown.
#if false
            if (!dlgData.active)
            {
                continue;
            }
#endif
            string tag = GetSingleDialogIDNodeTag(dlgData.dialogID);
            ByteCodeScriptTools.AddNodeCode(byteList, tag);

            CodeGenerator.GenerateADialogCode(byteList, dlgData, nameHndName, dialogHndName);
        }

        code.Add(byteList.ToArray());

        // To Byte codes this Children.
        ToByteCodeInternal(code);
    }
Beispiel #3
0
 static public void AddSetTextCode(List <byte> byteList, string text, string textNameHndStr)
 {
     if (!string.IsNullOrEmpty(textNameHndStr))
     {
         ByteCodeScriptTools.AddTextLiteralCode(byteList, text);
         AddSetTextCode(byteList, textNameHndStr);
     }
 }
Beispiel #4
0
    static public void AddPlaySoundCode(List <byte> byteList, string tag, string audioPath, string loop)
    {
        Hashtable args = new Hashtable();

        args["eventType"] = tag;
        args["storage"]   = audioPath;
        args["loop"]      = loop;
        ByteCodeScriptTools.AddTablePairsCode(byteList, args);
        ByteCodeScriptTools.AddMessagingCode(byteList, " ", OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS);
    }
Beispiel #5
0
    static public void AddDialogEventArgs(List <byte> byteList, string eventType, int messageID, string nodeName, string dialogText)
    {
        Hashtable args = new Hashtable();

        args["eventType"]  = eventType;
        args["ID"]         = messageID.ToString();
        args["nodeName"]   = nodeName;
        args["dialogText"] = dialogText;

        ByteCodeScriptTools.AddTablePairsCode(byteList, args);
        ByteCodeScriptTools.AddMessagingCode(byteList, nodeName, OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS);
    }
Beispiel #6
0
    static public void GenerateASelection(List <byte> byteList, int index, string targetFuncName, string text, bool checkFlag, string flagName)
    {
        Hashtable param = new Hashtable();

        param["target"] = targetFuncName;
        param["text"]   = text;
        if (checkFlag)
        {
            param["IsFlagOn"] = flagName;
        }
        ByteCodeScriptTools.AddTablePairsCode(byteList, param);
        byteList.Add(Opcode.LINK);
//		ByteCodeScriptTools.AddMessagingCode( byteList , "Select-" + index.ToString() , OpcodeMessaging.LINK );
    }
    public override void ToByteCode(ByteCodes code)
    {
        base.ToByteCode(code);

        List <byte> byteList = new List <byte>();
        string      target   = GetTargetName();

//		Debug.Log( "LoadImageTarget:" + target );
        ByteCodeScriptTools.AddMessagingCode(byteList, target, OpcodeMessaging.SET_RESOURCE_AS_TEXTURE);

        code.Add(byteList.ToArray());

        ToByteCodeInternal(code);
    }
Beispiel #8
0
    public override void ToByteCode(ByteCodes code)
    {
        List <byte> byteList = new List <byte>();

//		AddNodeCodeWithTag( byteList , name );
        AddNodeCode(byteList);

        ByteCodeScriptTools.AddTextLiteralCode(byteList, m_NextLevelName);
        ByteCodeScriptTools.AddMessagingCode(byteList, "env", OpcodeMessaging.LOAD_LEVEL);

        code.Add(byteList.ToArray());

        ToByteCodeInternal(code);
    }
Beispiel #9
0
    public override void ToByteCode(ByteCodes code)
    {
        base.ToByteCode(code);

        List <byte> byteList = new List <byte>();

        if (parent != null)
        {
            ByteCodeScriptTools.AddCreateGOCode(byteList, parent.name);
        }
        else
        {
            ByteCodeScriptTools.AddCreateGOCode(byteList, "");
        }
        code.Add(byteList.ToArray());

        ToByteCodeInternal(code);
    }
Beispiel #10
0
    public override void ToByteCode(ByteCodes code)
    {
        List <byte> byteList = new List <byte>();

        AddNodeCode(byteList);

        ISoundPlayer pl = ISoundPlayer.Instance;

        if (pl as ViNoSoundPlayer)
        {
            Hashtable tbl = new Hashtable();
            tbl["name"] = m_SoundName;
            switch (m_SoundType)
            {
            case SoundType.MUSIC:
                tbl["category"] = "Music";
                break;

/*			case SoundType.SE:
 *                                      tbl[ "category" ] = "SE";
 *                                      break;
 *
 *                      case SoundType.VOICE:
 *                                      tbl[ "category" ] = "Voice";
 *                                      break;
 * //*/
            }
            tbl["fadeOutSeconds"] = m_FadeOutSeconds.ToString();
            ByteCodeScriptTools.AddTablePairsCode(byteList, tbl);
            ByteCodeScriptTools.AddMessagingCode(byteList, "env", OpcodeMessaging.STOP_SOUND);
        }
        else if (pl as SimpleSoundPlayer)
        {
            Hashtable args = new Hashtable();
            args["eventType"] = "fadeoutbgm";
            int time = (int)(m_FadeOutSeconds * 1000f);
            args["time"] = time.ToString();
            ByteCodeScriptTools.AddTablePairsCode(byteList, args);
            ByteCodeScriptTools.AddMessagingCode(byteList, " ", OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS);
        }
        code.Add(byteList.ToArray());

        ToByteCodeInternal(code);
    }
    public override void ToByteCode(ByteCodes code)
    {
        if (jumpTarget != null)
        {
            List <byte> byteList = new List <byte>();

            AddNodeCode(byteList);

            string tag = jumpTarget.GetNodeTag(jumpTarget.name);                                // TODO: GetNodeLabel
            ByteCodeScriptTools.AddJumpTargetCode(byteList, tag);

            code.Add(byteList.ToArray());
        }
        else
        {
            Debug.LogError("JumpTargetNode:" + name + " isn't set jumpTarget.");
        }

        ToByteCodeInternal(code);
    }
Beispiel #12
0
    public override void ToByteCode(ByteCodes code)
    {
        base.ToByteCode(code);
        List <byte> byteList = new List <byte>();

        // Add Parent Name.
        if (targetObject != null)
        {
            ByteCodeScriptTools.AddTextLiteralCode(byteList, targetObject.name);
        }
        else
        {
            Debug.LogError("DestroyObjectNode: target not set !");
        }

        byteList.Add(Opcode.DESTROY_OBJECT);

        code.Add(byteList.ToArray());

        ToByteCodeInternal(code);
    }
Beispiel #13
0
    /// <summary>
    /// Tos the byte code.
    /// </summary>
    /// <param name='code'>
    /// Code.
    /// </param>
    public override void ToByteCode(ByteCodes code)
    {
        List <byte> byteList = new List <byte>();

        AddNodeCode(byteList);

#if false
        Hashtable args = new Hashtable();
        args["eventType"]  = eventType;
        args["ID"]         = messageID.ToString();
        args["nodeName"]   = nodeName;
        args["dialogText"] = dialogText;
#endif

        ByteCodeScriptTools.AddTextLiteralCode(byteList, sendMessage);
        ByteCodeScriptTools.AddMessagingCode(byteList, " ", OpcodeMessaging.TRIGGER_EVENT);

        code.Add(byteList.ToArray());

        // ToByteCode this Children.
        ToByteCodeInternal(code);
    }
    public override void ToByteCode(ByteCodes code)
    {
        base.ToByteCode(code);

        List <byte> byteList = new List <byte>();

#if false
        Hashtable hash = MakeHash(anyResourcePath, method, withFadeIn);
        ByteCodeScriptTools.AddTablePairsCode(byteList, hash);
        code.Add(byteList.ToArray());
        code.Add(Opcode.LOAD_SCENE);
#else
        Hashtable args = new Hashtable();
        args["eventType"] = "enterscene";
        args["name"]      = sceneName;
        args["destroy"]   = (method == Methods.DESTROY_AND_LOAD) ? "true" : "false";
        args["fade"]      = withFadeIn ? "true" : "false";
        ByteCodeScriptTools.AddTablePairsCode(byteList, args);
        ByteCodeScriptTools.AddMessagingCode(byteList, " ", OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS);
        code.Add(byteList.ToArray());
#endif
        ToByteCodeInternal(code);
    }
Beispiel #15
0
    public override void ToByteCode(ByteCodes code)
    {
        if (animTarget == null)
        {
            ViNoDebugger.LogWarning("Animation Target Not Set");
            return;
        }

        SetUpParamTable();

        List <byte> byteList = new List <byte>();

        // Labeling.
        AddNodeCode(byteList);

#if false
// instantiate prefab , if target is in asset.
        if (isTargetInAsset)
        {
            Debug.Log("add load resource :" + animTarget.name);
            // Add CreateObjectNode.ToByteCode...
            ByteCodeScriptTools.AddLoadResourceCode(byteList, animTarget.name);

            GameObject parent = null;
            if (Application.isPlaying)
            {
                parent = ViNoSceneManager.Instance.theSavedPanel;
            }
            else
            {
                ViNoSceneManager sm = GameObject.FindObjectOfType(typeof(ViNoSceneManager)) as ViNoSceneManager;
                parent = sm.theSavedPanel;
            }

            if (parent == null)
            {
                // SceneManager Not Needed user .
                parent = Camera.main.gameObject;
            }

            Debug.Log("AddCreateGOCode :" + parent.name);
            ByteCodeScriptTools.AddCreateGOCode(byteList, parent);
        }
        else
        {
            Debug.Log("target is in scene...");
        }
#endif

        ByteCodeScriptTools.AddTablePairsCode(byteList, paramTbl);
        byte op = OpcodeMessaging.TWEEN;
        switch (animationType)
        {
        case AnimationType.FADE_PANEL:          op = OpcodeMessaging.FADE_PANEL;        break;

        case AnimationType.CROSS_FADE:          op = OpcodeMessaging.CROSS_FADE;        break;
        }
        ByteCodeScriptTools.AddMessagingCode(byteList, animTarget.name, op);

        code.Add(byteList.ToArray());

        ToByteCodeInternal(code);
    }
Beispiel #16
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
        }
    }
Beispiel #17
0
 static public void GenerateWaitCode(List <byte> byteList, float waitSeconds)
 {
     ByteCodeScriptTools.AddTextLiteralCode(byteList, waitSeconds.ToString());
     byteList.Add(Opcode.START_WAIT);
     byteList.Add(Opcode.UPDATE_WAIT);
 }