Ejemplo n.º 1
0
    /// <summary>
    /// Skips the text.
    /// </summary>
    /// <param name='vm'>
    /// Vm.
    /// </param>
    public override void SkipText(VirtualMachine vm)
    {
        if (vm.m_MsgTargetTextBox == null)
        {
            ViNoDebugger.LogWarning("Current ViNoTextBox is null.");
            vm.ProgressProgramCounter(1);
            return;
        }

        if (!vm.m_MsgTargetTextBox.reachedEnd)
        {
            vm.m_MsgTargetTextBox.DispTextQuick();
        }
        else
        {
            // Stop Voice.
            ISoundPlayer pl = ISoundPlayer.Instance;
            if (pl != null)
            {
                if (pl.IsPlayingVoice())
                {
                    pl.StopVoice();
                }
            }
            vm.ProgressProgramCounter(1);
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Sends the message to VM ScriptBinder.
 /// </summary>
 /// <param name='msg'>
 /// Message.
 /// </param>
 void SendMessageToBinder(string msg)
 {
     if (m_Vm.scriptBinder != null)
     {
         m_Vm.scriptBinder.SendMessage(msg, m_Vm.tweenDataCached);
     }
     else
     {
         ViNoDebugger.LogWarning("Tween Receiver is not Set. Please Set GameObject with " +
                                 " OnTween Function is Implemented.");
     }
 }
Ejemplo n.º 3
0
 public bool IsEvtReceiverAttach( )
 {
     if (eventReceiver == null)
     {
         ViNoDebugger.LogWarning("ViNoEventManager eventReceiver Not Attached.");
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 4
0
    // Finally our save and load methods for the file itself
    static public void CreateXML(string dataStr)
    {
        _FileLocation = GetDataPath();
        if (Application.platform == RuntimePlatform.WindowsWebPlayer
            ||
            Application.platform == RuntimePlatform.OSXWebPlayer)
        {
            ViNoDebugger.LogWarning("WebPlayer not support FileInfo. Can't CreateXML.");
            return;
        }

#if UNITY_EDITOR
        string path = _FileLocation + "/" + _FileName;
#else
        string path = _FileLocation + "/" + _FileName;
#endif

        try
        {
            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(path))
            {
                try
                {
                    sw.Write(dataStr);
                    ViNoDebugger.Log("SaveInfo", "File written.");
                }
                finally
                {
                    sw.Close();
                }
            }
        }
        catch (System.IO.IOException er)
        {
            // Disk Full or some exception.
            Debug.LogError("An Error occured while Creating a File.");
            Debug.LogError("Message:" + er.Message);

//			DialogManager.Instance.ShowSelectDialog( "IOException" , er.Message , Dummy );
        }
    }
Ejemplo n.º 5
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);
    }
Ejemplo n.º 6
0
    void OnGUI()
    {
#if false
        if (GUILayout.Button("Fade and LoadLevel"))
        {
            StartCoroutine("FadeInAndLoadLevelAndFadeOut");
        }
        if (GUILayout.Button("FADE_IN"))
        {
            StartFade(true);
        }
        if (GUILayout.Button("FADE_OUT"))
        {
            StartFade(false);
        }
#endif
        if (texture == null)
        {
            ViNoDebugger.LogWarning("texture must not be NULL.");
            return;
        }

        if (startFading)
        {
            Color col = _COLOR;
            col.a = cnt;
            texture.SetPixel(0, 0, col);
            texture.Apply();
            if (fadeInFlag)
            {
                cnt += fadeSpeed;
                if (cnt > 1)
                {
                    cnt         = 1;
                    fadeInFlag  = false;
                    startFading = false;
                    if (receiver != null)
                    {
                        receiver.SendMessage("DidFadeIn", SendMessageOptions.DontRequireReceiver);
                    }

                    if (_SCENE_TRANSITION)
                    {
                        if (!nextSceneName.Equals(""))
                        {
                            Application.LoadLevel(nextSceneName);
                        }
                    }
                }
            }
            else
            {
                cnt -= fadeSpeed;
                if (cnt < 0)
                {
                    cnt         = 0;
                    fadeInFlag  = true;
                    startFading = false;
                    if (receiver != null)
                    {
                        receiver.SendMessage("DidFadeOut", SendMessageOptions.DontRequireReceiver);
                    }
                }
            }
        }
        GUI.DrawTexture(new Rect(0, 0, Screen.width + 2f, Screen.height), texture);
    }
Ejemplo n.º 7
0
/*
 *      public void HandleAOpcode( VM vm , byte op ){
 *              vm.code = new byte[ 1 ];
 *              vm.code[ 0 ] = op;
 *              HandleOpcode( vm );
 *      }
 * //*/
    /// <summary>
    /// Handles the opcode.
    /// </summary>
    /// <returns>
    /// The opcode.
    /// </returns>
    /// <param name='vm'>
    /// If set to <c>true</c> vm.
    /// </param>
    public override bool HandleOpcode(VirtualMachine vm)
    {
        m_Vm = vm;
        switch (vm.code[vm.pc])
        {
        case OpcodeMessaging.PUNCH_POSITION:    vm.scriptBinder.PUNCH_POSITION(vm);   break;

        case OpcodeMessaging.SIZE:                              vm.scriptBinder.SIZE(vm);                                            break;

        case OpcodeMessaging.LOAD_IMAGE:                vm.scriptBinder.LOAD_IMAGE(vm.tweenDataCached);                       break;

        case OpcodeMessaging.CHANGE_IMAGE:              vm.scriptBinder.CHANGE_IMAGE(vm.tweenDataCached);             break;

        case OpcodeMessaging.MSG_TARGET:
            GameObject obj = vm.tweenDataCached.tweenTarget;
            vm.scriptBinder.MSG_TARGET(obj);
            break;

        case OpcodeMessaging.SET_TEXT:                                          vm.scriptBinder.SET_TEXT(vm);                                                                                 break;

        case OpcodeMessaging.SET_RESOURCE_AS_TEXTURE:
            Texture2D    image = vm.loadedResource as Texture2D;
            MeshRenderer ren   = vm.tweenDataCached.tweenTarget.GetComponent <MeshRenderer>();
            if (ren != null)
            {
                ren.sharedMaterial.mainTexture = image;
                ren.transform.localScale       = new Vector3(image.width, image.height, 1f);

                // VinoSceneNode component is needed.
                vm.tweenDataCached.tweenTarget.SendMessage("OnChangeTexture", vm.loadedResourcePath, SendMessageOptions.DontRequireReceiver);
            }
            else
            {
                Debug.LogError("MeshRenderer not Found.");
            }
            break;

        case OpcodeMessaging.SET_RESOURCE_AS_TRANSITION_TEXTURE1:
            image = vm.loadedResource as Texture2D;
            ren   = vm.tweenDataCached.tweenTarget.GetComponent <MeshRenderer>();
            if (ren != null)
            {
                ren.sharedMaterial.SetTexture("_tex0", image);
            }
            else
            {
                Debug.LogError("MeshRenderer not Found.");
            }
            break;

        case OpcodeMessaging.SET_RESOURCE_AS_TRANSITION_TEXTURE2:
            image = vm.loadedResource as Texture2D;
            ren   = vm.tweenDataCached.tweenTarget.GetComponent <MeshRenderer>();
            if (ren != null)
            {
                ren.sharedMaterial.SetTexture("_tex1", image);
            }
            else
            {
                Debug.LogError("MeshRenderer not Found.");
            }
            break;

        case OpcodeMessaging.FADE_PANEL:                        vm.update = false;              vm.scriptBinder.FADE_PANEL(vm.tweenDataCached);       break;

        case OpcodeMessaging.CROSS_FADE:                        vm.update = false;              vm.scriptBinder.CROSS_FADE(vm.tweenDataCached);       break;

        case OpcodeMessaging.TWEEN:                                     vm.update = false;              vm.scriptBinder.TWEEN(vm.tweenDataCached);                    break;

        case OpcodeMessaging.DESTROY:                           GameObject.Destroy(vm.tweenDataCached.tweenTarget);           break;

        case OpcodeMessaging.DESTROY_CHILDREN:          ViNoGOExtensions.FindAndDestroyChildren(vm.messagingTargetName);                                      break;

        case OpcodeMessaging.TARGET:                            vm.m_CurrTarget = GameObject.Find(VM.loadedTextLiteralString);                                break;

        case OpcodeMessaging.LOAD_LEVEL:                        Application.LoadLevel(VM.loadedTextLiteralString);                    break;

        case OpcodeMessaging.LOAD_SCENE_XML:            vm.scriptBinder.LOAD_SCENE_XML(vm);                                           break;

        case OpcodeMessaging.PLAY_SOUND:
            if (ISoundPlayer.Instance == null)
            {
                vm.ProgressProgramCounter(1);
                ViNoDebugger.LogError("VM", "PLAY_SOUND : ISoundPlayer.Instance NOT FOUND.");
                return(false);
            }
            string soundName = vm.paramHash["name"] as string;
            string soundCat  = vm.paramHash["category"] as string;
            string delayStr  = vm.paramHash["delay"] as string;
            float  delay     = float.Parse(delayStr);

            if (ISoundPlayer.Instance != null)
            {
                ISoundPlayer.Instance.PlaySoundCallback(soundName, soundCat, 1f, delay);
            }
            break;

        case OpcodeMessaging.STOP_SOUND:
            if (ISoundPlayer.Instance == null)
            {
                vm.ProgressProgramCounter(1);
                ViNoDebugger.LogWarning("ISoundPlayer.Instance NOT FOUND.");
                return(false);
            }
            soundName = vm.paramHash["name"] as string;
            soundCat  = vm.paramHash["category"] as string;
            string fadeStr        = vm.paramHash["fadeOutSeconds"] as string;
            float  fadeOutSeconds = float.Parse(fadeStr);

            if (ISoundPlayer.Instance != null)
            {
                ISoundPlayer.Instance.StopSoundCallback(soundName, soundCat, fadeOutSeconds);
            }
            break;

// TODO:
#if false
        case OpcodeMessaging.SET_ACTIVE:                // OBSOLETE. ===> OPCODE.LAYOPT.
            GOOptionNode.Do(vm.paramHash);
            break;
#endif

        case OpcodeMessaging.SET_POS_3D:
            Vector3 pos = ViNoStringExtensions.ParseVector3(VM.loadedTextLiteralString);
            if (vm.tweenDataCached.tweenTarget != null)
            {
                vm.tweenDataCached.tweenTarget.transform.localPosition = pos;
            }
            break;

        case OpcodeMessaging.SET_SCALE_3D:
            Vector3 scale = ViNoStringExtensions.ParseVector3(VM.loadedTextLiteralString);
            if (vm.tweenDataCached.tweenTarget != null)
            {
                vm.tweenDataCached.tweenTarget.transform.localScale = scale;
            }
            break;

        case OpcodeMessaging.TRANSLATE:
            if (!string.IsNullOrEmpty(VM.loadedTextLiteralString))
            {
                string[] strs = VM.loadedTextLiteralString.Split(',');
                if (strs.Length > 0)
                {
                    if (strs.Length == 3)
                    {
                        GameObject target = vm.tweenDataCached.tweenTarget;
                        if (target != null)
                        {
                            Vector3 tra  = ViNoStringExtensions.ParseVector3(VM.loadedTextLiteralString);
                            Vector3 temp = target.transform.localPosition;
                            temp += tra;
                            target.transform.localPosition = temp;
                        }
                    }
                }
            }
            break;

        case OpcodeMessaging.TRIGGER_EVENT:
            ViNoEventManager em = ViNoEventManager.Instance;
            if (!string.IsNullOrEmpty(VM.loadedTextLiteralString) && em != null)
            {
                em.TriggerEvent(VM.loadedTextLiteralString);
            }
            break;

        case OpcodeMessaging.TRIGGER_EVENT_WITH_ARGS:
            em = ViNoEventManager.Instance;
            if (em != null && vm.tweenDataCached.paramTable.ContainsKey("eventType"))
            {
                string evtType = vm.tweenDataCached.paramTable["eventType"] as string;
                em.TriggerEvent(evtType, vm.tweenDataCached.paramTable);
            }
            break;

        default:
            ViNoDebugger.LogError("PC : " + vm.pc);
            break;
        }

        // Progress Counter.
        vm.ProgressProgramCounter(1);

        return(true);
    }