Пример #1
0
    /// <summary>
    /// Creates A new scenario.
    /// </summary>
    /// <returns>
    /// return the Created GameObject Attached a New Scenario Node.
    /// </returns>
    static public GameObject CreateANewScenario(string scenarioName, bool startAndPlay)
    {
//		GameObject vinoObj = GetViNoObject();
        GameObject scenarioObj = GameObject.Find(scenarioName);

        if (scenarioObj == null)
        {
            scenarioObj = new GameObject(scenarioName);
//			scenarioObj.transform.parent = vinoObj.transform;
            scenarioObj.AddComponent <ScenarioNode>();
        }

        // if a New ScenarioNode is Played at Start , Other ScenarioNode objects of all the are Not Played at Start.
        if (startAndPlay)
        {
            ScenarioNode[] snodes = GameObject.FindObjectsOfType(typeof(ScenarioNode)) as ScenarioNode[];
            for (int i = 0; i < snodes.Length; i++)
            {
                snodes[i].m_PlayAtStart = false;
            }
        }

        GameObject startObj  = new GameObject("START");
        ViNode     startNode = startObj.AddComponent <ViNode>();

        startObj.transform.parent = scenarioObj.transform;

        ScenarioNode scenarioNode = scenarioObj.GetComponent <ScenarioNode>();

        scenarioNode.startNode     = startNode;
        scenarioNode.m_PlayAtStart = startAndPlay;
        return(scenarioObj);
    }
Пример #2
0
    public void ReIndexChildren()
    {
        ViNode[] nodes = GetComponentsInChildren <ViNode>();
        if (nodes != null)
        {
            int        index   = 0;
            GameObject nodeObj = null;
            for (int i = 0; i < nodes.Length; i++)
            {
                ViNode node = nodes[i];
                if (node.name.Equals(name) || node.gameObject == nodeObj)
                {
                    continue;                           // Dont Rename MySelf.
                }

                nodeObj = nodes[i].gameObject;

                // Extract 1_Dialog to "1_" and "Dialog".
                string[] strs = node.name.Split("_"[0]);
                if (strs.Length > 1)
                {
                    node.name = (index).ToString() + "_" + strs[1];
                }
                else
                {
                    node.name = (index).ToString() + "_" + node.name;
                }
                index++;
            }
        }
    }
Пример #3
0
    /// <summary>
    /// Play From a Node.
    /// </summary>
    public void PlayFrom(ViNode node)
    {
        CheckInstance();

        string tag = node.GetNodeTag(node.name);

        VM.Instance.RunWithTag(tag);
    }
Пример #4
0
    static public void CreateViNodeOfMenu( )
    {
        Transform parentNodeTra = (Selection.activeGameObject != null) ? Selection.activeGameObject.transform : null;

        ViNode node = ViNoToolUtil.AddViNodeGameObject <ViNode>("ViNode", parentNodeTra);

        EditorGUIUtility.PingObject(node.gameObject);
    }
Пример #5
0
    public void SetChild(ViNode childNode)
    {
        if (childNode == null)
        {
            return;
        }

        Transform thisTra    = transform;
        int       childCount = this.transform.GetChildCount();
        int       index      = childCount - 1;

        childNode.name             = index + "_" + childNode.name;
        childNode.transform.parent = thisTra;
    }
Пример #6
0
 public override void ToScenarioScript(ref System.Text.StringBuilder sb)
 {
     if (units != null && units.Length > 0)
     {
         for (int i = 0; i < units.Length; i++)
         {
             ViNode target    = units[i].targetNode;
             string targetStr = target.GetNodeTag(target.name);
             sb.Append("[link target=*" + targetStr + "]" + units[i].text + "[endlink][r]");                         // This is KiriKiri Script.
             sb.Append(System.Environment.NewLine);
         }
         sb.Append("[s]");
         sb.Append(System.Environment.NewLine);
     }
 }
