Exemplo n.º 1
0
        /// <summary>
        /// <para>Eng. Assign Vinove file on Canvas UI GameObject. </para>
        /// <para>Kor. 비노비 파일을 인게임 매니저 오브젝트에 등록합니다. </para>
        /// </summary>
        public void VinoveInitialize()
        {
#if UNITY_EDITOR
            string _archivePath = Application.dataPath + "/TemporaryArchive.vnvach";

            if (System.IO.File.Exists(_archivePath))
            {
                var loaded = Resources.Load <Vinove>("Gamedat");
                AssetPathArchive _archive = BinaryIOManager.GetInst().BinaryDeserialize <AssetPathArchive>(_archivePath);

                AssetDatabase.ImportAsset(_archive._path);
                var currentLoaded = AssetDatabase.LoadAssetAtPath <Vinove>(_archive._path);
                _currentVinove = currentLoaded as Vinove;
                // ----------------------- Vinove - Starter Scene -----------------------

                if (ErrorDetector.Instance.IsStringHasData(_archive._sceneUID))
                {
                    // ----------------------- Scene -----------------------
                    _currentScene = _currentVinove.FindSceneWithUID(_archive._sceneUID);

                    // ----------------------- Scene - Specific Script -----------------------

                    if (ErrorDetector.Instance.IsStringHasData(_archive._scriptUID))
                    {
                        _currentScript = _currentScene.FindScriptWithUID(_archive._scriptUID);
                    }
                    // ----------------------- Scene - Starter Script -----------------------
                    else if (ErrorDetector.Instance.IsStringHasData(_currentScene.StarterUID))
                    {
                        _currentScript = _currentScene.FindScriptWithUID(_currentScene.StarterUID);
                    }
                }
            }
#else
            if (_currentVinove == null)
            {
                _currentVinove = Resources.Load <Vinove>("Gamedat");

                // ----------------------- Vinove - Starter Scene -----------------------

                if (ErrorDetector.Instance.IsStringHasData(_currentVinove.StarterUID))
                {
                    // ----------------------- Scene -----------------------
                    _currentScene = _currentVinove.FindSceneWithUID(_currentVinove.StarterUID);

                    // ----------------------- Scene - Specific Script -----------------------

                    if (ErrorDetector.Instance.IsStringHasData(_currentScene.StarterUID))
                    {
                        _currentScript = _currentScene.FindScriptWithUID(_currentScene.StarterUID);
                    }
                }
            }
#endif
        }
Exemplo n.º 2
0
        /// <summary>
        /// <para>Eng. Load all save file in local save folder </para>
        /// <para>Kor. 세이브 폴더내에 저장된 파일을 게임으로 모두 불러옵니다. </para>
        /// </summary>
        void ReloadSaveFile(string _path)
        {
            VinoveGameSaveData _saveData = BinaryIOManager.GetInst().BinaryDeserialize <VinoveGameSaveData>(_path);

            _saveDatas.Add(_saveData);

            VinoveScript _script = InGameManager.GetInstance()._currentVinove.FindSceneWithUID(_saveData._parentSceneUID).FindScriptWithUID(_saveData._scriptUID);

            GameObject _instantiatedButton = Instantiate(_savedFileButtonPrefab, _contentParent.transform);

            _instantiatedButton.GetComponent <SavedButtonManager>().ChangeSaveData(_saveData);
            _instantiatedButton.GetComponent <SavedButtonManager>().ChangeTexts(_saveData._savedDate, _script.ScriptConversation.Speaker, _script.ScriptConversation.Dialog);
            _savedFileButtons.Add(_instantiatedButton);
        }
