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);
            }
        }
Exemple #3
0
        private TaskInfo CreateTaskInfo(Task_TableItem task, int param)
        {
            var taskTypeRes = TableMgr.singleton.CampTaskTypeTable.GetItemByID(task.type);

            if (taskTypeRes == null)
            {
                return(null);
            }

            var info = new TaskInfo();

            info.taskID   = task.id;
            info.taskType = task.type;

            if (param > 0)
            {
                info.taskParam = param - 1;
            }

            switch ((TaskType)task.type)
            {
            //case TaskType.Finish_Battle:
            //    {
            //        info.conditionValue = GetFinishTaskCount(task.type) + task.value + campSetRes.taskDifficulty;
            //    }
            //    break;
            case TaskType.Occupy_Building:
            {
                if (info.taskParam >= 0)
                {
                    var pointData = CampsiteMgr.singleton.GetPointByIndex(info.taskParam);
                    if (pointData == null)
                    {
                        return(null);
                    }

                    info.conditionValue = 1;
                    return(info);
                }
                else
                {
                    CampsitePointMgr pointData = null;
                    for (int i = 0; i < campSetRes.CampBuildingArr.Length; ++i)
                    {
                        pointData = CampsiteMgr.singleton.GetPointByIndex(i);
                        if (pointData == null)
                        {
                            continue;
                        }

                        if (!pointData.isUnlock)
                        {
                            info.taskParam      = i;
                            info.conditionValue = 1;
                            return(info);
                        }
                    }
                }

                return(null);
            }

            case TaskType.Equip_Gun:
            {
                if (info.taskParam < 0)
                {
                    List <int> buildingList = new List <int>();
                    for (int i = 0; i < campSetRes.CampBuildingArr.Length; ++i)
                    {
                        var pointData = CampsiteMgr.singleton.GetPointByIndex(i);
                        if (pointData == null)
                        {
                            continue;
                        }

                        if (pointData.isUnlock)
                        {
                            buildingList.Add(campSetRes.CampBuildingArr[i]);
                        }
                    }

                    if (buildingList.Count > 0)
                    {
                        info.taskParam = BaseRandom.Next(0, buildingList.Count);
                    }
                    else
                    {
                        return(null);
                    }
                }

                info.conditionValue = GetFinishTaskCount(task.type) * task.value *
                                      campSetRes.taskDifficulty +
                                      campSetRes.AutoLevelArr[info.taskParam];
            }
            break;

            case TaskType.LvUp_Building:
            {
                if (info.taskParam < 0)
                {
                    //var index = GetFinishTaskCount(task.type) + GetContainTaskCount(task.type);
                    //Debug.Log("index " + index);
                    //var pointData = CampsiteMgr.singleton.GetPointByIndex(index);
                    //if (pointData == null)
                    //    return null;

                    //if (!pointData.isUnlock)
                    //{
                    //    return null;
                    //}
                    int index = -1;
                    for (int i = 0; i < campSetRes.CampBuildingArr.Length; ++i)
                    {
                        var pointData = CampsiteMgr.singleton.GetPointByIndex(i);
                        if (pointData == null)
                        {
                            continue;
                        }

                        if (pointData.isUnlock)
                        {
                            index = i;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (index <= GetFinishTaskParam(task.type))
                    {
                        return(null);
                    }

                    info.taskParam = index;
                }

                info.conditionValue = (int)(task.value * campSetRes.taskDifficulty *
                                            campSetRes.id * 0.3f) + 5;
            }
            break;

            case TaskType.Buildings_Level:
            {
                info.conditionValue = task.value * campSetRes.taskDifficulty *
                                      campSetRes.id / 2;
            }
            break;

            case TaskType.LevelUp_Gun:
            {
                if (info.taskParam < 0)
                {
                    var typeList = PlayerDataMgr.singleton.GetGunCardTypeList();
                    if (typeList.Count <= 0)
                    {
                        return(null);
                    }

                    info.taskParam = typeList[BaseRandom.Next(0, typeList.Count)];
                }
                info.conditionValue = GetFinishTaskCount(task.type) * 2 + task.value + campSetRes.taskDifficulty;
            }
            break;

            case TaskType.Supplies_Add:
            {
                //if (CampsiteMgr.singleton.TotalRewardRate <= 0.0f)
                //{
                //    return null;
                //}

                info.conditionValue = (BigInteger)(CampsiteMgr.singleton.TotalRewardRate *
                                                   task.value * campSetRes.taskDifficulty);
            }
            break;

            case TaskType.Cost_Gold:
            case TaskType.Get_Gold:
            {
                info.conditionValue = (BigInteger)(IdleRewardMgr.singleton.GetGoldPerMinute() *
                                                   (GetFinishTaskCount(task.type) + 1) * task.value * 0.5f *
                                                   campSetRes.taskDifficulty);
            }
            break;

            case TaskType.Quick_Reward:
            case TaskType.Open_Box:
            case TaskType.Fuse_Gun:
            case TaskType.Explore_Gold:
            case TaskType.Lv10_Gun:
            case TaskType.Finish_Battle:
            {
                info.conditionValue = task.value;
            }
            break;

            case TaskType.Epic_Gun:
            {
                info.conditionValue = 1;
            }
            break;

            case TaskType.Auto_Level:
            {
                if (info.taskParam < 0)
                {
                    int index = 0;
                    for (int i = 0; i < campSetRes.CampBuildingArr.Length; ++i)
                    {
                        var pointData = CampsiteMgr.singleton.GetPointByIndex(i);
                        if (pointData == null)
                        {
                            continue;
                        }

                        if (pointData.isUnlock)
                        {
                            index = i;
                        }
                        else
                        {
                            break;
                        }
                    }

                    info.taskParam = index;
                }

                var data = CampsiteMgr.singleton.GetPointByIndex(info.taskParam);
                if (data == null)
                {
                    return(null);
                }
                info.conditionValue = 1;
            }
            break;
            }

            return(info);
        }