You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
5.2 KiB
160 lines
5.2 KiB
// 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, zaocan: ['馒头', '肉包', '烧卖', '红薯'], needLevel: [1, 5, 10, 20], initPrice: 100, jiacheng: [1, 2, 3, 4] },
|
|
{ id: 1, zaocan: ['鸡蛋', '茶叶蛋', '玉米', '西兰花'], needLevel: [1, 5, 10, 20], initPrice: 100, jiacheng: [1, 2, 3, 4] },
|
|
{ id: 2, zaocan: ['饺子', '韭菜盒子', '鸡蛋饼', '牛排'], needLevel: [1, 5, 10, 20], initPrice: 100, jiacheng: [1, 2, 3, 4] },
|
|
{ id: 3, zaocan: ['油条', '麻球', '油饼', '鸡腿'], needLevel: [1, 5, 10, 20], initPrice: 100, jiacheng: [1, 2, 3, 4] },
|
|
{ id: 4, zaocan: ['豆浆', '小米粥', '燕麦', '咖啡机'], needLevel: [1, 5, 10, 20], initPrice: 100, jiacheng: [1, 2, 3, 4] },
|
|
]
|
|
|
|
|
|
//食谱
|
|
export default class ZaoCanManager {
|
|
|
|
public static getManagerConfigDate() {
|
|
return zaocanConfig
|
|
}
|
|
|
|
public static getDanJia() {
|
|
let price = 0
|
|
for (let i = 0; i < zaocanConfig.length; i++) {
|
|
let config = zaocanConfig[i]
|
|
let level = User.getMyLevel()
|
|
price += config.initPrice + level
|
|
}
|
|
let danjia = Math.floor(price / zaocanConfig.length)
|
|
return danjia
|
|
}
|
|
|
|
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.zaocan[0]
|
|
for (let i = 0; i < config.needLevel.length; i++) {
|
|
let _needLevel = config.needLevel[i];
|
|
if (level >= _needLevel) {
|
|
name = config.zaocan[i]
|
|
}
|
|
}
|
|
//大于最大的
|
|
if (level >= config.needLevel[config.needLevel.length - 1]) {
|
|
name = config.zaocan[config.zaocan.length - 1]
|
|
}
|
|
return name
|
|
}
|
|
|
|
/**
|
|
* 获取所有已解锁的早餐加成
|
|
*/
|
|
public static getAllZaoCanJiaCheng() {
|
|
let jiacheng = 0
|
|
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]) {
|
|
jiacheng += zaocanConfig[i].jiacheng[j]
|
|
}
|
|
}
|
|
}
|
|
// 没有加成就是1倍加成
|
|
if (jiacheng == 0) {
|
|
jiacheng = 1
|
|
}
|
|
return jiacheng
|
|
}
|
|
|
|
/**
|
|
* 获取所有需要解锁的早餐,初始的早餐不计入
|
|
*/
|
|
public static getAllZaoCan() {
|
|
let all = []
|
|
for (let i = 0; i < zaocanConfig.length; i++) {
|
|
let _zaocan = zaocanConfig[i].zaocan
|
|
// 初始的早餐不计入
|
|
for (let j = 1; j < _zaocan.length; j++) {
|
|
all.push({ name: zaocanConfig[i].zaocan[j], addPercent: zaocanConfig[i].jiacheng[j] })
|
|
}
|
|
}
|
|
return all
|
|
}
|
|
|
|
/**
|
|
* 获取早餐是否解锁
|
|
*/
|
|
public static isUnLockByName(name) {
|
|
let level = User.getMyLevel()
|
|
let lockState = false
|
|
for (let i = 0; i < zaocanConfig.length; i++) {
|
|
let _zaocan = zaocanConfig[i].zaocan
|
|
let _needLevel = zaocanConfig[i].needLevel
|
|
for (let j = 0; j < _zaocan.length; j++) {
|
|
//是当前早餐并且等级已经到了自动解锁
|
|
if (name == _zaocan[j] && level >= _needLevel[j]) {
|
|
lockState = true
|
|
break
|
|
}
|
|
}
|
|
}
|
|
return lockState
|
|
}
|
|
|
|
/**
|
|
* 获取早餐解锁等级要求
|
|
*/
|
|
public static getZaoCanNeedLevelByName(name) {
|
|
let needLevel = 0
|
|
for (let i = 0; i < zaocanConfig.length; i++) {
|
|
let _zaocan = zaocanConfig[i].zaocan
|
|
let _needLevel = zaocanConfig[i].needLevel
|
|
for (let j = 0; j < _zaocan.length; j++) {
|
|
//是当前早餐
|
|
if (name == _zaocan[j]) {
|
|
needLevel = _needLevel[j]
|
|
break
|
|
}
|
|
}
|
|
}
|
|
return needLevel
|
|
}
|
|
}
|
|
|