// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html import { ryw_Event } from "../../FrameWork/Event/EventEnum" import EventMgr from "../../FrameWork/Event/EventMgr" import User from "../../FrameWork/User/User" import BagManager from "./BagManager" let zaocanConfig = [ { id: 0, zancan: ['馒头', '肉包', '烧卖', '红薯'], needLevel: [1, 5, 10, 20], initPrice: 100, jiacheng: [1, 2, 3, 4] }, { id: 1, zancan: ['鸡蛋', '茶叶蛋', '玉米', '西兰花'], needLevel: [1, 5, 10, 20], initPrice: 100, jiacheng: [1, 2, 3, 4] }, { id: 2, zancan: ['饺子', '韭菜盒子', '鸡蛋饼', '牛排'], needLevel: [1, 5, 10, 20], initPrice: 100, jiacheng: [1, 2, 3, 4] }, { id: 3, zancan: ['油条', '麻球', '油饼', '鸡腿'], needLevel: [1, 5, 10, 20], initPrice: 100, jiacheng: [1, 2, 3, 4] }, { id: 4, zancan: ['豆浆', '小米粥', '燕麦', '咖啡机'], needLevel: [1, 5, 10, 20], initPrice: 100, jiacheng: [1, 2, 3, 4] }, ] //食谱 export default class ZaoCanManager { public static getManagerConfigDate() { return zaocanConfig } public static getCurPriceById(id) { let config = zaocanConfig[id] let level = User.getMyLevel() let price = config.initPrice + level return price } public static getNextPriceById(id) { let config = zaocanConfig[id] let level = User.getMyLevel() + 1 let price = config.initPrice + level return price } public static isCanLevelUpById(id) { let config = zaocanConfig[id] let level = User.getMyLevel() + 1 let isCan = false for (let i = 0; i < config.needLevel.length; i++) { let _needLevel = config.needLevel[i]; if (level == _needLevel) { isCan = true } } return isCan } public static getCurNameById(id) { let config = zaocanConfig[id] let level = User.getMyLevel() let name = config.zancan[0] for (let i = 0; i < config.needLevel.length; i++) { let _needLevel = config.needLevel[i]; if (level <= _needLevel) { name = config.zancan[i] } } //大于最大的 if (level >= config.needLevel[config.needLevel.length - 1]) { name = config.zancan[config.zancan.length - 1] } return name } /** * 获取等级到了解锁的物品 */ public static getAllZaoCan() { let all = [] let level = User.getMyLevel() for (let i = 0; i < zaocanConfig.length; i++) { let _needLevel = zaocanConfig[i].needLevel for (let j = 0; j < _needLevel.length; j++) { if (level >= _needLevel[j]) { all.push({ name: zaocanConfig[i].zancan[j], addPercent: zaocanConfig[i].jiacheng[j] }) } } } return all } }