var touch;!function(t){var s;!function(t){t[t.DIAMOND=0]="DIAMOND",t[t.SKIN=1]="SKIN"}(s=t.REWARD_TYPE||(t.REWARD_TYPE={}));var e;!function(t){t[t.NONE=0]="NONE",t[t.TOTAL_DISTANCE=1]="TOTAL_DISTANCE",t[t.TOTAL_SURPASS=2]="TOTAL_SURPASS",t[t.BEST_DISTANCE=3]="BEST_DISTANCE",t[t.BEST_SURPASS=4]="BEST_SURPASS"}(e=t.TASK_VALUE_TYPE||(t.TASK_VALUE_TYPE={}));var a;!function(t){t[t.NEW=0]="NEW",t[t.FINISHED=1]="FINISHED"}(a=t.TASK_STATE||(t.TASK_STATE={}));var r=function(){function r(){this._inited=!1,this._skinTasks=[],this._isDirty=!1}return Object.defineProperty(r,"instance",{get:function(){return this._inst||(this._inst=new r),this._inst},enumerable:!1,configurable:!0}),r.prototype.init=function(){this._inited||(this._inited=!0,this._initSkinTasks(),this.load())},r.prototype._initSkinTasks=function(){this._skinTasks=t.GameData.instance.config.tasks.skins},r.prototype.getSkinUnlockTasks=function(){return this._skinTasks},r.prototype.getSkinUnlockCondition=function(t){for(var e,a=0;a0&&t._setTaskState(s.id,s.state)})},r.prototype._initProgress=function(){this._progress=[],this._progress.push({type:e.TOTAL_SURPASS,value:0}),this._progress.push({type:e.TOTAL_DISTANCE,value:0}),this._progress.push({type:e.BEST_SURPASS,value:0}),this._progress.push({type:e.BEST_DISTANCE,value:0})},r.prototype._migrateOldProgress=function(){var s=t.GameData.instance.videoNums[t.GameData.getProgressIdByType(e.TOTAL_SURPASS)],a=t.GameData.instance.videoNums[t.GameData.getProgressIdByType(e.TOTAL_DISTANCE)];this.setTaskProgress(e.TOTAL_SURPASS,s),this.setTaskProgress(e.TOTAL_DISTANCE,a),this.setTaskProgress(e.BEST_SURPASS,t.GameData.instance.getOldSurpassRecord()),this.setTaskProgress(e.BEST_DISTANCE,t.GameData.instance.getOldDistanceRecord()),console.info("Surpass: "+s),console.info("Distance: ",a)},r.prototype.save=function(){var t={progress:this._progress,states:this._states},s=JSON.stringify(t);Laya.LocalStorage.setItem(r.DATA,s),this._isDirty=!1},r.prototype.setTaskProgress=function(t,s){var e=this.getTaskProgress(t);e?e.value=s:this._progress.push({type:t,value:s})},r.prototype.getTaskProgress=function(t){for(var s=null,e=0;ethis.getBestDistance()&&(this.setTaskProgress(e.BEST_DISTANCE,t),this._isDirty=!0,!0)},r.prototype.getBestSurpass=function(){return this.getTaskProgressValue(e.BEST_SURPASS,0)},r.prototype.setBestSurpass=function(t){return t>this.getBestSurpass()&&(this.setTaskProgress(e.BEST_SURPASS,t),this._isDirty=!0,!0)},r.prototype.addTaskProgress=function(t,s){var e=this.getTaskProgress(t);e?this.setTaskProgress(t,e.value+s):this.setTaskProgress(t,s),this.updateTaskStates()},r.prototype.addDistance=function(t){this.addTaskProgress(e.TOTAL_DISTANCE,t)},r.prototype.addSurpass=function(t){this.addTaskProgress(e.TOTAL_SURPASS,t)},r.prototype._getTaskState=function(t){for(var s=null,e=0;e=a.FINISHED},r.prototype.updateTaskStates=function(){for(var a=0;a=r.value&&this._finishTask(r)}}this._saveOnDirty()},r.prototype._finishTask=function(s){this._setTaskState(s.id,a.FINISHED),t.GameModule.instance.event(t.GameEvent.TASK_FINISHED,s)},r.prototype._saveOnDirty=function(){this._isDirty&&this.save()},r.DATA="Task",r}();t.TaskManager=r}(touch||(touch={}));