Ejemplo n.º 1
0
    /// <summary>
    /// Adds the selection.
    /// </summary>
    /// <returns>
    /// The selection.
    /// </returns>
    /// <param name='title'>
    /// Title.
    /// </param>
    /// <param name='target'>
    /// Target.
    /// </param>
    public override GameObject AddSelection(string title, string target)
    {
        GameObject selection = m_SelectionCache[m_CurrSelectIndex];

        m_CurrSelectIndex++;
        if (m_CurrSelectIndex > base._SELECTION_CACHE_NUM)
        {
            ViNoDebugger.LogError("selection index range error.");
        }

        GUISelection guiSel = selection.GetComponent <GUISelection>();

        guiSel.SetGUIDiglogCtrl(this);
        guiSel.text = title;

        float posY = Screen.height / 2f;
        float w    = Screen.width / 4f;
        float h    = 50f;

        posY += +(m_CurrSelectIndex - 1) * (kOffsetY + kLineSpaceY);
        Vector2 pos = initialPos;

        pos += new Vector2(Screen.width / 2f - w / 2f, posY);
        guiSel.SetPosition(pos, w, h);

        m_SelectionDict.Add(selection.name, new SelectionUnit(title, target));

        // Now , Show Selection.
        selection.SetActive(true);

        return(selection);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Change Texture2D of renderer.sharedMaterial.
    /// </summary>
    /// <param name='tweenData'>
    /// Tween data.
    /// </param>
    public override void LOAD_IMAGE(TweenOperandData tweenData)
    {
        Resources.UnloadUnusedAssets();

        string     texpath = VM.loadedTextLiteralString;
        Texture2D  tex     = Resources.Load(texpath) as Texture2D;
        GameObject obj     = tweenData.tweenTarget;

        if (obj.GetComponent <Renderer>() != null)
        {
            if (obj.GetComponent <Renderer>().sharedMaterial != null)
            {
                obj.GetComponent <Renderer>().sharedMaterial.mainTexture = tex;

                ViNoDebugger.Log("loaded texture and the GameObject Name will change to :" + texpath);
                obj.name = texpath;
//				obj.transform.localScale = new Vector3( tex.width , tex.height , 1f );
            }
            else
            {
                ViNoDebugger.LogError("Material not attached !");
            }
        }
        else
        {
            ViNoDebugger.LogError("renderer not attached !");
        }
    }
Ejemplo n.º 3
0
    public override bool OnTouchBegan()
    {
        if (TouchScreen.selectedGameObject == this.gameObject)
        {
            ViNoDebugger.Log("INPUT", "OnTouchBegan :" + name);
            m_TouchObjectResponse = touchResponse;
            switch (touchResponse)
            {
            case TouchResponse.OFFSET:
                m_TouchedObject    = this.gameObject;
                m_TouchBeganAmount = m_TouchedObject.transform.localPosition;
                m_TouchedObject.transform.localPosition = m_TouchBeganAmount + offsetAmount;                        // new Vector3( 5f , - 5f , 0f );
                break;

            case TouchResponse.SCALE:
                m_TouchedObject    = this.gameObject;
                m_TouchBeganAmount = m_TouchedObject.transform.localScale;
                m_TouchedObject.transform.localScale = new Vector3(m_TouchBeganAmount.x * scaleAmount.x, m_TouchBeganAmount.y * scaleAmount.y, scaleAmount.z);
                break;

            case TouchResponse.NONE:
                break;
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 4
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.º 5
0
    /// <summary>
    /// Raises the load event.
    /// </summary>
    /// <param name='info'>
    /// Info.
    /// </param>
    public override void OnLoad(ViNoSaveData info)
    {
        if (currentAudioKey == info.m_BgmName)
        {
            ViNoDebugger.Log("Sound", "currentAudioKey:" + currentAudioKey + "info.BGM:" + info.m_BgmName);
            return;
        }

        ViNoDebugger.Log("Sound", "<color=cyan>" + "OnLoad in ViNoSoundPlayer" + "</color>");

        StopMusic(1f);

        ViNoDebugger.Log("Sound", info.m_BgmName + " Play. ");

        if (!string.IsNullOrEmpty(info.m_BgmName) || !info.m_BgmName.Equals("NotPlayed"))
        {
//				StartCoroutine( "DelayPlayBGM" , info.m_BgmName );
            bool loop = true;
            PlayMusic(info.m_BgmName, loop, 0f);
//				player.PlayMusic( item , true , 0f );
        }
        else
        {
            ViNoDebugger.Log("Sound", "No Music was Played when Saved.");
            StopMusic(kPlayDelayWhenLoaded);
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Load the specified info.
    /// </summary>
    /// <param name='info'>
    /// Info.
    /// </param>
    public void Load(ViNoSaveInfo info)
    {
        VM vm = VM.Instance;

        if (vm == null)
        {
            ViNoDebugger.LogError("VM Not Found . Can't Load.");
        }


        switch (saveMethod)
        {
        case SaveMethods.COLLECT_VINO_SCENE_NODES:

            break;

        case SaveMethods.TRAVERSE_CHILDREN:
            if (destroyChildrenOnLoad)
            {
                if (theSavedPanel != null)
                {
                    ViNoGOExtensions.DestroyImmediateChildren(theSavedPanel.name);
                }
            }
            break;
        }

        ViNoGameSaveLoad.Load(info);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Raises the click select callback event.
    /// </summary>
    /// <param name='obj'>
    /// Object.
    /// </param>
    public void OnClickSelectCallback(GameObject obj)
    {
        string objName = obj.name;

        ViNoDebugger.Log("SELECTION", "click callback obj : " + objName);
        if (m_SelectionDict == null)
        {
            return;
        }
        if (m_SelectionDict.ContainsKey(objName))
        {
            string destNodeName = m_SelectionDict[objName].m_Target;
            if (!destNodeName.Equals(string.Empty))
            {
                if (ScenarioNode.Instance.flagTable != null)
                {
                    ScenarioNode.Instance.flagTable.SetFlagBy("SELECTED/" + destNodeName, true);
                }
                VM.Instance.GoToLabel(m_SelectionDict[objName].m_Target);                       // Run with Tag.
            }
            else
            {
                Debug.LogError("SelectionUnit Target must not be empty .");
            }
        }
        else
        {
            Debug.LogError("SelectionUnit  NOT FOUND in SelectionDictionary .");
        }
        SystemUtility.EnableColliderCurrentTextBox(true);

        DeactivateSelections();

        ChangeActive(false);
    }
Ejemplo n.º 8
0
 public override void PlaySE(int id, float volume, float delay)
 {
     ViNoDebugger.Log("Sound", "");
     if (seEntries != null && seEntries.Length > 0 && seEntries.Length > id)
     {
         PlaySE(seEntries[id].name, volume, delay);
     }
 }
Ejemplo n.º 9
0
    /// <summary>
    /// Load the specified info.
    /// </summary>
    /// <returns>
    /// If Load Succeed return true , Load Failed return false.
    /// </returns>
    static public bool Load(ViNoSaveInfo info)
    {
        bool levelNameNotMatchThisScene = !info.data.m_LoadedLevelName.Equals(Application.loadedLevelName);

        if (levelNameNotMatchThisScene)
        {
            ViNoDebugger.LogError("SaveData Level Name is : \""
                                  + info.data.m_LoadedLevelName + "\" but this level is \"" + Application.loadedLevelName + "\"");
            return(false);
        }

        // Load Scene from XML.
        if (ViNoSceneManager.Instance != null)
        {
            ViNoSceneManager.Instance.Load(info);
        }

        bool haveLevelName = !string.IsNullOrEmpty(info.data.m_LoadedLevelName);
        bool haveNodeName  = !string.IsNullOrEmpty(info.data.m_NodeName);
        bool isLoad        = (haveLevelName && haveNodeName);

        if (isLoad)
        {
            // Deserialize VM.
            VM vm = VM.Instance;
            if (vm != null)
            {
                vm.ClearTextBuilder();

                SystemUtility.ClearAllTextBoxMessage();

                vm.Deserialize(info.data.m_NodeName);

                GameObject scenarioObj = GetScenarioObject(info);

                // Play from File ?.
                ScenarioNode scenario = scenarioObj.GetComponent <ScenarioNode>();
                scenario.startFromSave = true;
                scenario.PlayFrom(info.data.m_NodeName);
            }

            // Load Sound.
            if (ISoundPlayer.Instance != null)
            {
                ISoundPlayer pl = ISoundPlayer.Instance;
                pl.OnLoad(info.data);
            }

            // Deactivate Selections.
            if (ISelectionsCtrl.Instance != null)
            {
                ISelectionsCtrl.Instance.ChangeActive(false);
            }
        }
        return(isLoad);
    }
Ejemplo n.º 10
0
 public override bool OnTouchOut()
 {
     if (m_TouchedObject != null)
     {
         ViNoDebugger.Log("INPUT", "OnTouchOut:" + name);
         ResetBeganAmount(m_TouchedObject.transform);
         m_TouchedObject = null;
     }
     return(true);
 }
Ejemplo n.º 11
0
    static public void WriteBinaryFile(byte[] bytes, string path)
    {
        FileStream   fs = new FileStream(path, FileMode.Create);
        BinaryWriter bw = new BinaryWriter(fs);

        bw.Write(bytes);
        bw.Close();
        fs.Close();
        ViNoDebugger.Log("Wrote BinaryFile to " + path);
    }
Ejemplo n.º 12
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.º 13
0
 public bool IsEvtReceiverAttach( )
 {
     if (eventReceiver == null)
     {
         ViNoDebugger.LogWarning("ViNoEventManager eventReceiver Not Attached.");
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 14
0
    static public DictionaryEntry[] ConvertHashtableToArray(Hashtable ht)
    {
        DictionaryEntry[] entries = new DictionaryEntry[ht.Count];
        int entryIndex            = 0;

        foreach (DictionaryEntry de in ht)
        {
            ViNoDebugger.Log("De Val GetType:" + de.Value.GetType());
            entries[entryIndex] = de;
            entryIndex++;
        }
        return(entries);
    }
Ejemplo n.º 15
0
    static public void LoadSceneXMLFromTextAssetPath(string path)
    {
        TextAsset txt = Resources.Load(path, typeof(TextAsset)) as TextAsset;

        if (txt != null)
        {
            LoadSceneXMLFromTextAsset(txt);
        }
        else
        {
            ViNoDebugger.LogError("SaveInfo", "LOAD_SCENE_XML : Resources.Load Error! ");
        }
    }
Ejemplo n.º 16
0
 protected void FadeCommon(string layerName, float duration, float fadeTo)
 {
     m_CachedData.tweenTarget = GameObject.Find(layerName);
     if (m_CachedData.tweenTarget != null)
     {
         m_CachedData.paramTable             = new Hashtable();
         m_CachedData.paramTable["duration"] = duration.ToString();
         m_CachedData.paramTable["fadeTo"]   = fadeTo.ToString();
     }
     else
     {
         ViNoDebugger.Log("DialogPartEvent", "there is expected that " + layerName + " Layer Exists Under the SavedLayer.");
     }
 }
Ejemplo n.º 17
0
    /// <summary>
    /// Save the specified info.
    /// </summary>
    /// <param name='info'>
    /// Info.
    /// </param>
    static public void Save(ViNoSaveInfo info)
    {
        info.data.m_LoadedLevelIndex = Application.loadedLevel;
        info.data.m_LoadedLevelName  = Application.loadedLevelName;

        // Serialization of Scene.
        if (ViNoSceneManager.Instance != null)
        {
            info.data.m_SceneXmlData = ViNoSceneManager.Instance.Save( );
        }

        // Serialization of VM.
        if (VM.Instance != null)
        {
            VM.SerializationInfo vmSerInfo = VM.Instance.Serialize( );
            info.data.m_NodeName            = vmSerInfo.m_NodeName;
            info.data.m_CurrentScenarioName = vmSerInfo.m_ScenarioName;
        }
        else
        {
            ViNoDebugger.LogError("SaveInfo", "VM NOT Found. Can't serialize VM Info.");
        }

        // Serialization of BGM.
        if (ISoundPlayer.Instance != null)
        {
            ISoundPlayer pl = ISoundPlayer.Instance;
//			ViNoSoundPlayer pl = ISoundPlayer.Instance as ViNoSoundPlayer;
            pl.OnSave(info.data);
        }

/*		if( ScenarioNode.Instance != null ){
 *                      info.data.m_ScenarioResourceFilePath = ScenarioNode.Instance.scenarioResourceFilePath;
 *              }
 * //*/

        // Set DateTime.
        info.data.m_Date = ViNoStringExtensions.GetDateTimeNowString();

        // Set Message.
        SystemUIEvent sys = GameObject.FindObjectOfType(typeof(SystemUIEvent)) as SystemUIEvent;
        string        str = sys.GetCurrentMessage();

        if (str.Length >= 14)
        {
            str = str.Substring(0, 14) + "...";
        }
        info.data.m_ScenarioDescription = str;
    }
Ejemplo n.º 18
0
    // Filename without Extension.
    static public void SaveToExternalFile(string fileName)
    {
#if UNITY_EDITOR
        _FileLocation = Application.dataPath;
#else
        _FileLocation = Application.persistentDataPath;
#endif
        // Where we want to save and load to and from
        _FileName = fileName + ".xml";

        string xmlData = SaveAndGetXMLString();

        CreateXML(xmlData);

        ViNoDebugger.Log("SaveInfo", "Saved Scene as XML Data : " + xmlData);
    }
Ejemplo n.º 19
0
    public void ChangeTargetTextBox(byte id)
    {
        if (messageBoxes == null)
        {
            Debug.LogError("SystemUIEvent messageBoxes Not Attached. please attach some textboxes.");
            return;
        }

        if (messageBoxes.Length <= id)
        {
            Debug.LogError("SystemUIEvent Text Message Target ID error. the id : " + id.ToString());
            return;
        }

        if (systemUIRoot != null)
        {
            if (!systemUIRoot.activeInHierarchy)
            {
                systemUIRoot.SetActive(true);
            }
        }

        ViNoDebugger.Log("SystemUIEvent", "ChangeTargetTextBox :" + id);

        if (deactivePrevMessageTarget)
        {
            // Deactivate prev textBox.
            if (currentTextBox != null && currentTextBox != messageBoxes[id])
            {
                currentTextBox.gameObject.SetActive(false);
            }
        }
        currentTextBox = messageBoxes[id];

        // Deactivate all textboxes.
//		ShowAllTextBoxes( false );
        // or DeactiveColor.
        // DeactiveColorTextBoxes();

        // Activate Current.
        if (!currentTextBox.gameObject.activeInHierarchy)
        {
            currentTextBox.gameObject.SetActive(true);
        }

        VM.Instance.m_MsgTargetTextBox = currentTextBox;
    }
Ejemplo n.º 20
0
    static public void LoadSceneFromXmlString(string xmlStr)
    {
        ViNoSceneManager sm = ViNoSceneManager.Instance;

        if (sm == null)
        {
            ViNoDebugger.LogError("SceneManager Instance NOT FOUND. Can't Loaded.");
            return;
        }

        sm.SetSceneData((SceneData)DeserializeObject <SceneData>(xmlStr));
        SceneData sceneData = sm.GetSceneData();

        sm.SetNodeData(sceneData.m_DataArray);
        sm.CreateSceneNodes();

        ViNoDebugger.Log("SaveInfo", "Loaded Scene from XmlString.");
    }
Ejemplo n.º 21
0
 /// <summary>
 /// Raises the save event.
 /// </summary>
 /// <param name='info'>
 /// Info.
 /// </param>
 public override void OnSave(ViNoSaveData info)
 {
     if (currentAudio != null)
     {
         if (currentAudio.isPlaying)
         {
             ViNoDebugger.Log("Sound", currentAudioKey + " is Playing when Save. Now , Save the Music Name.");
             info.m_BgmName = currentAudioKey;
         }
         else
         {
             info.m_BgmName = "NotPlayed";
         }
     }
     else
     {
         info.m_BgmName = "NotPlayed";
     }
 }
Ejemplo n.º 22
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 );
        }
    }
    /// <summary>
    /// Adds the selection.
    /// </summary>
    /// <returns>
    /// The selection.
    /// </returns>
    /// <param name='title'>
    /// Title.
    /// </param>
    /// <param name='target'>
    /// Target.
    /// </param>
    public override GameObject AddSelection(string title, string target)
    {
        TextButton sel = textButtons[m_CurrSelectIndex];

        sel.onClick += OnClickSelectCallback;
        sel.OnInitialize(title);
        sel.selectText.text = title;

        m_CurrSelectIndex++;
        if (m_CurrSelectIndex > base._SELECTION_CACHE_NUM)
        {
            ViNoDebugger.LogError("selection index range error.");
        }

//		Debug.Log( "AddSel:" + sel.name );
        m_SelectionDict.Add(sel.name, new SelectionUnit(title, target));

        // Now , Show Selection.
        sel.gameObject.SetActive(true);

        return(sel.gameObject);
    }
Ejemplo n.º 24
0
    // OBSOLETE.
    public override void SET_TEXT(VirtualMachine vm)
    {
        string theText = VirtualMachine.loadedTextLiteralString;

        if (vm.tweenDataCached.tweenTarget != null)
        {
            ViNoTextBox txtBox = vm.tweenDataCached.tweenTarget.GetComponent <ViNoTextBox>();
            if (txtBox != null)
            {
                txtBox.SetText(theText);
                m_CurrentText = theText;
            }
            else
            {
                ViNoDebugger.LogError("ViNoTextBox Object NOT FOUND.");
            }
        }
        else
        {
            ViNoDebugger.LogError("ViNoTextBox Object NOT FOUND.");
        }
    }
Ejemplo n.º 25
0
 public override bool OnTouchEnded()
 {
     if (m_TouchedObject != null)
     {
         ResetBeganAmount(m_TouchedObject.transform);
         m_TouchedObject = null;
     }
     if (TouchScreen.selectedGameObject == this.gameObject)
     {
         ViNoDebugger.Log("INPUT", "OnTouchEnded :" + name);
         if (findObjectAndSendMessage)
         {
             eventReceiver = GameObject.Find(targetObjectName);
             if (eventReceiver == null)
             {
                 Debug.Log("Target :" + targetObjectName + " not found.");
             }
         }
         if (eventReceiver != null)
         {
             if (!string.IsNullOrEmpty(paramString))
             {
                 eventReceiver.SendMessage(sendMessage, paramString, SendMessageOptions.DontRequireReceiver);
             }
             else
             {
                 eventReceiver.SendMessage(sendMessage, SendMessageOptions.DontRequireReceiver);
             }
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 26
0
    static public string LoadXML( )
    {
        _FileLocation = GetDataPath();
        string path = "";

#if UNITY_EDITOR
        path = _FileLocation + "/" + _FileName;
#else
        path = _FileLocation + "/" + _FileName;
#endif
        if (System.IO.File.Exists(path))
        {
            StreamReader r     = File.OpenText(path);
            string       _info = r.ReadToEnd();
            r.Close();
            //      _data=_info;
            ViNoDebugger.Log("SaveInfo", "File Read");
            return(_info);
        }
        else
        {
            return(string.Empty);
        }
    }
Ejemplo n.º 27
0
    // ------------- Override --------------------.

    /// <summary>
    /// Handles the opcode.
    /// </summary>
    public override void OnUpdate()
    {
        if (IsFinish())
        {
            return;
        }

        // Pomp Message to MessagingHandler.
        if (m_MessagePompToMsghandler)
        {
            if (m_MessagingHandler != null)
            {
                bool handled = m_MessagingHandler.HandleOpcode(this);
                m_MessagePompToMsghandler = !handled;
            }
            return;
        }

        m_CanTextProgress = false;
        switch (code[pc])
        {
        case Opcode.STRING:             pc = ByteCodeReader.readString(code, pc + 1);        m_TextBuilder.Append(loadedString);   break;

        case Opcode.TEXT:               pc = ReadText(pc);                                                                                                                                            break;

        case Opcode.VAR:                pc = ByteCodeReader.readVar(code, pc, ref paramHash, ref m_TextBuilder, stubIndent);       break;

        case Opcode.TABLE:              pc = ByteCodeReader.readTable(code, pc, ref paramHash);                                                                     break;

        case Opcode.ASSIGN_STRING:
//			Debug.Log("OPCODE>ASSIGN_STRING");
            pc        = ByteCodeReader.readString(code, pc + 2);
            leftHand  = loadedString;
            pc        = ByteCodeReader.readString(code, pc + 1);
            rightHand = loadedString;
//			Debug.Log(  "Opcode.ASSIGN key=" + leftHand + " value=\"" + rightHand + "\"" );

// Assign Value to Hashtable ?.
#if false
            symbolTable[leftHand] = rightHand;

// Assign Value to FlagTable.
#else
            ScenarioNode scenario = ScenarioNode.Instance;
            if (scenario != null && scenario.flagTable != null)
            {
                scenario.flagTable.SetStringValue(leftHand, rightHand);
            }
#endif
            leftHand  = "";
            rightHand = "";
            break;

        case Opcode.NULL:              pc++;                                                                                                                                                                           break;

        case Opcode.MESSAGING:
            pc = ByteCodeReader.readString(code, pc + 2);
            messagingTargetName       = loadedString;
            m_MessagePompToMsghandler = true;
            bool isIgnoreObj = loadedString.Equals("env");
            if (!isIgnoreObj)
            {
                if (tweenDataCached.tweenTarget != null)
                {
                    if (!tweenDataCached.tweenTarget.name.Equals(messagingTargetName))
                    {
                        tweenDataCached.tweenTarget = GameObject.Find(messagingTargetName);
                    }
                }
                else
                {
                    tweenDataCached.tweenTarget = GameObject.Find(messagingTargetName);
                }
            }
            tweenDataCached.paramTable = paramHash;
            break;

        case Opcode.NODE:
            m_PrevNodeName = m_CurrNodeName;
            pc             = ByteCodeReader.readString(code, pc + 2);
            ViNoDebugger.Log("NODE", loadedString);

            m_CurrNodeName            = loadedString;
            m_NodePcMap[loadedString] = pc;
            SetCurrentNodeToScriptEngine();

            // Callback to ScriptBinder.
            scriptBinder.OnEnterNode(this);
            break;

        case Opcode.LOAD_RESOURCE:
            m_LoadedResourcePath = VirtualMachine.loadedTextLiteralString;
            m_LoadedResource     = UnityWrapper.LoadResource(m_LoadedResourcePath);
            pc++;
            break;

// TODO : Need to Test .
        case Opcode.PLAY_AUDIO_FROM_RESOURCE:
            m_LoadedResourcePath = VirtualMachine.loadedTextLiteralString;
            ISoundPlayer.Instance.PlayAudioClip(m_LoadedResource as AudioClip, m_LoadedResourcePath, ViNoConfig.prefsBgmVolume, 0f);
            m_LoadedResource = null;
            Resources.UnloadUnusedAssets();

            pc++;
            break;

        case Opcode.INSTANTIATE_AS_GAMEOBJECT:
            if (m_LoadedResource != null)
            {
                string parentName = VirtualMachine.loadedTextLiteralString;

                UnityWrapper.InstantiateAsGameObject(m_LoadedResource, parentName);

                m_LoadedResource = null;
                Resources.UnloadUnusedAssets();
            }
            else
            {
                Debug.LogError("Resource not loaded.");
            }
            pc++;
            break;

        case Opcode.DESTROY_OBJECT:
            string     goName = VirtualMachine.loadedTextLiteralString;
            GameObject go     = GameObject.Find(goName);                                // TODO : GO.Find is Slow .
            GameObject.Destroy(go);
            pc++;
            break;

        case Opcode.JUMP:               // Jump to loadedString Node  .
            ByteCodeReader.readString(code, pc + 2);
            GoToLabel(loadedString);
            ViNoDebugger.Log("NODE", "jump to :" + loadedString);
            break;

        case Opcode.IF:
            pc = ByteCodeReader.readString(code, pc + 2);
            string flagName = VirtualMachine.loadedString;
            Debug.Log("flag name :" + flagName);

            bool isOnOrOff = (code[pc] == 1) ? true : false;
            pc++;

            pc = ByteCodeReader.readString(code, pc + 1);
            string ifTarget = VirtualMachine.loadedString;
            Debug.Log("IF =>" + ifTarget);
            pc = ByteCodeReader.readString(code, pc + 1);
            string elseTarget = VirtualMachine.loadedString;
            Debug.Log("ELSE =>" + elseTarget);

            bool isFlagOn = ScenarioNode.Instance.flagTable.CheckFlagBy(flagName);
            if (isFlagOn == isOnOrOff)
            {
                Debug.Log("IF");
                GoToLabel(ifTarget);
            }
            else
            {
                Debug.Log("ELSE");
                GoToLabel(elseTarget);
            }
            break;

            // ----- Layer -----.
#if false
        case Opcode.LAYOPT:                             GOOptionNode.Do(paramHash);           pc++;   break;
#endif
        case Opcode.BEGIN_TRANSITION:   UnityWrapper.BeginTransition();         pc++;   break;

        case Opcode.END_TRANSITION:             UnityWrapper.EndTransition();           pc++;   break;

        case Opcode.SCENE_NODE:
            SceneData.SceneNodeData data = SceneCreator.CreateNodeData(paramHash);
            SceneCreator.Create(data);
            pc++;
            break;

        case Opcode.LOAD_SCENE:
//			bool destroy = ( code[ pc + 1 ] == 0 ) ? true : false ;
//			UnityWrapper.LoadScene( m_LoadedResource , destroy );
            LoadSceneNode.Do(m_LoadedResource, paramHash);
            m_LoadedResource = null;
            Resources.UnloadUnusedAssets();
            pc++;
            break;

        case Opcode.CLEAR_SCENE:
            GameObject advSceneRoot     = ViNoSceneManager.Instance.theSavedPanel;
            bool       immediateDestroy = false;
            SceneCreator.DestroyScene(advSceneRoot, immediateDestroy);
            pc++;
            break;

/*		case Opcode.PLAY_ANIMATION:
 *                      byte animationID = code[ pc + 1 ];
 *                      ViNoAnimationManager.Instance.PlayAnimation( (int)animationID );
 *                      pc+= 2;
 *                      break;
 * //*/

        // ----- Message -----.
        case Opcode.BR:
//			m_TextBuilder.Append( "\n" );
            pc++;           break;            //scriptBinder.BR( this );	pc++;		break;

        case Opcode.CM:         ClearMessage();                         pc++;           break;

        case Opcode.ER:
            AddToBacklog();
            ClearTextBuilder();
            if (m_MsgTargetTextBox != null)
            {
                m_MsgTargetTextBox.ClearMessage();
            }
            else
            {
                Debug.LogWarning("Current Message Target Not Set.");
            }
            pc++;
            break;

        case Opcode.PRINT:              scriptBinder.PRINT(this);                     pc++;           break;

        case Opcode.CURRENT:
            TriggerMessageEvent("OnMessageTargetChanged", code[pc + 1], "", true);
            break;

        case Opcode.SET_TEXT:
            TriggerMessageEvent("OnSetText", code[pc + 1], VirtualMachine.loadedTextLiteralString, true);
            m_CurrentText = m_MessageEventData.message;
            break;

        case Opcode.HIDE_MESSAGE:
            TriggerMessageEvent("OnHideMessage", code[pc + 1], "", false);
            break;

        // ------ System Opcode -----.
        case Opcode.START_WAIT:
            m_ElapsedSec = 0f;
            if (!string.IsNullOrEmpty(loadedTextLiteralString))
            {
                m_WaitSec = float.Parse(loadedTextLiteralString);
            }
            else
            {
                m_WaitSec = kWaitSec;
            }
            pc++;
            break;

        case Opcode.UPDATE_WAIT:
//			ViNoDebugger.Log( "VM" , "waiting ...");
            m_ElapsedSec += Time.deltaTime;
            if (m_ElapsedSec > m_WaitSec)
            {
                pc++;
            }
            break;

        case Opcode.STOP:
            // Wait Until Player choosing from options . or reached to the end of a leaf node .
            // Nothing to do...

            break;

        case Opcode.END:
            ViNoEventManager.Instance.TriggerEvent("OnFinishScenario");
            update = false;
            break;

        case Opcode.PLAY_SCENARIO:
            pc = ByteCodeReader.readString(code, pc + 2);
            string     scenarioName = loadedString;
            GameObject scenarioObj  = GOCache.SetActive(scenarioName, true);
            if (scenarioObj != null)
            {
                ScenarioNode s = scenarioObj.GetComponent <ScenarioNode>();
                s.Play();
            }
            break;

        case Opcode.FLAG_ON:
            if (ScenarioNode.Instance != null && ScenarioNode.Instance.flagTable != null)
            {
                ScenarioNode.Instance.flagTable.SetFlagBy(VirtualMachine.loadedTextLiteralString, true);
            }
            pc++;
            break;

        case Opcode.FLAG_OFF:
            if (ScenarioNode.Instance != null && ScenarioNode.Instance.flagTable != null)
            {
                ScenarioNode.Instance.flagTable.SetFlagBy(VirtualMachine.loadedTextLiteralString, false);
            }
            pc++;
            break;

        case Opcode.SELECTIONS:
            ISelectionsCtrl selCtrl = ISelectionsCtrl.Instance;
            if (selCtrl != null)
            {
                if (!selCtrl.IsActive())
                {
                    string title = VirtualMachine.loadedTextLiteralString;
                    selCtrl.SetTitle(title);
                    ISelectionsCtrl.Instance.ChangeActive(true);
                }
            }
            else
            {
                Debug.LogError("ISelectionsCtrl instance not found.");
            }
            pc++;
            break;

        case Opcode.LINK:               ISelectionsCtrl.Instance.AddSelection(ref paramHash); pc++;   break;

        case Opcode.WAIT_TOUCH:
            if (IScriptEngine.skip)
            {
                if (IScriptEngine.skipAlreadyPass && !VirtualMachine._ALREADY_PASS_THE_NODE)
                {
                    return;
                }

                _SkipText( );

                ISoundPlayer pl = ISoundPlayer.Instance;
                if (pl != null)
                {
                    if (pl.IsPlayingVoice())
                    {
                        pl.StopVoice();
                    }
                }
                m_CanTextProgress = true;
                return;
            }

            if (autoMode)
            {
                float dt = Time.deltaTime;
                m_TimeElapsed += dt;
                if (m_TimeElapsed > _AUTO_MODE_WAIT_TIME)
                {
                    m_TimeElapsed = 0f;
                    _SkipText();
                }
                return;
            }
            m_CanTextProgress = true;
            break;

//		case Opcode.PLAY_BGM:
//			break;

        // -----Audio -----.
        case Opcode.PLAY_SOUND:
            byte soundCategory = code[pc + 1];                  // 0: BGM 1:SE 2: VOICE.
            byte soundID       = code[pc + 2];

            UnityWrapper.PlaySound(soundCategory, soundID);
            if (soundCategory == 2)
            {
                SET_CURRENT_VOICE_ID(true, soundID);
            }
            pc += 3;
            break;

        case Opcode.STOP_SOUND:
            //TODO :

            pc++;
            break;

        case Opcode.STOP_VOICE:
            SET_CURRENT_VOICE_ID(false, 0);
            if (ISoundPlayer.Instance != null)
            {
                ISoundPlayer.Instance.StopVoice();
            }
            pc++;
            break;

        default:
            ViNoDebugger.LogError("VM", "PC : " + pc);
            break;
        }
    }
Ejemplo n.º 28
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.º 29
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.º 30
0
    protected void AnimationMove(TweenOperandData tweenData)
    {
        Hashtable paramHash = tweenData.paramTable;
        string    name      = ContainsKey_name(ref paramHash);

        GameObject root = tweenData.tweenTarget;

        if (root == null)
        {
            ViNoDebugger.LogError("tween target not found !");
            return;
        }

        Transform rootra = root.transform;

        if (string.IsNullOrEmpty(name))
        {
            name = "__animation";            // default animation name.
        }

        Animation animation = root.GetComponent <Animation>();

        if (animation == null)
        {
            animation = root.AddComponent <Animation>();
        }
        AnimationClip clip        = new AnimationClip();
        float         duration    = ContainsKey_duration(ref paramHash);
        bool          isMove      = false;
        bool          isRotate    = false;
        bool          isScale     = false;
        bool          isFromPos   = false;
        bool          isFromRot   = false;
        bool          isFromScale = false;
        WrapMode      wrapmode    = ContainsKey_mode(ref paramHash);
        int           method      = 0;

        if (paramHash.ContainsKey("method"))
        {
            string methodStr = paramHash["method"] as string;
            method = int.Parse(methodStr);
        }
        Vector3 move      = ContainsKey_moveXorYorZ(out isMove, ref paramHash, rootra.localPosition);
        Vector3 euler     = ContainsKey_rotateXorYorZ(out isRotate, ref paramHash, rootra.localEulerAngles);        //localRotation.eulerAngles );
        Vector3 scale     = ContainsKey_scaleXorYorZ(out isScale, ref paramHash, rootra.localScale);
        Vector3 fromPos   = ContainsKey_StrAndXorYorZ(out isFromPos, "fromPos", ref paramHash, rootra.localPosition);
        Vector3 fromRot   = ContainsKey_StrAndXorYorZ(out isFromRot, "fromRot", ref paramHash, rootra.localEulerAngles);
        Vector3 fromScale = ContainsKey_StrAndXorYorZ(out isFromScale, "fromScale", ref paramHash, rootra.localScale);

        clip.wrapMode = wrapmode;

        if (isMove)
        {
            switch (method)
            {
            case 0:                      // Linear.
                AnimationCurve animCurveX = AnimationCurve.Linear(0f, fromPos.x, duration, move.x);
                AnimationCurve animCurveY = AnimationCurve.Linear(0f, fromPos.y, duration, move.y);
                AnimationCurve animCurveZ = AnimationCurve.Linear(0f, fromPos.z, duration, move.z);
                clip.SetCurve("", typeof(Transform), "localPosition.x", animCurveX);
                clip.SetCurve("", typeof(Transform), "localPosition.y", animCurveY);
                clip.SetCurve("", typeof(Transform), "localPosition.z", animCurveZ);
                break;

            case 1:                     // Easeinout.
                animCurveX = AnimationCurve.EaseInOut(0f, fromPos.x, duration, move.x);
                animCurveY = AnimationCurve.EaseInOut(0f, fromPos.y, duration, move.y);
                animCurveZ = AnimationCurve.EaseInOut(0f, fromPos.z, duration, move.z);
                clip.SetCurve("", typeof(Transform), "localPosition.x", animCurveX);
                clip.SetCurve("", typeof(Transform), "localPosition.y", animCurveY);
                clip.SetCurve("", typeof(Transform), "localPosition.z", animCurveZ);
                break;
            }
        }

        if (isRotate)
        {
            Quaternion q1 = Quaternion.Euler(fromRot);
            Quaternion q2 = Quaternion.Euler(euler);

            switch (method)
            {
            case 0:                      // Linear.
                AnimationCurve animCurveX = AnimationCurve.Linear(0f, q1.x, duration, q2.x);
                AnimationCurve animCurveY = AnimationCurve.Linear(0f, q1.y, duration, q2.y);
                AnimationCurve animCurveZ = AnimationCurve.Linear(0f, q1.z, duration, q2.z);
                AnimationCurve animCurveW = AnimationCurve.Linear(0f, q1.w, duration, q2.w);

                clip.SetCurve("", typeof(Transform), "localRotation.x", animCurveX);
                clip.SetCurve("", typeof(Transform), "localRotation.y", animCurveY);
                clip.SetCurve("", typeof(Transform), "localRotation.z", animCurveZ);
                clip.SetCurve("", typeof(Transform), "localRotation.w", animCurveW);
                break;

            case 1:                     // Easeinout.
                animCurveX = AnimationCurve.EaseInOut(0f, q1.x, duration, q2.x);
                animCurveY = AnimationCurve.EaseInOut(0f, q1.y, duration, q2.y);
                animCurveZ = AnimationCurve.EaseInOut(0f, q1.z, duration, q2.z);
                animCurveW = AnimationCurve.EaseInOut(0f, q1.w, duration, q2.w);

                clip.SetCurve("", typeof(Transform), "localRotation.x", animCurveX);
                clip.SetCurve("", typeof(Transform), "localRotation.y", animCurveY);
                clip.SetCurve("", typeof(Transform), "localRotation.z", animCurveZ);
                clip.SetCurve("", typeof(Transform), "localRotation.w", animCurveW);
                break;
            }
        }

        if (isScale)
        {
            switch (method)
            {
            case 0:                      // Linear.
                AnimationCurve animCurveX = AnimationCurve.Linear(0f, fromScale.x, duration, scale.x);
                AnimationCurve animCurveY = AnimationCurve.Linear(0f, fromScale.y, duration, scale.y);
                AnimationCurve animCurveZ = AnimationCurve.Linear(0f, fromScale.z, duration, scale.z);
                clip.SetCurve("", typeof(Transform), "localScale.x", animCurveX);
                clip.SetCurve("", typeof(Transform), "localScale.y", animCurveY);
                clip.SetCurve("", typeof(Transform), "localScale.z", animCurveZ);
                break;

            case 1:                     // Easeinout.
                animCurveX = AnimationCurve.EaseInOut(0f, fromScale.x, duration, scale.x);
                animCurveY = AnimationCurve.EaseInOut(0f, fromScale.y, duration, scale.y);
                animCurveZ = AnimationCurve.EaseInOut(0f, fromScale.z, duration, scale.z);
                clip.SetCurve("", typeof(Transform), "localScale.x", animCurveX);
                clip.SetCurve("", typeof(Transform), "localScale.y", animCurveY);
                clip.SetCurve("", typeof(Transform), "localScale.z", animCurveZ);
                break;
            }
        }

        ViNoAnimationListener animcb = root.GetComponent <ViNoAnimationListener>();

        if (animcb == null)
        {
            root.AddComponent <ViNoAnimationListener>();
        }

        AnimationEvent tweenFinished = new AnimationEvent();

        tweenFinished.time            = duration;
        tweenFinished.intParameter    = 123;
        tweenFinished.stringParameter = "end";
        tweenFinished.functionName    = "AnimationFinishedCallback";

        clip.AddEvent(tweenFinished);

        animation.AddClip(clip, name);

        // Now, Start the Animation.
        animation.Play(name);

        // Is  paramHash Contains Key "sendDelay" ? .
        ContainsKey_sendDelayAndStartCoroutine(ref paramHash);
    }