Esempio n. 1
0
        /// <summary>
        /// 场景初始化
        /// </summary>
        private void SceneInit()
        {
            NameBoardRoot = GameObject.Find("CharacterRoot");
            if (NameBoardRoot == null)
            {
                NameBoardRoot = ResourceManager.InstantiateResource("Prefab/HeadInfo/NameBoardRoot") as GameObject;
            }

            FakeObjRoot = GameObject.Find("FakeObjRoot");
            if (FakeObjRoot == null)
            {
                FakeObjRoot = ResourceManager.InstantiateResource("Prefab/HeadInfo/FakeObjRoot") as GameObject;
                FakeObjRoot.SetActive(false);
            }

            DropItemBoardRoot = GameObject.Find("DropItemBoardRoot");
            if (DropItemBoardRoot == null)
            {
                DropItemBoardRoot = ResourceManager.InstantiateResource("Prefab/HeadInfo/DropItemBoardRoot") as GameObject;
            }


            //初始化特效
            m_MovingCircle = GameObject.Find("cb_dituzhizhen_02");
            if (null == m_MovingCircle)
            {
                m_MovingCircle = ResourceManager.InstantiateResource("Prefab/Effect/cb_dituzhizhen_02") as GameObject;
                if (null != m_MovingCircle)
                {
                    m_MovingCircle.transform.position = Vector3.zero;
                    m_MovingCircle.transform.rotation = Quaternion.Euler(Vector3.zero);
                    m_MovingCircle.SetActive(false);
                }
            }

            m_SelectCircle = GameObject.Find("SelectCircle");
            if (null == m_SelectCircle)
            {
                m_SelectCircle = ResourceManager.InstantiateResource("Prefab/Effect/SelectCircle") as GameObject;
                if (null != m_SelectCircle)
                {
                    m_SelectCircle.transform.position = Vector3.zero;
                    m_SelectCircle.transform.rotation = Quaternion.Euler(Vector3.zero);
                    m_SelectCircle.SetActive(false);
                }
            }

            // 方向指引
            GameObject guideDirSignObj = GameObject.Find("cb_dituzhizhen_01");

            if (null == guideDirSignObj)
            {
                guideDirSignObj = ResourceManager.InstantiateResource("Prefab/Effect/cb_dituzhizhen_01") as GameObject;
                m_GuideDirSign  = guideDirSignObj.AddComponent <GuideDirectionSign>();
                if (null != m_GuideDirSign)
                {
                    m_GuideDirSign.m_circleTrans          = guideDirSignObj.transform;
                    m_GuideDirSign.m_circleTrans.position = Vector3.zero;
                    m_GuideDirSign.m_circleTrans.rotation = Quaternion.Euler(Vector3.zero);
                    guideDirSignObj.SetActive(false);
                }
            }
            else
            {
                m_GuideDirSign = guideDirSignObj.GetComponent <GuideDirectionSign>();
            }

            if (m_GuideDirSign != null)
            {
                m_GuideDirSign.Init();
                m_GuideDirSign.SetGuideEffectScale(m_curMainPlayerCircleScale);
            }
            m_Teleport = GameObject.Find("Teleport");
            if (m_Teleport != null)
            {
                if (IsCopyScene())
                {
                    m_Teleport.SetActive(false);
                }
            }
            m_TeleportCopyScene = GameObject.Find("TeleportCopyScene");
            if (m_TeleportCopyScene)
            {
                if (IsCopyScene())
                {
                    m_TeleportCopyScene.SetActive(false);
                }
            }
            if (null == m_DamageBoardRoot)
            {
                m_DamageBoardRoot = new GameObject("DamageBoard Root");
                if (null != m_DamageBoardRoot)
                {
                    UIPanel panel = m_DamageBoardRoot.AddComponent <UIPanel>();
                    if (null != panel)
                    {
                        panel.depth = 20;
                    }
                    m_DamageBoardRoot.transform.localScale = new Vector3(0.015f, 0.015f, 0.015f);

                    m_DamageBoardManager = m_DamageBoardRoot.AddComponent <DamageBoardManager>();
                }
            }

            m_QingGongPointList = GameObject.FindGameObjectsWithTag("QingGongPoint");
            for (int i = 0; i < m_QingGongPointList.Length; ++i)
            {
                if (IsCopyScene() && m_QingGongPointList[i] != null)
                {
                    m_QingGongPointList[i].SetActive(false);
                }
            }

            //声音资源
            m_SceneAudioSources = GameObject.FindGameObjectsWithTag("SceneSoundEffect");
            for (int i = 0; i < m_SceneAudioSources.Length; ++i)
            {
                if (m_SceneAudioSources[i] != null && PlayerPreferenceData.SystemSoundEffect == 0)
                {
                    m_SceneAudioSources[i].SetActive(false);
                }
            }

            //初始化Terrain数据
            if (GameManager.gameManager != null)
            {
                GameManager.gameManager.m_loadErrorNum = 0;
            }

            //初始化名字版池子
            if (null == m_NameBoardPool)
            {
                m_NameBoardPool = new GameObjectPool("HeadInfo", 128);
            }

            if (null != m_NameBoardPool)
            {
                m_NameBoardPool.ClearAllPool();
            }

            if (m_MainCamera == null)
            {
                m_MainCamera = GameObject.Find("Main Camera");
            }
        }