コード例 #1
0
    static public GameObject Create(SceneData.SceneNodeData data)
    {
        ViNoSceneManager sm = GameObject.FindObjectOfType(typeof(ViNoSceneManager)) as ViNoSceneManager;
        GameObject       go = sm.CreateSceneNode(ref data);

        return(go);
    }
コード例 #2
0
ファイル: SceneCreator.cs プロジェクト: Joon-min/wiper
    public static SceneData.SceneNodeData CreateNodeData( Hashtable attrTable )
    {
        SceneData.SceneNodeData data = new SceneData.SceneNodeData();
        data.name = attrTable["name"] as string;
        data.parentname = attrTable["parentname"] as string;

        ParamUtil.SetFloatAttr( out data.posX , "posX" , attrTable , 0f );
        ParamUtil.SetFloatAttr( out data.posY , "posY" , attrTable , 0f );
        ParamUtil.SetFloatAttr( out data.posZ , "posZ" , attrTable , 0f );

        ParamUtil.SetFloatAttr( out data.rotX , "rotX" , attrTable , 0f );
        ParamUtil.SetFloatAttr( out data.rotY , "rotY" , attrTable , 0f );
        ParamUtil.SetFloatAttr( out data.rotZ , "rotZ" , attrTable , 0f );

        ParamUtil.SetFloatAttr( out data.sclX , "sclX" , attrTable , 1f );
        ParamUtil.SetFloatAttr( out data.sclY , "sclY" , attrTable , 1f );
        ParamUtil.SetFloatAttr( out data.sclZ , "sclZ" , attrTable , 1f );

        data.uiAtlasName = attrTable["uiAtlasName"] as string;
        data.texturePath = attrTable["texturePath"] as string;
        ParamUtil.SetFloatAttr( out data.alpha , "alpha" , attrTable , 1f );
        if( attrTable.ContainsKey( "show") ){
            data.show = ViNoStringExtensions.IsTrueOrYes( attrTable["show"] as string  );
        }
        if( attrTable.ContainsKey( "makePixelPerfect") ){
            data.makePixelPerfect = ViNoStringExtensions.IsTrueOrYes( attrTable["makePixelPerfect"] as string  );
        }
        return data;
    }
コード例 #3
0
    static private bool m_DestroyRequested;                     // Destroy Calling Locker .

    static public SceneData.SceneNodeData CreateNodeData(Hashtable attrTable)
    {
        SceneData.SceneNodeData data = new SceneData.SceneNodeData();
        data.name       = attrTable["name"] as string;
        data.parentname = attrTable["parentname"] as string;

        ParamUtil.SetFloatAttr(out data.posX, "posX", attrTable, 0f);
        ParamUtil.SetFloatAttr(out data.posY, "posY", attrTable, 0f);
        ParamUtil.SetFloatAttr(out data.posZ, "posZ", attrTable, 0f);

        ParamUtil.SetFloatAttr(out data.rotX, "rotX", attrTable, 0f);
        ParamUtil.SetFloatAttr(out data.rotY, "rotY", attrTable, 0f);
        ParamUtil.SetFloatAttr(out data.rotZ, "rotZ", attrTable, 0f);

        ParamUtil.SetFloatAttr(out data.sclX, "sclX", attrTable, 1f);
        ParamUtil.SetFloatAttr(out data.sclY, "sclY", attrTable, 1f);
        ParamUtil.SetFloatAttr(out data.sclZ, "sclZ", attrTable, 1f);

        data.uiAtlasName = attrTable["uiAtlasName"] as string;
        data.texturePath = attrTable["texturePath"] as string;
        ParamUtil.SetFloatAttr(out data.alpha, "alpha", attrTable, 1f);
        if (attrTable.ContainsKey("show"))
        {
            data.show = ViNoStringExtensions.IsTrueOrYes(attrTable["show"] as string);
        }
        if (attrTable.ContainsKey("makePixelPerfect"))
        {
            data.makePixelPerfect = ViNoStringExtensions.IsTrueOrYes(attrTable["makePixelPerfect"] as string);
        }
        return(data);
    }
コード例 #4
0
    static public void SaveViNoSceneNodes(ref List <SceneData.SceneNodeData> nodelist, ISpriteFactory fact)
    {
        ViNoSceneNode[] sceneNodesData = GameObject.FindObjectsOfType(typeof(ViNoSceneNode)) as ViNoSceneNode[];
        if (sceneNodesData != null)
        {
            for (int i = 0; i < sceneNodesData.Length; i++)
            {
                GameObject sceneNode = sceneNodesData[i].gameObject;
                if (sceneNodesData[i].singleNodeData != null)
                {
                    SceneData.SceneNodeData data = sceneNodesData[i].singleNodeData;
                    nodelist.Add(data);
                    fact.SaveData(ref data, sceneNode);
                }

/*
 *                              else{
 *                                      if( sceneNodesData[ i ].scrNodeData.nodesData != null ){
 *                                              int len = sceneNodesData[ i ].scrNodeData.nodesData.Length;
 *                                              for( int k=0;k<len;k++){
 *                                                      SceneData.SceneNodeData data =  sceneNodesData[ i ].scrNodeData.nodesData[ k ];
 *                                                      nodelist.Add( data );
 *                                                      GameObject obj = GameObject.Find( data.name );//sceneNode.gameObject.transform.FindChild( data.name ).gameObject;
 *                                                      fact.SaveData( ref data , obj );
 *                                              }
 *                                      }
 *                              }
 * //*/
            }
        }
    }