Пример #7
0
    static public void CreateSelectionsNodeOfMenu( )
    {
        ISelectionsCtrl sel = GameObject.FindObjectOfType(typeof(ISelectionsCtrl)) as ISelectionsCtrl;

        if (sel == null)
        {
            DrawObjectsTab.CreateGUISelectionsCtrl();
        }

        Transform parentNodeTra = (Selection.activeGameObject != null) ? Selection.activeGameObject.transform : null;

        SelectionsNode node       = ViNoToolUtil.AddViNodeGameObject <SelectionsNode>("Selections", parentNodeTra);
        ViNode         childNode1 = ViNoToolUtil.AddViNodeGameObject <ViNode>("Selected1", node.transform);
        ViNode         childNode2 = ViNoToolUtil.AddViNodeGameObject <ViNode>("Selected2", node.transform);

        DialogPartNode dlg1 = CreateDialogNode("name", "Selected 1");           //ViNoToolUtil.AddViNodeGameObject<DialogPartNode>( "Dialog" , childNode1.transform );

        dlg1.transform.parent = childNode1.transform;

        DialogPartNode dlg2 = CreateDialogNode("name", "Selected 2");           //ViNoToolUtil.AddViNodeGameObject<DialogPartNode>( "Dialog" , childNode2.transform );

        dlg2.transform.parent = childNode2.transform;

        node.units               = new SelectionsNode.SelectUnit [2];
        node.units[0]            = new SelectionsNode.SelectUnit();
        node.units[0].targetNode = childNode1;
        node.units[0].text       = "Selection 1";
        node.units[0].index      = 0;

        node.units[1]            = new SelectionsNode.SelectUnit();
        node.units[1].targetNode = childNode2;
        node.units[1].text       = "Selection 2";
        node.units[1].index      = 1;

        EditorGUIUtility.PingObject(node.gameObject);
    }
Пример #8
0
    /// <summary>
    /// Play From a Node.
    /// </summary>
    public void PlayFrom( ViNode node )
    {
        CheckInstance();

        string tag = node.GetNodeTag( node.name );
        VM.Instance.RunWithTag( tag );
    }
Пример #9
0
    public static void OnGUI_ViNode( ViNode node , bool drawChildList , bool showNextNode )
    {
        GUICommon.DrawLineSpace( 7f , 7f );

        bool hasViNode = false;
        if( drawChildList ){

            Color savedCol = GUI.color;
            GUI.color = Color.green;

        //			node.startAndActive = EditorGUILayout.Toggle( "Start and Active" , node.startAndActive  );
        //			EditorGUILayout.LabelField( "ViNode List" , GUILayout.Width( 200f ) );

            int childCount= node.transform.GetChildCount();
            for( int i=0;i<childCount;i++){
                Transform childTra = node.transform.GetChild( i );
             	ViNode vinode = childTra.GetComponent<ViNode>();
                if( vinode != null ){
                    hasViNode = true;
                    Undo.RegisterUndo( childTra.gameObject , "active" + childTra.name );

                    EditorGUILayout.BeginHorizontal();
        //						bool t = EditorGUILayout.Toggle( childTra.gameObject.activeInHierarchy , GUILayout.Width( 10f) );

                        // Toggle active.
                        if( GUILayout.Button( i.ToString () , GUILayout.Width ( 20f ) ) ){
                            childTra.gameObject.SetActive( ! childTra.gameObject.activeInHierarchy  );
                        }
        // Need to be fixed.
        #if false
                        if( GUILayout.Button( "up" , GUILayout.Width ( 35f ) ) ){
                            childTra.name = childTra.name.Replace( i + "_" , ( i + 1 ) + "_" );
                            Transform parantTra = childTra.parent;
                            childTra.parent = null;
                            childTra.parent = parantTra;

                            Transform childTra2 = node.transform.GetChild( i + 1 );
                            childTra2.name = childTra2.name.Replace( ( i + 1 ) + "_" , i + "_" );
                            parantTra = childTra2.parent;
                            childTra2.parent = null;
                            childTra2.parent = parantTra;
                        }

                        if( GUILayout.Button( "dwn" , GUILayout.Width ( 35f ) ) ){
                            childTra.name = childTra.name.Replace( i + "_" , ( i - 1 )  + "_" );

                            Transform childTra2 = node.transform.GetChild( i - 1 );
                            childTra2.name = childTra2.name.Replace( ( i - 1 ) + "_" , i + "_" );
                            Transform parantTra = childTra2.parent;
                            childTra2.parent = null;
                            childTra2.parent = parantTra;
                        }
        #endif
                        GUI.enabled = childTra.gameObject.activeInHierarchy;

                        if( GUILayout.Button ( childTra.name ) ){
                            EditorGUIUtility.PingObject( childTra.gameObject );
                            if( Application.isPlaying ){
                                VM.Instance.GoToLabel( vinode.GetNodeLabel() );
                            }
                        }

                        GUI.enabled = true;

                    EditorGUILayout.EndHorizontal ();
                }
            }
            GUI.color = savedCol;
        }

        if( hasViNode ){
            EditorGUILayout.LabelField( "When execution order is not right in Children," );
            EditorGUILayout.LabelField( "Please push RefreshChildren button to fix." );

            EditorGUILayout.BeginHorizontal();

                if( GUILayout.Button( "RefreshChildren" ) ){
                    node.RefreshChildren();
                }

                if( GUILayout.Button( "ReIndexChildren" ) ){
                    ViNode[] childNodes = node.GetComponentsInChildren<ViNode>();

                    Undo.RegisterUndo( childNodes , "ReIndexChildren" );

                    node.ReIndexChildren ();
                }

            EditorGUILayout.EndHorizontal();
        }

        GUICommon.DrawLineSpace( 5f , 5f );
    }
