void Awake()
 {
     _instance     = this;
     gameLogic     = FindObjectOfType <RegularityAlphaGameLogic>();
     audioPos      = Camera.main.transform.position;
     ui            = FindObjectOfType <UIRegGuide>();
     m_ElementList = new List <PilesAlphaElement>();
     m_PlayerAnim  = gameLogic.m_ObjPlayer.GetComponent <Animator>();
     m_Grid        = gameLogic.m_ObjElementRoot.GetComponent <SimpleUIGrid>();
 }
Exemple #2
0
        public void Initialize()
        {
            m_ElementList       = new List <PilesAlphaElement>();
            m_GameSettingConfig = ConfigManager.Instance.GetRegularityGameSetting();
            m_DiffMgr           = new RegularityGameDifficultyManager();
            m_PlayerAnim        = m_ObjPlayer.GetComponent <Animator>();
            m_Grid = m_ObjElementRoot.GetComponent <SimpleUIGrid>();

            ReloadScene();

            m_iLeftRedFlower = 3;
            m_iLeftWinCount  = m_GameSettingConfig.PlayCountLimit;
            m_UIWindow.SetLeftCount(m_GameSettingConfig.PlayCountLimit);
            m_UIWindow.SetLeftTime(m_GameSettingConfig.PlayTime);
            m_UIWindow.SetLeftFlower(m_iLeftRedFlower);
        }
        private void ReLoadScene()
        {
            if (!m_bIsResetByUI)
            {
                m_CurrentConfig = m_DiffMgr.GetDifficulty();
            }
            m_bIsResetByUI = false;

            m_ElementList = new List <PilesElement>();
            for (int i = 0; i < m_CurrentConfig.OptionList.Count; ++i)
            {
                string     name = m_CurrentConfig.OptionList[i].Name;
                GameObject elem = GameObject.Instantiate(m_ElementTemplate);
                elem.name = i.ToString();
                MeshRenderer renderer     = ComponentTool.FindChildComponent <MeshRenderer>("Option", elem);
                Material     elemMaterial =
                    new Material(ResourceManager.Instance.LoadBuildInResource <Material>("Piles/PilesMaterial",
                                                                                         AssetType.Materials));
                if (m_CurrentConfig.OptionList[i].IsVisable)
                {
                    elemMaterial.mainTexture = ResourceManager.Instance.LoadBuildInResource <Texture2D>(name,
                                                                                                        AssetType.Texture);
                }
                else
                {
                    elemMaterial.mainTexture = ResourceManager.Instance.LoadBuildInResource <Texture2D>(m_strEmptyTextureName,
                                                                                                        AssetType.Texture);
                }
                renderer.material = elemMaterial;
                elem.SetActive(true);
                m_ElementList.Add(new PilesElement(renderer.gameObject, elem, name, elemMaterial, m_CurrentConfig.OptionList[i].IsVisable));
                ComponentTool.Attach(m_ObjRoot.transform, elem.transform);
            }
            m_Grid = m_ObjRoot.GetComponent <RegularityGame.SimpleUIGrid>();
            m_Grid.Reposition();
            FixPosition();

            m_bIsInit = true;
        }