Ejemplo n.º 1
0
 protected override void OnAwake()
 {
     base.OnAwake();
     Instance = this;
     m_View   = UISceneCtrl.Instance.Load(UISceneType.Main).GetComponent <UIMainSceneView>();
     m_View.OnLoadComplete += OnMainUIComplete;
     //-------------测试
     SimulatedDatabase.Instance.AddCoin(100000);
     //-------------测试结束
 }
        public void SetWorldMap(int grade)
        {
            m_CurMapGrade = grade;
            UIMainSceneView view = (UIMainSceneView)UISceneCtrl.Instance.CurrentUIScene;

            if (view == null)
            {
                return;
            }
            DataTransfer           data            = new DataTransfer();
            List <DataTransfer>    datas           = new List <DataTransfer>();
            List <GameLevelEntity> levelEntityList = GameLevelDBModel.Instance.GetList();
            int maxCanPlayGameLevelId = SimulatedDatabase.Instance.GetMaxCanPlayGameLevel(grade);

            data.SetData(ConstDefine.UI_WorldMap_MaxCanPlayGameLevelId, maxCanPlayGameLevelId);
            for (int i = 0; i < levelEntityList.Count; i++)
            {
                int      id        = levelEntityList[i].Id;
                string   name      = levelEntityList[i].Name;
                string   icon      = levelEntityList[i].Ico;
                string[] posStrArr = levelEntityList[i].Pos.Split('_');
                Vector2  pos       = Vector2.zero;
                pos.x = posStrArr[0].ToFloat();
                pos.y = posStrArr[1].ToFloat();
                DataTransfer d = new DataTransfer();
                d.SetData(ConstDefine.UI_WorldMap_LevelId, id);
                d.SetData(ConstDefine.UI_WorldMap_LevelGrade, grade);
                d.SetData(ConstDefine.UI_WorldMap_LevelName, name);
                d.SetData(ConstDefine.UI_WorldMap_LevelIcon, icon);
                d.SetData(ConstDefine.UI_WorldMap_LevelPos, pos);
                if (maxCanPlayGameLevelId == -1001)//未通关上一难度
                {
                    d.SetData(ConstDefine.UI_WorldMap_CanPlay, false);
                }
                else
                {
                    if (id <= maxCanPlayGameLevelId)//关卡ID升序
                    {
                        d.SetData(ConstDefine.UI_WorldMap_CanPlay, true);
                    }
                    else
                    {
                        d.SetData(ConstDefine.UI_WorldMap_CanPlay, false);
                    }
                }

                datas.Add(d);
            }
            data.SetData(ConstDefine.UI_WorldMap_Content, datas);
            view.SetWorldMap(data);
        }