Exemplo n.º 3
0
        ///////////////////////////////
        /// Save & Load Sequence

        /// <summary>
        /// <para>Eng. Load all save file in local save folder </para>
        /// <para>Kor. 세이브 폴더내에 저장된 파일을 게임으로 모두 불러옵니다. </para>
        /// </summary>
        void ReloadSaveFiles()
        {
            DirectoryInfo info = new System.IO.DirectoryInfo(_saveFolderDir);

            FileInfo [] fileInfo = info.GetFiles();

            foreach (FileInfo file in fileInfo)
            {
                if (file.Name.EndsWith(".sav"))
                {
                    VinoveGameSaveData _saveData = BinaryIOManager.GetInst().BinaryDeserialize <VinoveGameSaveData>(file.FullName);
                    _saveDatas.Add(_saveData);

                    VinoveScript _script = InGameManager.GetInstance()._currentVinove.FindSceneWithUID(_saveData._parentSceneUID).FindScriptWithUID(_saveData._scriptUID);

                    GameObject _instantiatedButton = Instantiate(_savedFileButtonPrefab, _contentParent.transform);
                    _instantiatedButton.GetComponent <SavedButtonManager>().ChangeSaveData(_saveData);
                    _instantiatedButton.GetComponent <SavedButtonManager>().ChangeTexts(_saveData._savedDate, _script.ScriptConversation.Speaker, _script.ScriptConversation.Dialog);
                    _savedFileButtons.Add(_instantiatedButton);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// <para>Eng. Create class for archive and save to file. </para>
        /// <para>Kor. 저장용 클래스를 생성하고, 파일화 하여 저장합니다. </para>
        /// </summary>
        void SaveData()
        {
            VinoveGameSaveData _saveData = new VinoveGameSaveData();

            _saveData._parentSceneUID          = _parentSceneUID;
            _saveData._scriptUID               = _saveTargetUID;
            _saveData._speakerIllustKey        = _speakerIllustKey;
            _saveData._speakerIllustColorAlpha = _speakerIllustColorAlpha;
            _saveData._speakerIllustActivated  = _speakerIllustActivated;

            _saveData._savedDate = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");

            BinaryIOManager.GetInst().BinarySerialize <VinoveGameSaveData>(_saveData, _saveFolderDir + _saveData._savedDate + ".sav");

            ReloadSaveFile(_saveFolderDir + _saveData._savedDate + ".sav");

            if (_state == SaveLoadSlotManagerState.NewGameSave)
            {
                DisableSlot();
                MainMenuManager.GetInstance().DisableMainMenu();
                InGameManager.GetInstance().NewGameInitialize();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// <para>Eng. Create class for archive and save to file. </para>
        /// <para>Kor. 저장용 클래스를 생성하고, 파일화 하여 저장합니다. </para>
        /// </summary>
        void SaveData(GameObject _button)
        {
            VinoveGameSaveData _saveData = _button.GetComponent <SavedButtonManager>()._savedData;
            string             _tmpDate  = _saveData._savedDate;

            _saveData._parentSceneUID          = _parentSceneUID;
            _saveData._scriptUID               = _saveTargetUID;
            _saveData._savedDate               = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
            _saveData._speakerIllustKey        = _speakerIllustKey;
            _saveData._speakerIllustColorAlpha = _speakerIllustColorAlpha;
            _saveData._speakerIllustActivated  = _speakerIllustActivated;

            System.IO.File.Delete(_saveFolderDir + _tmpDate + ".sav");
            BinaryIOManager.GetInst().BinarySerialize <VinoveGameSaveData>(_saveData, _saveFolderDir + _saveData._savedDate + ".sav");

            ReloadSaveFile(_saveData);

            if (_state == SaveLoadSlotManagerState.NewGameSave)
            {
                DisableSlot();
                MainMenuManager.GetInstance().DisableMainMenu();
                InGameManager.GetInstance().NewGameInitialize();
            }
        }
Exemplo n.º 6
0
        ////////////////////////////////////////////////////////////////////////
        /// Func

        /// <summary>
        /// <para>Eng. GraphViewer Event Proc Func </para>
        /// <para>Kor. GraphViewer의 이벤트를 담당하는 함수 </para>
        /// </summary>
        /// <param name="_vinove"> <para> Eng. Currently opened vinove file</para>
        ///                           <para> Kor. 현재 열린 비노비 파일 </para> </param>
        /// <param name="_canvasMousePos"> <para> Eng. Mouse pos on Canvas</para>
        ///                           <para> Kor. 캔버스 내에서의 마우스 위치</para> </param>
        static void GraphEvents(Vinove _vinove, Vector2 _canvasMousePos)
        {
            if (IsMouseOnMinimap())
            {
            }
            else
            {
                if (e.type == EventType.Repaint)
                {
                    needRepaint = false;
                }

                if (e.type == EventType.MouseUp)
                {
                    graphTranslating = false;

                    hoverScene  = null;
                    hoverBranch = null;
                    hoverMerge  = null;
                }

                if (e.type == EventType.MouseMove)
                {
                    hoverScene = currentVinove.IsContainWholeGraph(e.mousePosition);
                    if (hoverScene == null)
                    {
                        hoverBranch = currentVinove.IsContainWholeBranch(e.mousePosition);
                        if (hoverBranch == null)
                        {
                            hoverMerge = currentVinove.IsContainWholeMerge(e.mousePosition);
                        }
                    }

                    needRepaint = true;
                }

                if (e.type == EventType.ScrollWheel)
                {   // Zoom
                    if (canvasRect.Contains(e.mousePosition))
                    {
                        float zoomCtrl  = e.control ? 0.1f : 0.2f;
                        float zoomValue = e.delta.y > 0 ? -zoomCtrl : zoomCtrl;

                        ZoomWithFocus(e.mousePosition, zoomValue);
                        e.Use();
                    }
                }

                if (((e.alt && e.button == 0 && e.type == EventType.MouseDrag && e.isMouse)) ||
                    (e.button == 2 && e.type == EventType.MouseDrag && canvasRect.Contains(e.mousePosition)))
                {   //translation canvas
                    Translation += e.delta;

                    e.Use();
                }

                if (e.type == EventType.MouseDown && e.button == 1 && canvasRect.Contains(e.mousePosition))
                {   // Open node popupMenu
                    GenericMenu popupMenu = new GenericMenu();

                    VinoveScene  overScene  = currentVinove.IsContainWholeGraph(e.mousePosition);
                    VinoveBranch overBranch = currentVinove.IsContainWholeBranch(e.mousePosition);
                    VinoveMerge  overMerge  = currentVinove.IsContainWholeMerge(e.mousePosition);

                    if (overScene == null && overBranch == null && overMerge == null)
                    {   // if, right click not on scene node
                        popupMenu.AddItem(new GUIContent("Add Scene"), false, () =>
                        {
                            currentVinove.CreateScene("New Scene", new Rect(_canvasMousePos.x, _canvasMousePos.y, 200, 100));
                            Debug.Log("popupMenu_AddScene Test");
                        });

                        popupMenu.AddItem(new GUIContent("Add Branch"), false, () =>
                        {
                            currentVinove.CreateBranch("New Branch", new Rect(_canvasMousePos.x, _canvasMousePos.y, 150, 200));
                            Debug.Log("popupMenu_AddBranch Test");
                        });

                        popupMenu.AddItem(new GUIContent("Add Merge"), false, () =>
                        {
                            currentVinove.CreateMerge("New Merge", new Rect(_canvasMousePos.x, _canvasMousePos.y, 150, 200));
                            Debug.Log("popupMenu_AddMerge Test");
                        });

                        popupMenu.AddSeparator("");

                        if (_copiedScene == null)
                        {
                            popupMenu.AddDisabledItem(new GUIContent("Paste Scene"));
                        }
                        else
                        {
                            popupMenu.AddItem(new GUIContent("Paste Scene"), false, () =>
                            {
                                currentVinove.PasteScene(_copiedScene, new Rect(_canvasMousePos.x, _canvasMousePos.y, 200, 100));
                                _copiedScene = null;
                            });
                        }

                        popupMenu.AddSeparator("");
                    }
                    else if (overScene != null)
                    {   // on graph
                        popupMenu.AddItem(new GUIContent("Open Scene"), false, () =>
                        {
                            currentScene = overScene;
                            scriptViewer = true;

                            _copiedScene = null;
                        });

                        popupMenu.AddItem(new GUIContent("Copy Scene"), false, () =>
                        {
                            _copiedScene = overScene;
                        });

                        popupMenu.AddItem(new GUIContent("Delete Scene"), false, () =>
                        {
                            GraphDeleteSequence(overScene.UID, true);
                        });

                        popupMenu.AddSeparator("");

                        popupMenu.AddItem(new GUIContent("Select Starter"), false, () =>
                        {
                            currentVinove.StarterUID = overScene.UID;
                        });

                        popupMenu.AddItem(new GUIContent("Set Background Image and Music"), false, () =>
                        {
                            OpenSceneBackgroundInspector(overScene);
                        });

                        popupMenu.AddSeparator("");

                        popupMenu.AddItem(new GUIContent("Rename"), false, () =>
                        {
                            OpenRenameInspector(overScene.UID);
                        });

                        popupMenu.AddItem(new GUIContent("Run"), false, () =>
                        {
                            AssetPathArchive _archive = new AssetPathArchive(currentVinovePath, overScene.UID);
                            string _archivePath       = "Assets/TemporaryArchive.vnvach";

                            BinaryIOManager.GetInst().BinarySerialize <AssetPathArchive>(_archive, _archivePath);

                            ToolbarFuncSave();

                            EditorApplication.isPlaying = true;
                        });
                    }
                    else if (overBranch != null)
                    {
                        popupMenu.AddItem(new GUIContent("Open Branch"), false, () =>
                        {
                            OpenBranchInspector(overBranch);
                            Debug.Log("popupMenu_OpenBranch Test : " + overBranch.UID);
                        });

                        popupMenu.AddItem(new GUIContent("Delete Branch"), false, () =>
                        {
                            GraphDeleteSequence(overBranch.UID, true);
                            Debug.Log("popupMenu_DeleteBranch");
                        });

                        popupMenu.AddSeparator("");

                        popupMenu.AddItem(new GUIContent("Change Branch Count"), false, () =>
                        {
                            OpenCountInspector(overBranch);
                        });

                        popupMenu.AddSeparator("");

                        popupMenu.AddItem(new GUIContent("Rename"), false, () =>
                        {
                            OpenRenameInspector(overBranch.UID);
                        });
                    }
                    else if (overMerge != null)
                    {
                        popupMenu.AddItem(new GUIContent("Change Merge Count"), false, () =>
                        {
                            OpenCountInspector(overMerge);
                        });

                        popupMenu.AddSeparator("");

                        popupMenu.AddItem(new GUIContent("Delete Merge"), false, () =>
                        {
                            GraphDeleteSequence(overMerge.UID, true);
                            Debug.Log("popupMenu_DeleteBranch");
                        });

                        popupMenu.AddSeparator("");

                        popupMenu.AddItem(new GUIContent("Rename"), false, () =>
                        {
                            OpenRenameInspector(overMerge.UID);
                        });
                    }

                    popupMenu.ShowAsContext();
                }

                if (e.type == EventType.MouseDrag && e.button == 0 && canvasRect.Contains(e.mousePosition) && graphTranslating == true)
                {
                    if (hoverScene != null)
                    {
                        graphTranslating = true;

                        hoverScene.MoveSceneGraph(e.delta, ZoomFactor);
                        needRepaint = true;
                    }
                    else if (hoverBranch != null)
                    {
                        graphTranslating = true;

                        hoverBranch.MoveBranchGraph(e.delta, ZoomFactor);
                        needRepaint = true;
                    }
                    else if (hoverMerge != null)
                    {
                        graphTranslating = true;

                        hoverMerge.MoveMergeGraph(e.delta, ZoomFactor);
                        needRepaint = true;
                    }

                    e.Use();
                }


                if (e.isMouse && e.type == EventType.MouseDown && e.clickCount == 2)
                {   // Double clicked
                    graphTranslating = false;

                    VinoveScene overScene = currentVinove.IsContainWholeGraph(e.mousePosition);

                    if (overScene != null)
                    {
                        currentScene            = overScene;
                        scriptViewer            = true;
                        prevLinkUID             = null;
                        linkerControllActivated = false;

                        _copiedScene = null;

                        _undoList.Clear();
                    }

                    VinoveBranch overBranch = currentVinove.IsContainWholeBranch(e.mousePosition);

                    if (overBranch != null)
                    {
                        OpenBranchInspector(overBranch);
                    }
                    e.Use();
                }

                if (e.type == EventType.MouseDown && e.button == 0)
                {
                    if (hoverScene == null && hoverBranch == null && hoverMerge == null)
                    {
                        linkerControllActivated = false;
                    }
                    else
                    {
                        graphTranslating = true;
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// <para>Eng. Script GraphViewer Event Proc Func </para>
        /// <para>Kor. Script GraphViewer의 이벤트를 담당하는 함수 </para>
        /// </summary>
        /// <param name="_vinove"> <para> Eng. Currently opened vinove file</para>
        ///                           <para> Kor. 현재 열린 비노비 파일 </para> </param>
        /// <param name="_openedScene"> <para> Eng. Currently opened scene</para>
        ///                           <para> Kor. 현재 뷰어로 열린 씬</para> </param>
        /// <param name="_canvasMousePos"> <para> Eng. Mouse pos in Canvas</para>
        ///                           <para> Kor. 캔버스 내에서의 마우스 위치</para> </param>
        static void ScriptGraphEvents(Vinove _vinove, VinoveScene _openedScene, Vector2 _canvasMousePos)
        {
            if (IsMouseOnMinimap())
            {
            }
            else
            {
                if (e.type == EventType.Repaint)
                {
                    needRepaint = false;
                }

                if (e.type == EventType.MouseUp)
                {
                    graphTranslating = false;
                    hoverScript      = null;
                }

                if (e.type == EventType.ScrollWheel)
                {   // Zoom
                    if (canvasRect.Contains(e.mousePosition))
                    {
                        float zoomCtrl  = e.control ? 0.1f : 0.2f;
                        float zoomValue = e.delta.y > 0 ? -zoomCtrl : zoomCtrl;

                        ZoomWithFocus(e.mousePosition, zoomValue);
                        e.Use();
                    }
                }

                if (((e.alt && e.button == 0 && e.type == EventType.MouseDrag && e.isMouse)) ||
                    (e.button == 2 && e.type == EventType.MouseDrag && canvasRect.Contains(e.mousePosition)))
                {   //translation canvas
                    _openedScene.Translation += e.delta;

                    e.Use();
                }

                if (e.type == EventType.MouseDown && e.button == 1 && canvasRect.Contains(e.mousePosition))
                {   // Open node popupMenu
                    GenericMenu popupMenu = new GenericMenu();

                    VinoveScript overScript = _openedScene.IsContainWholeGraph(e.mousePosition);
                    if (overScript == null)
                    {   // if, right click not on scene node
                        popupMenu.AddItem(new GUIContent("Add Script"), false, () =>
                        {
                            currentVinove.CreateScript(_openedScene, "New Script", new Rect(_canvasMousePos.x, _canvasMousePos.y, Constants.HORIZONTAL_GRAPH_SIZE_X, Constants.HORIZONTAL_GRAPH_SIZE_Y));
                            Debug.Log("popupMenu_AddScript Test");
                        });
                        popupMenu.AddSeparator("");

                        if (_copiedScript == null)
                        {
                            popupMenu.AddDisabledItem(new GUIContent("Paste Script"));
                        }
                        else
                        {
                            popupMenu.AddItem(new GUIContent("Paste Script"), false, () =>
                            {
                                currentVinove.PasteScript(currentScene, _copiedScript, new Rect(_canvasMousePos.x, _canvasMousePos.y, Constants.HORIZONTAL_GRAPH_SIZE_X, Constants.HORIZONTAL_GRAPH_SIZE_Y));
                                _copiedScript = null;
                            });
                        }
                        popupMenu.AddSeparator("");
                    }
                    else
                    {   // on graph
                        popupMenu.AddItem(new GUIContent("Open Script"), false, () =>
                        {
                            OpenScriptInspector(overScript);
                            Debug.Log("popupMenu_OpenScript Test : " + overScript.UID);
                        });

                        popupMenu.AddItem(new GUIContent("Copy Script"), false, () =>
                        {
                            _copiedScript = overScript;
                        });

                        popupMenu.AddItem(new GUIContent("Delete Script"), false, () =>
                        {
                            GraphDeleteSequence(overScript.UID, true);
                            Debug.Log("popupMenu_DeleteScript Test");
                        });

                        popupMenu.AddSeparator("");

                        popupMenu.AddItem(new GUIContent("Select Starter"), false, () =>
                        {
                            currentScene.StarterUID = overScript.UID;
                        });

                        popupMenu.AddSeparator("");

                        popupMenu.AddItem(new GUIContent("Rename"), false, () =>
                        {
                            OpenRenameInspector(overScript.ParentSceneUID, overScript.UID);
                        });

                        popupMenu.AddItem(new GUIContent("Run"), false, () =>
                        {
                            ToolbarFuncSave();

                            AssetPathArchive _archive = new AssetPathArchive(currentVinovePath, overScript.ParentSceneUID, overScript.UID);
                            string _archivePath       = "Assets/TemporaryArchive.vnvach";

                            BinaryIOManager.GetInst().BinarySerialize <AssetPathArchive>(_archive, _archivePath);

                            EditorApplication.isPlaying = true;
                        });
                    }

                    popupMenu.ShowAsContext();
                }

                if (e.type == EventType.MouseDrag && e.button == 0 && canvasRect.Contains(e.mousePosition))
                {   // Graph Translating
                    VinoveScript overScript = currentScene.IsContainWholeGraph(e.mousePosition);

                    if (hoverScript != null)
                    {
                        graphTranslating = true;

                        hoverScript.MoveScriptGraph((e.delta / currentScene.ZoomFactor));
                        needRepaint = true;
                    }

                    e.Use();
                }

                if (e.isMouse && e.type == EventType.MouseDown && e.clickCount == 2)
                {   // Double clicked
                    graphTranslating = false;

                    VinoveScript overScript = currentScene.IsContainWholeGraph(e.mousePosition);

                    if (overScript != null)
                    {
                        OpenScriptInspector(overScript);
                    }
                    e.Use();
                }

                if (e.type == EventType.MouseDown && e.button == 0)
                {
                    VinoveScript _scriptTmp = currentScene.IsContainWholeGraph(e.mousePosition);

                    if (_scriptTmp == null)
                    {
                        linkerControllActivated = false;
                    }
                    else if (graphTranslating == false)
                    {
                        hoverScript = _scriptTmp;
                    }
                }
            }
        }