123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- "use strict";
- cc._RF.push(module, '6f454eoPcBB45Dc5h97xIZl', 'DataManager');
- // Script/Framework/Manager/DataManager.ts
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.DataManager = void 0;
- var Singleton_1 = require("../Utils/Singleton");
- var App_1 = require("../../Manager/App");
- var TimeControl_1 = require("../../TimeControl");
- var hallModel_1 = require("../../model/hallModel");
- /**
- * 数据管理器
- */
- var DataManager = /** @class */ (function (_super) {
- __extends(DataManager, _super);
- function DataManager() {
- var _this = _super.call(this) || this;
- // /** 免费视频总次数 */
- // public FREE_WATCH_TIMES: number = 10;
- /**已有皮肤数组 */
- _this.GetSkins = ['niao1'];
- /**当前穿戴皮肤 */
- _this.DressingSkin = 'niao1';
- /**用户金币*/
- _this.UserCoin = 0;
- _this.UserDiamond = 0;
- /**通关进度 2表示通过了第一关,当前关卡为2, 3表示通过了第2关,当前关卡为3, */
- _this.PassProgress = { "1": 1 };
- /**30关后随机关卡存储 保证只随机一次 */
- _this.InfiniteLevelDate = {};
- /**玩家已经玩到的关卡*/
- _this.PlayLevel = 1;
- /**点击关卡号进入的关卡*/
- _this.CurrentIntoLevel = 1;
- /**关卡数据*/
- _this.Configs = [];
- /**看视频得体力数*/
- _this.VideoAddTili = 10;
- /**看视频得金币数*/
- _this.VideoAddCoin = 500;
- /**总关卡数*/
- _this.LevelCount = 15;
- /**重玩标志 */
- _this.resetFlag = false;
- /**重玩关卡*/
- _this.resetLevel = 0;
- /**重玩关卡*/
- _this.resetLevelBgIndex = 0;
- _this.guideStep = 0;
- // 关卡钻石数量
- _this.diamondNum = [
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- [1, 1, 1],
- ];
- // 钥匙的位置
- _this.keyPos = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3];
- _this.foodLevel = [0, 0, 0, 0, 0, 0];
- _this.kinchenLevel = [0, 0, 0];
- _this.maxFoodLevel = 2;
- _this.maxKitchenLevel = 2;
- //升级食物需要的金币
- _this.upgradeFoodCoin = [
- [500, 1000],
- [630, 1200],
- [550, 860],
- [520, 800],
- [500, 600],
- [870, 1000],
- ];
- // 食物升级之后售价
- _this.foodSoldCoin = [
- [5, 8, 11],
- [6, 9, 12],
- [3, 5, 10],
- [4, 6, 10],
- [1, 2, 3],
- [3, 4, 5],
- ];
- // 升级厨具需要的金币
- _this.upgradeKitchenCoin = [
- [500, 1000],
- [500, 1000],
- [1000, 1500],
- ];
- // 餐具数量
- _this.kitchenNum = [
- [2, 3, 4],
- [2, 3, 4],
- [1, 2, 3],
- ];
- _this.dirnkMachinTime = [4, 3, 2];
- // 食物搭配种类
- _this.levelFoodKind = [
- 3, 3, 4, 4, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- ];
- _this.personCount = [
- [6, 9, 12],
- [7, 10, 13],
- [8, 11, 14],
- [9, 12, 15],
- [10, 13, 16],
- [11, 14, 17],
- [12, 15, 18],
- [13, 16, 19],
- [14, 17, 20],
- [15, 18, 21],
- [16, 19, 22],
- [17, 20, 23],
- [18, 21, 24],
- [19, 22, 25],
- [20, 23, 26],
- ];
- _this.RandomLevelList = [
- {
- startLevel: 11,
- endLevel: 15
- },
- {
- startLevel: 16,
- endLevel: 20
- },
- {
- startLevel: 21,
- endLevel: 25
- },
- {
- startLevel: 26,
- endLevel: 30
- }
- ];
- _this.particleColorList = {
- 'niao1': {
- startColor: new cc.Color(12, 166, 249, 255),
- endColor: new cc.Color(5, 223, 255, 255)
- },
- };
- // 道具数量
- _this.PropNum = [0, 0, 0, 0, 0];
- _this.propPrice = [1800, 1500, 1700, 1250, 2300];
- /**变小道具持续时间*/
- _this.SmallTime = 5;
- /**已加载预设组*/
- _this.PropPrefabs = [];
- /**倒计时标志*/
- _this.TimeFlag = false;
- /**获得新皮肤标志 */
- _this.GetNewSkinFlag = false;
- _this.NewSkinName = "";
- // public MissionName = ["制作%d个牛排", "卖出饮料%d杯", "招待%d个顾客", "获得%d颗星星"];
- _this.MissionName = ["Make %d steaks", "Sell drinks %d cups", "Serve %d customers", "Earn %d stars"];
- _this.MissionComplete = [0, 0, 0, 0]; // soldSteakNum,soldDrinkNum,solCustomerNum,getStarNum;
- _this.MissionReceive = [0, 0, 0, 0];
- /**皮肤设置 */
- _this.SkinDataList = [
- {
- name: 'niao1',
- path: 'skin/niao1'
- },
- ];
- /**任务设置 */
- _this.MissionDataList = [
- {
- missonNum: [5, 10, 20, 30, 40, 50, 60],
- rewardCoin: [100, 200, 300, 400, 500, 600, 700],
- rewardDiamon: [10, 20, 30, 40, 50, 60, 70],
- },
- {
- missonNum: [5, 10, 15, 20, 30, 40, 50],
- rewardCoin: [100, 200, 300, 400, 500, 600, 700],
- rewardDiamon: [10, 20, 30, 40, 50, 60, 70],
- },
- {
- missonNum: [5, 10, 20, 30, 40, 50, 60, 1000],
- rewardCoin: [100, 200, 300, 400, 500, 600, 700],
- rewardDiamon: [10, 20, 30, 40, 50, 60, 70],
- },
- {
- missonNum: [9, 18, 27, 36, 45, 54, 63, 72, 81],
- rewardCoin: [100, 200, 300, 400, 500, 600, 700],
- rewardDiamon: [10, 20, 30, 40, 50, 60, 70],
- },
- ];
- return _this;
- }
- DataManager.prototype.init = function () {
- var _this = this;
- console.log("初始化用户数据");
- this.initSkinData();
- cc.game.on(cc.game.EVENT_SHOW, function () {
- _this.OnShow();
- console.log('进入游戏&&&&&&&&&&&&&&');
- });
- cc.game.on(cc.game.EVENT_HIDE, function () {
- _this.OnHide();
- console.log('退出游戏&&&&&&&&&&&&&&');
- });
- this.iniLevelData();
- this.initUserCoin();
- this.initUserDiamond();
- };
- DataManager.prototype.iniLevelData = function () {
- var playLevel = App_1.App.LocalStorageUtil.getNumber(App_1.App.LocalStorageUtil.lst_playLevel);
- if (!playLevel)
- App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_playLevel, this.PlayLevel);
- else
- this.PlayLevel = playLevel;
- var passProgress = App_1.App.LocalStorageUtil.getJsonObj(App_1.App.LocalStorageUtil.lst_passProgress);
- if (!passProgress)
- App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.lst_passProgress, this.PassProgress);
- else
- this.PassProgress = passProgress;
- console.log('通关进度:', this.PassProgress);
- // let infiniteLevelDate = App.LocalStorageUtil.getJsonObj(App.LocalStorageUtil.lst_InfiniteLevelDate);
- // if (!infiniteLevelDate) App.LocalStorageUtil.setJsonObj(App.LocalStorageUtil.lst_InfiniteLevelDate, this.InfiniteLevelDate);
- // else this.InfiniteLevelDate = infiniteLevelDate;
- // console.log('30关后随机关卡存储:', this.InfiniteLevelDate);
- // 食物等级
- var fLevel = App_1.App.LocalStorageUtil.getJsonObj(App_1.App.LocalStorageUtil.list_foodLevel);
- if (!fLevel)
- App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.list_foodLevel, this.foodLevel);
- else
- this.foodLevel = fLevel;
- // 厨具等级
- var kChenLevel = App_1.App.LocalStorageUtil.getJsonObj(App_1.App.LocalStorageUtil.list_kitchenLevel);
- if (!kChenLevel)
- App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.list_kitchenLevel, this.kinchenLevel);
- else
- this.kinchenLevel = kChenLevel;
- // 任务完成进度
- var missionComplete = App_1.App.LocalStorageUtil.getJsonObj(App_1.App.LocalStorageUtil.list_missionComplete);
- if (!missionComplete)
- App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.list_missionComplete, this.MissionComplete);
- else
- this.MissionComplete = missionComplete;
- console.log('aaa--------missionComplete-----------', missionComplete);
- // 任务奖励领取进度
- var missionReceive = App_1.App.LocalStorageUtil.getJsonObj(App_1.App.LocalStorageUtil.list_missionReceive);
- if (!missionReceive)
- App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.list_missionReceive, this.MissionReceive);
- else
- this.MissionReceive = missionReceive;
- console.log('aaa--------missionReceive-----------', missionReceive);
- var guidei = App_1.App.LocalStorageUtil.getNumber(App_1.App.LocalStorageUtil.str_guideStep);
- if (!guidei)
- App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.str_guideStep, this.guideStep);
- else
- this.guideStep = Number(guidei);
- };
- DataManager.prototype.initUserCoin = function () {
- var coin = App_1.App.LocalStorageUtil.getNumber(App_1.App.LocalStorageUtil.lst_Coin);
- if (!coin)
- App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_Coin, this.UserCoin);
- else
- this.UserCoin = Number(coin);
- };
- DataManager.prototype.initUserDiamond = function () {
- var diamond = App_1.App.LocalStorageUtil.getNumber(App_1.App.LocalStorageUtil.lst_UserDiamond);
- if (!diamond)
- App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_UserDiamond, this.UserDiamond);
- else
- this.UserDiamond = Number(diamond);
- };
- DataManager.prototype.SaveMessage = function () {
- App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_Tili, TimeControl_1.default.instance.currentTili);
- };
- DataManager.prototype.UpdateTili = function (num, cb) {
- if (num === void 0) { num = 1; }
- if (cb === void 0) { cb = null; }
- var shengyuTili = TimeControl_1.default.instance.currentTili + num;
- if (shengyuTili < 0) {
- if (cb)
- cb(false);
- return;
- }
- if (cb)
- cb(true);
- TimeControl_1.default.instance.currentTili = shengyuTili;
- // console.log('^^^^^^^^^^^', TimeControl.instance.currentTili, shengyuTili)
- App_1.App.DataManager.SaveMessage();
- this.TimeCountJudge();
- App_1.App.Facade.getModel(hallModel_1.default).updateTiliNumber();
- };
- /**
- * 加载关卡预设
- * @param levelName 关卡预设名
- * @param cb 加载完关卡后回调
- */
- DataManager.prototype.LoadLevelPrefab = function (levelName, cb) {
- var _this = this;
- if (this.PropPrefabs.hasOwnProperty(levelName)) {
- cb && cb(this.PropPrefabs[levelName]);
- }
- else {
- cc.assetManager.loadBundle("gameScene", function (err, bundle) {
- bundle.load('prefabs/levelPrefab/' + levelName, cc.Prefab, function (err, assets) {
- _this.PropPrefabs[levelName] = assets;
- cb && cb(assets);
- });
- });
- }
- };
- DataManager.prototype.LoadAllPropPrefab = function (cb) {
- var _this = this;
- cc.assetManager.loadBundle("gameScene", function (err, bundle) {
- bundle.loadDir('prefabs/levelPrefab', cc.Prefab, function (err, assets) {
- for (var i = 0; i < assets.length; i++) {
- var sf = assets[i];
- _this.PropPrefabs[sf.name] = sf;
- if (i == assets.length - 1) {
- cb && cb();
- }
- }
- });
- });
- };
- DataManager.prototype.TimeCountJudge = function () {
- if (TimeControl_1.default.instance.currentTili < TimeControl_1.default.instance.tiliMax) {
- TimeControl_1.default.instance.CountTili();
- }
- else {
- if (App_1.App.DataManager.TimeFlag)
- TimeControl_1.default.instance.StopCount();
- }
- };
- DataManager.prototype.TimeChange = function (time) {
- // var h = Math.floor(time / 3600) < 10 ? '0' + Math.floor(time / 3600) : Math.floor(time / 3600);
- var min = Math.floor((time / 60 % 60)) < 10 ? '0' + Math.floor((time / 60 % 60)) : Math.floor((time / 60 % 60));
- var sec = Math.floor((time % 60)) < 10 ? '0' + Math.floor((time % 60)) : Math.floor((time % 60));
- //return result = h + ":" + m + ":" + s;
- var returnValue = min + ":" + sec;
- return returnValue;
- };
- DataManager.prototype.initSkinData = function () {
- var getSkins = App_1.App.LocalStorageUtil.getJsonObj(App_1.App.LocalStorageUtil.lst_getSkin);
- if (!getSkins)
- App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.lst_getSkin, this.GetSkins);
- else
- this.GetSkins = getSkins;
- var dressOnSkin = App_1.App.LocalStorageUtil.getString(App_1.App.LocalStorageUtil.lst_dressOnSkin);
- if (!dressOnSkin)
- App_1.App.LocalStorageUtil.setString(App_1.App.LocalStorageUtil.lst_dressOnSkin, this.DressingSkin);
- else
- this.DressingSkin = dressOnSkin;
- if (this.DressingSkin == "niao0") {
- this.DressingSkin = 'niao1';
- if (this.GetSkins.indexOf('niao1') == -1)
- this.GetSkins.push('niao1');
- }
- };
- DataManager.prototype.OnShow = function () {
- if (App_1.App.DataManager.TimeFlag) {
- TimeControl_1.default.instance.OfflineTime();
- }
- };
- DataManager.prototype.OnHide = function () {
- if (App_1.App.DataManager.TimeFlag) {
- var currentTime = Date.parse(new Date().toString());
- App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_CountTime, currentTime);
- App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_CountSecond, TimeControl_1.default.instance.currentTimeCount);
- }
- };
- return DataManager;
- }(Singleton_1.Singleton));
- exports.DataManager = DataManager;
- cc._RF.pop();
|