Beispiel #1
0
 //重置
 public void Reset()
 {
     //mCommands.Clear();
     {
         // foreach(var pair in mDictActor)
         var __enumerator1 = (mDictActor).GetEnumerator();
         while (__enumerator1.MoveNext())
         {
             var pair = __enumerator1.Current;
             {
                 pair.Value.Destroy();
             }
         }
     }
     mDictActor.Clear();
     mDictGo.Clear();
     if (null != mLogic)
     {
         //mLogic.StopAllCoroutines();
         if (mWillDestroySelf)
         {
             Object.Destroy(mLogic.gameObject);
         }
     }
     mLogic = null;
 }
Beispiel #2
0
    //销毁当前的CG
    public void Destroy()
    {
        mDictActor.Clear();
        mDictGo.Clear();
        mLogic = null;
        var root = GameObject.Find("CGRoot");

        if (null != root)
        {
            Object.Destroy(root);
        }
    }
Beispiel #3
0
 //销毁当前的CG
 public void Destroy()
 {
     try
     {
         mDictActor.Clear();
         mDictGo.Clear();
         mLogic = null;
         var root = GameObject.Find("CGRoot");
         if (null != root)
         {
             Object.Destroy(root);
         }
     }
     catch (Exception e)
     {
         Logger.Error(e.Message);
     }
 }
Beispiel #4
0
    //播放CG
    public void PlayCGFile(string path, Action callback = null, bool skipable = true, bool willDestroy = true)
    {
        Reset();
        mWillDestroySelf = willDestroy;
        //读取资源
        var asset = ResourceManager.PrepareResourceSync <TextAsset>(path);

        if (null == asset)
        {
            Logger.Error("PlayCGFile null == res|path[{0}]", path);
            return;
        }

        //转换成字符串
        var source = Encoding.Default.GetString(asset.bytes);

        if (string.IsNullOrEmpty(source))
        {
            Logger.Error("string.IsNullOrEmpty(source)");
            return;
        }

        mState = State.Playing;

        mPlayCallback = callback;

        //清除指令
        mCommands.Clear();

        //初步处理指令字符串
        var temp = source.Split('\n');

        for (var i = 0; i < temp.Length; i++)
        {
            if (string.IsNullOrEmpty(temp[i]))
            {
                continue;
            }
            if (temp[i].Equals("\r"))
            {
                continue;
            }
            if (temp[i].Contains("//"))
            {
                continue;
            }
            mCommands.Add(temp[i]);
        }

        //加载prefab
        var res = ResourceManager.PrepareResourceSync <GameObject>("UI/CG/CGRoot"); //, (res) =>

        {
            //对当前游戏进行屏蔽
            Camera camera = null;
            if (null != GameLogic.Instance)
            {
                InputManager.Instance.enabled        = false;
                GameLogic.Instance.MainCamera.active = false;
                //UIManager.Instance.UIRoot.active = false;
                //SoundManager.Instance.active = false;

                camera = GameLogic.Instance.MainCamera;

                EventDispatcher.Instance.DispatchEvent(new PlayCgEvent(0));
            }
            else
            {
                var cameraGo = GameObject.Find("Main Camera");
                if (null != cameraGo)
                {
                    camera = cameraGo.GetComponent <Camera>();
                }
            }


            var go = Object.Instantiate(res) as GameObject;
            go.name = "CGRoot";
            mLogic  = go.GetComponent <CGLogic>();

            mLogic.SkipBtn.gameObject.SetActive(skipable);

            //先把 CG摄像机和游戏摄像机重合
            if (null != camera)
            {
                mLogic.CGCamera.transform.position = camera.transform.position;
                mLogic.CGCamera.transform.rotation = camera.transform.rotation;
                mLogic.CGCamera.fieldOfView        = camera.fieldOfView;
                mLogic.CGCamera.farClipPlane       = camera.farClipPlane;
                mLogic.CGCamera.nearClipPlane      = camera.nearClipPlane;
            }


            //开始执行指令
            ProcessCommand();
        }
        //);

        curPlayPath = path;
    }