コード例 #1
0
ファイル: TextBubble.cs プロジェクト: frozen4/UnityPlus
        void Update()
        {
            CGGlobal cgg = GetComponentInParent <CGGlobal>();

            if (!target || !cgg.Current)
            {
                return;
            }
            transform.position = target.position + DeltaHeight;
            transform.rotation = cgg.Current.transform.rotation;
        }
コード例 #2
0
ファイル: CGManager.cs プロジェクト: frozen4/UnityPlus
    /// CG播放完回调
    public void OnCutsceneFinished(object sender, CutsceneEventArgs e)
    {
        Cutscene cs = sender as Cutscene;

        if (cs != _CurCutscene || _CurCutscene == null)
        {
            Common.HobaDebuger.LogWarningFormat("Logic Error: when call OnCutsceneStarted, another cg is playing");
            return;
        }

        var useCGCamera = _CurCGGlobal.cameraType == CGGlobal.CameraType.CGCamera;

        if (useCGCamera)
        {
            ChangeOtherSetting(true, _CurCGGlobal.UseUICamera);
            DynamicEffectManager.Instance.EnterCGEffect(-1, null);
        }

        {
            IntPtr L = LuaScriptMgr.Instance.GetL();
            try
            {
                var ls     = LuaScriptMgr.Instance.GetLuaState();
                var oldTop = LuaDLL.lua_gettop(L);
                LuaDLL.lua_getglobal(L, "OnCGFinish");
                LuaDLL.lua_pushboolean(L, useCGCamera);
                if (!ls.PCall(1, 0))
                {
                    Common.HobaDebuger.LogLuaError(LuaDLL.lua_tostring(L, -1));
                }
                LuaDLL.lua_settop(L, oldTop);
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                Debug.LogError(LuaStatic.GetTraceBackInfo(L));
            }
        }

        _CurCutscene.CutsceneFinished -= OnCutsceneFinished;
        _CurCutscene = null;

        if (_CgXmlConfig.IsVideo)
        {
            EntryPoint.Instance.VideoManager.StopVideo();
        }

        Destroy(_CurCGGlobal.gameObject);
        _CurCGGlobal = null;

        _CgXmlConfig.Reset();
    }
コード例 #3
0
ファイル: CGManager.cs プロジェクト: frozen4/UnityPlus
    private void PlayCommonCG()
    {
        Action <UnityEngine.Object> callback = (asset) =>
        {
            // 异步加载中 可能存在其他操作(比如cg结束 切换成功)
            if (asset == null || _CgXmlConfig.Path == null || !_CgXmlConfig.Path.Contains(asset.name))
            {
                return;
            }

            var cg = CUnityUtil.Instantiate(asset) as GameObject;
            if (cg == null)
            {
                return;
            }

            var cgg = cg.GetComponent <CGGlobal>();
            if (cgg == null)
            {
                Destroy(cg);
                return;
            }

            _CurCGGlobal = cgg;
            _CurCutscene = cg.GetComponentInChildren <Cutscene>();
            _CurCutscene.CutsceneStarted  += OnCutsceneStarted;
            _CurCutscene.CutsceneFinished += OnCutsceneFinished;

            if (_CgXmlConfig.StartCallback != null)
            {
                _CgXmlConfig.StartCallback();
                _CgXmlConfig.StartCallback = null;
            }

            if (_CgXmlConfig.IsMaskShown)
            {
                _CGMask.Hide();
            }

            if (_CurCutscene != null)
            {
                _CurCutscene.Optimize();
                _CurCutscene.Play();
            }
        };

        CAssetBundleManager.AsyncLoadResource(_CgXmlConfig.Path, callback, false);
    }
コード例 #4
0
ファイル: CGManager.cs プロジェクト: frozen4/UnityPlus
    private void PlayVideoImp()
    {
        if (_CommonVideoFrame == null)
        {
            return;
        }

        var cgg = _CommonVideoFrame.GetComponent <CGGlobal>();

        if (cgg == null)
        {
            return;
        }

        _CurCGGlobal = cgg;
        _CurCutscene = _CommonVideoFrame.GetComponentInChildren <Cutscene>();

        foreach (var v in _DialogueTimerList)
        {
            EntryPoint.Instance.RemoveTimer(v);
        }
        _DialogueTimerList.Clear();

        _DialogueRoot.SetActive(false);

        _CurCutscene.CutsceneStarted  += OnCutsceneStarted;
        _CurCutscene.CutsceneFinished += OnCutsceneFinished;

        if (!string.IsNullOrEmpty(_CgXmlConfig.Path))
        {
            Action onStartFunc = () =>
            {
                if (_CgXmlConfig.StartCallback != null)
                {
                    _CgXmlConfig.StartCallback();
                    _CgXmlConfig.StartCallback = null;
                }

                if (_CurCutscene != null)
                {
                    _CurCutscene.Optimize();
                    _CurCutscene.Play();
                }

                if (_CgXmlConfig.IsMaskShown)
                {
                    _CGMask.Hide();
                }

                foreach (var v in _CgXmlConfig.Dialogues)
                {
                    if (v.Value != null && v.Value.ShowTime >= 0)
                    {
                        var timerId = EntryPoint.Instance.AddTimer(v.Value.ShowTime, true,
                                                                   delegate
                        {
                            if (!_DialogueRoot.activeSelf)
                            {
                                _DialogueRoot.SetActive(true);
                            }
                            _DialogueNameText.text    = v.Value.Name;
                            _DialogueContentText.text = v.Value.Content;
                        }, false);

                        _DialogueTimerList.Add(timerId);
                    }

                    if (v.Value != null && Util.IsZero(v.Value.HideTime))
                    {
                        var timerId = EntryPoint.Instance.AddTimer(v.Value.HideTime, true,
                                                                   delegate
                        {
                            if (_DialogueRoot.activeSelf)
                            {
                                _DialogueRoot.SetActive(false);
                            }
                        }, false);

                        _DialogueTimerList.Add(timerId);
                    }
                }
            };
            Action onEndFunc = () =>
            {
                foreach (var v in _DialogueTimerList)
                {
                    EntryPoint.Instance.RemoveTimer(v);
                }
                _DialogueTimerList.Clear();

                if (_CurCutscene != null)
                {
                    _CurCutscene.Skip();
                }
            };

            var videoPath = EntryPoint.Instance.GetFullResPath("Video", _CgXmlConfig.Path);

            if (System.IO.File.Exists(videoPath))
            {
                EntryPoint.Instance.VideoManager.PlayVideo(videoPath, _VideoRawImage, onStartFunc, onEndFunc);
            }
            else
            {
                Common.HobaDebuger.LogWarningFormat("CgPath does not exist! {0}", videoPath);
                onStartFunc.Invoke();
                onEndFunc.Invoke();
            }
        }
    }