Exemple #1
0
        private void CreateNew(int campId)
        {
            if (id == campId)
            {
                return;
            }

            var res = TableMgr.singleton.CampSetTable.GetItemByID(campId);

            if (res == null)
            {
                return;
            }

            id        = campId;
            sceneName = res.sceneName;
            points    = new CampsitePointMgr[res.CampBuildingArr.Length];
            int lastAutoLv = 0;

            for (int i = 0; i < res.CampBuildingArr.Length; i++)
            {
                CampsitePointMgr p = new CampsitePointMgr();
                p.Init(id, i, res.CampBuildingArr[i], res.AutoLevelArr[i], lastAutoLv);
                p.InitByCreate();
                if (campId == 1 && i < TableMgr.singleton.ValueTable.CampLevel_1Arr.Length)
                {
                    p.SetUnlockStage(TableMgr.singleton.ValueTable.CampLevel_1Arr[i]);
                }
                else if (campId == 2 && i < TableMgr.singleton.ValueTable.CampLevel_2Arr.Length)
                {
                    p.SetUnlockStage(TableMgr.singleton.ValueTable.CampLevel_2Arr[i]);
                }
                points[i]  = p;
                lastAutoLv = res.AutoLevelArr[i];
            }
            totalRewardVal   = 0;
            lastRecordTime   = DateTimeMgr.singleton.UtcNow;
            hasOfflineReward = false;
            NotifyRefreshSaveData();
            CheckPointsFrozen();
            PlayerDataMgr.singleton.SetPlayerLevel(id);
        }
Exemple #2
0
        private bool LoadSaveData()
        {
            CampsiteData data = PlayerDataMgr.singleton.DB.campsiteData;//从DB取值

            if (data != null)
            {
                var res = TableMgr.singleton.CampSetTable.GetItemByID(data.id);
                if (res == null)
                {
                    return(false);
                }
                if (res.CampBuildingArr.Length != data.points.Length)
                {
                    return(false);
                }

                int lastAutoLv = 0;

                this.id               = data.id;
                this.sceneName        = res.sceneName;
                this.totalRewardVal   = data.totalRewardVal;
                this.lastRecordTime   = data.lastRecordTime;
                this.hasOfflineReward = data.hasOfflineReward;
                this.points           = new CampsitePointMgr[data.points.Length];
                for (int i = 0; i < points.Length; i++)
                {
                    var pData          = data.points[i];
                    CampsitePointMgr p = new CampsitePointMgr();
                    p.Init(id, i, res.CampBuildingArr[i], res.AutoLevelArr[i], lastAutoLv);
                    p.LoadSaveData(pData);
                    p.SetOfflineState(hasOfflineReward);
                    this.points[i] = p;
                    lastAutoLv     = res.AutoLevelArr[i];
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }