import Config from "./Config"; export default class GameModel { public win: boolean = false; private _drawLevel: number = 1 private _tipCount:number=20; public selectedModel: number = 1 //精确 掉落 拖曳 public selectedLevel: number = 18 public getStar: number = 0 public drawComplete: boolean = false; public dragComplete: boolean = false; public dropComplete: boolean = false; public preciseComplete: boolean = false; public completeInfo = [] public drawLevelInfo: Array = []; public isNull(str) { if (str != null && str != undefined && str != '' && str != NaN) { return false } return true } readDraw() { //画线关卡数据 var drawLevelStr = cc.sys.localStorage.getItem('drawLevelInfo') if (!this.isNull(drawLevelStr)) { this.drawLevelInfo = []; var list = drawLevelStr.split(',') for (var i = 0; i < list.length; i++) { this.drawLevelInfo.push(parseInt(list[i])); } } else { this.drawLevelInfo = [-1]; } for (var m = 0; m < this.drawLevelInfo.length; m++) { if (this.drawLevelInfo[m] == -1) { this._drawLevel = m + 1 break; } } //是否完成 var lInfo = cc.sys.localStorage.getItem('completeInfo') if (!this.isNull(lInfo)) { var list = lInfo.split(',') for (var i = 0; i < list.length; i++) { this.completeInfo.push(parseInt(list[i])); } } else { this.completeInfo = [0, 0, 0, 0] } //提示数量 var tipStr = cc.sys.localStorage.getItem('tipCount') if (!this.isNull(tipStr)) { this._tipCount=parseInt(tipStr) } else { this._tipCount=20 } } saveDraw() { var s = this.drawLevelInfo.join(',') cc.sys.localStorage.setItem('drawLevelInfo', s) } set drawLevel(value: number) { if (value > Config.drawLevels.length - 1) { console.log('通关'); // value = 1; this.completeInfo[3] = 1 cc.sys.localStorage.setItem('completeInfo', this.completeInfo.join(',')) } this._drawLevel = value; // cc.sys.localStorage.setItem('drawLevel', value + '') } get drawLevel() { return this._drawLevel } get tipCount() { return this._tipCount } set tipCount(value: number) { this._tipCount=value cc.sys.localStorage.setItem('tipCount', value + '') } }