コード例 #5
0
 public void CreateSceneNodes()
 {
     for (int i = 0; i < nodeData.Length; i++)
     {
         SceneData.SceneNodeData data = nodeData[i];
         CreateSceneNode(ref data);
     }
 }
コード例 #6
0
ファイル: ViNoSceneSaveUtil.cs プロジェクト: Joon-min/wiper
    public static void SaveDataRecursively( GameObject savedObj , ref List<SceneData.SceneNodeData> nodelist , ref ISpriteFactory spriteFact )
    {
        SceneData.SceneNodeData data = new SceneData.SceneNodeData();
        nodelist.Add( data );
        spriteFact.SaveData( ref data , savedObj );

        int count = savedObj.transform.GetChildCount();
        if( count > 0 ){
            for(int i=0;i<count;i++){
                GameObject childObj =  savedObj.transform.GetChild( i ).gameObject;
                SaveDataRecursively( childObj ,ref nodelist , ref spriteFact );
            }
        }
    }
コード例 #7
0
        GameObject CreateActorRoot(ActorInfo info, ActorInfo.ActorState actorState)
        {
            float scl = actorState.sizeInPercent / 100f;

            SceneData.SceneNodeData actorNodeData = new SceneData.SceneNodeData();
            actorNodeData.name       = info.actorName;
            actorNodeData.parentname = ViNoSceneManager.Instance.theSavedPanel.name;
            actorNodeData.sclX       = scl;
            actorNodeData.sclY       = scl;
            actorNodeData.sclZ       = 1f;
            actorNodeData.alpha      = 1f;
            actorNodeData.show       = true;
            GameObject actorGO = SceneCreator.Create(actorNodeData);

//			m_ActorGOMap[ info.actorName ] = actorGO;
            return(actorGO);
        }
コード例 #8
0
    static public void SaveDataRecursively(GameObject savedObj, ref List <SceneData.SceneNodeData> nodelist, ref ISpriteFactory spriteFact)
    {
        SceneData.SceneNodeData data = new SceneData.SceneNodeData();
        nodelist.Add(data);
        spriteFact.SaveData(ref data, savedObj);

        int count = savedObj.transform.GetChildCount();

        if (count > 0)
        {
            for (int i = 0; i < count; i++)
            {
                GameObject childObj = savedObj.transform.GetChild(i).gameObject;
                SaveDataRecursively(childObj, ref nodelist, ref spriteFact);
            }
        }
    }
コード例 #9
0
    static public void DrawSceneNodeField(SceneData.SceneNodeData data, int offset)
    {
        float y = 20 + offset;

        GUI.Box(new Rect(20, y, 200, 200), "");
        y              += 20;
        data.name       = EditorGUI.TextField(new Rect(30, y, 200, 20), "Name", data.name);
        y              += 20;
        data.parentname = EditorGUI.TextField(new Rect(30, y, 200, 20), "Parent", data.parentname);
        y              += 20;
        Vector3 pos = Vector3.zero;

        pos.x     = data.posX;
        pos.y     = data.posY;
        pos.z     = data.posZ;
        pos       = EditorGUI.Vector3Field(new Rect(30, y, 150, 20), "position", pos);
        data.posX = pos.x;
        data.posY = pos.y;
        data.posZ = pos.z;
    }
コード例 #10
0
    public GameObject CreateSceneNode(ref SceneData.SceneNodeData data)
    {
        GameObject node;
        string     nodePath = data.parentname + "/" + data.name;

        node = GameObject.Find(nodePath);
        if (node == null)
        {
            node = GameObject.Find(data.texturePath);
        }
        Vector3    pos = new Vector3(data.posX, data.posY, data.posZ);
        Vector3    scl = new Vector3(data.sclX, data.sclY, data.sclZ);
        GameObject pr  = GameObject.Find(data.parentname);

        if (spriteFactory != null)
        {
            node = spriteFactory.Create(ref data, node, pos, scl, pr);
        }
        if (node != null)
        {
            data.name = node.name;
        }
        return(node);
    }
コード例 #11
0
ファイル: VM.cs プロジェクト: wangsy1985/UnityProjects
    // ------------- 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;
        }
    }
コード例 #12
0
ファイル: SceneEvent.cs プロジェクト: Joon-min/wiper
 GameObject CreateActorRoot( ActorInfo info , ActorInfo.ActorState actorState )
 {
     float scl = actorState.sizeInPercent / 100f;
     SceneData.SceneNodeData actorNodeData =  new SceneData.SceneNodeData();
     actorNodeData.name = info.actorName;
     actorNodeData.parentname = ViNoSceneManager.Instance.theSavedPanel.name;
     actorNodeData.sclX = scl;
     actorNodeData.sclY = scl;
     actorNodeData.sclZ = 1f;
     actorNodeData.alpha = 1f;
     actorNodeData.show = true;
     GameObject actorGO = SceneCreator.Create( actorNodeData );
     //			m_ActorGOMap[ info.actorName ] = actorGO;
     return 	actorGO;
 }