//	private SerializedProperty soundDataProp = null;

    static private void CompileAndSaveAsBinaryFile(string fileName, ScenarioNode scenario)
    {
        ByteCodes btcodes = scenario.Compile();

        ViNode.SaveByteCodesToFile(fileName, btcodes.GetCode());
    }
Пример #11
0
    // --------------- public Methods --------------------------------------.

    public void AddNode <T>(ViNode aNode) where T : ViNode
    {
        aNode.transform.parent = transform;
    }
Пример #12
0
	public override void OnInspectorGUI(){		
		ViNode node = target as ViNode;
		
		NodeGUI.OnGUI_ViNode( node , true , true );			
	}
Пример #13
0
    static public void OnGUI_ViNode(ViNode node, bool drawChildList, bool showNextNode)
    {
        GUICommon.DrawLineSpace(7f, 7f);

        bool hasViNode = false;

        if (drawChildList)
        {
            Color savedCol = GUI.color;
            GUI.color = Color.green;

//			node.startAndActive = EditorGUILayout.Toggle( "Start and Active" , node.startAndActive  );
//			EditorGUILayout.LabelField( "ViNode List" , GUILayout.Width( 200f ) );

            int childCount = node.transform.GetChildCount();
            for (int i = 0; i < childCount; i++)
            {
                Transform childTra = node.transform.GetChild(i);
                ViNode    vinode   = childTra.GetComponent <ViNode>();
                if (vinode != null)
                {
                    hasViNode = true;
                    Undo.RegisterUndo(childTra.gameObject, "active" + childTra.name);

                    EditorGUILayout.BeginHorizontal();
//						bool t = EditorGUILayout.Toggle( childTra.gameObject.activeInHierarchy , GUILayout.Width( 10f) );

                    // Toggle active.
                    if (GUILayout.Button(i.ToString(), GUILayout.Width(20f)))
                    {
                        childTra.gameObject.SetActive(!childTra.gameObject.activeInHierarchy);
                    }
// Need to be fixed.
#if false
                    if (GUILayout.Button("up", GUILayout.Width(35f)))
                    {
                        childTra.name = childTra.name.Replace(i + "_", (i + 1) + "_");
                        Transform parantTra = childTra.parent;
                        childTra.parent = null;
                        childTra.parent = parantTra;

                        Transform childTra2 = node.transform.GetChild(i + 1);
                        childTra2.name   = childTra2.name.Replace((i + 1) + "_", i + "_");
                        parantTra        = childTra2.parent;
                        childTra2.parent = null;
                        childTra2.parent = parantTra;
                    }

                    if (GUILayout.Button("dwn", GUILayout.Width(35f)))
                    {
                        childTra.name = childTra.name.Replace(i + "_", (i - 1) + "_");

                        Transform childTra2 = node.transform.GetChild(i - 1);
                        childTra2.name = childTra2.name.Replace((i - 1) + "_", i + "_");
                        Transform parantTra = childTra2.parent;
                        childTra2.parent = null;
                        childTra2.parent = parantTra;
                    }
#endif
                    GUI.enabled = childTra.gameObject.activeInHierarchy;

                    if (GUILayout.Button(childTra.name))
                    {
                        EditorGUIUtility.PingObject(childTra.gameObject);
                        if (Application.isPlaying)
                        {
                            VM.Instance.GoToLabel(vinode.GetNodeLabel());
                        }
                    }

                    GUI.enabled = true;

                    EditorGUILayout.EndHorizontal();
                }
            }
            GUI.color = savedCol;
        }

        if (hasViNode)
        {
            EditorGUILayout.LabelField("When execution order is not right in Children,");
            EditorGUILayout.LabelField("Please push RefreshChildren button to fix.");

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("RefreshChildren"))
            {
                node.RefreshChildren();
            }

            if (GUILayout.Button("ReIndexChildren"))
            {
                ViNode[] childNodes = node.GetComponentsInChildren <ViNode>();

                Undo.RegisterUndo(childNodes, "ReIndexChildren");

                node.ReIndexChildren();
            }

            EditorGUILayout.EndHorizontal();
        }

        GUICommon.DrawLineSpace(5f, 5f);
    }