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.
151 lines
5.2 KiB
151 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"
|
|
|
|
|
|
let FangChangConfig = [
|
|
{ roomId: 0, name: '茅草房', iconUrl: 'FangChan/', buyPrice: 400000, inComeNum: 400 },
|
|
{ roomId: 1, name: '安置房', iconUrl: 'FangChan/', buyPrice: 2000000, inComeNum: 2000 },
|
|
{ roomId: 2, name: '城中村', iconUrl: 'FangChan/', buyPrice: 20000000, inComeNum: 20000 },
|
|
{ roomId: 3, name: '公寓', iconUrl: 'FangChan/', buyPrice: 700000000, inComeNum: 700000 },
|
|
{ roomId: 4, name: '自建房', iconUrl: 'FangChan/', buyPrice: 5000000000, inComeNum: 5000000 },
|
|
{ roomId: 5, name: '小复式', iconUrl: 'FangChan/', buyPrice: 30000000000, inComeNum: 30000000 },
|
|
{ roomId: 6, name: '市区住房', iconUrl: 'FangChan/', buyPrice: 20000000000000, inComeNum: 20000000000 },
|
|
{ roomId: 7, name: '三室一厅', iconUrl: 'FangChan/', buyPrice: 40000000000000, inComeNum: 40000000000 },
|
|
{ roomId: 8, name: '四室两厅', iconUrl: 'FangChan/', buyPrice: 200000000000000, inComeNum: 200000000000 },
|
|
{ roomId: 9, name: '高档大平层', iconUrl: 'FangChan/', buyPrice: 100000000000000000, inComeNum: 100000000000000 },
|
|
{ roomId: 10, name: '独栋别墅', iconUrl: 'FangChan/', buyPrice: 10000000000000000000, inComeNum: 10000000000000000 },
|
|
{ roomId: 11, name: '联排别墅', iconUrl: 'FangChan/', buyPrice: 100000000000000000000, inComeNum: 100000000000000000 },
|
|
{ roomId: 12, name: '欧式城堡', iconUrl: 'FangChan/', buyPrice: 1000000000000000000000, inComeNum: 1000000000000000000 },
|
|
{ roomId: 13, name: '中式宅院', iconUrl: 'FangChan/', buyPrice: 30000000000000000000000, inComeNum: 30000000000000000000 },
|
|
{ roomId: 14, name: '空中别墅', iconUrl: 'FangChan/', buyPrice: 4000000000000000000000000, inComeNum: 4000000000000000000000 },
|
|
]
|
|
|
|
|
|
export default class FangChanManager {
|
|
public static getManagerConfigs() {
|
|
return FangChangConfig
|
|
}
|
|
|
|
public static getConfigById(roomId) {
|
|
let configTemp = null
|
|
for (let i = 0; i < FangChangConfig.length; i++) {
|
|
let config = FangChangConfig[i]
|
|
if (config.roomId == roomId) {
|
|
configTemp = config
|
|
break
|
|
}
|
|
}
|
|
return configTemp
|
|
}
|
|
|
|
public static getRoomState(roomId) {
|
|
let list = User.getFangchanList()
|
|
return list[roomId]
|
|
}
|
|
//买入价
|
|
public static getAllBuyMoney() {
|
|
let list = User.getFangchanList()
|
|
let allNum = 0
|
|
for (let i = 0; i < list.length; i++) {
|
|
if (list[i] == 1) {
|
|
let config = this.getConfigById(i)
|
|
allNum += config.buyPrice
|
|
}
|
|
}
|
|
return allNum
|
|
}
|
|
|
|
//当前价
|
|
public static getCurIncomeMoney() {
|
|
let allNum = this.getAllBuyMoney()
|
|
let allNum2 = this.getAllInComeMoney()
|
|
return allNum + allNum2
|
|
}
|
|
|
|
|
|
//总收益
|
|
public static getAllInComeMoney() {
|
|
let list = User.getFangchanShouyi()
|
|
let allNum = 0
|
|
for (let i = 0; i < list.length; i++) {
|
|
let shouyi = list[i]
|
|
allNum += shouyi
|
|
}
|
|
return allNum
|
|
}
|
|
|
|
public static refreshHaveMoney() {
|
|
let myMoney = User.getMoney()
|
|
let list = User.getFangchanList()
|
|
let isHave = false
|
|
for (let i = 0; i < list.length; i++) {
|
|
if (list[i] == 0) {
|
|
let config = this.getConfigById(i)
|
|
let buyPrice = config.buyPrice
|
|
if (myMoney - buyPrice >= 0) {
|
|
isHave = true
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
return isHave
|
|
|
|
}
|
|
|
|
//收益每秒
|
|
public static refreshFangChanIncome() {
|
|
let list = User.getFangchanList()
|
|
let shouyiList = User.getFangchanShouyi()
|
|
let allshouyi = 0
|
|
for (let i = 0; i < list.length; i++) {
|
|
if (list[i] == 1) {
|
|
let config = this.getConfigById(i)
|
|
shouyiList[i] += config.inComeNum
|
|
allshouyi += config.inComeNum
|
|
}
|
|
}
|
|
|
|
EventMgr.emitEvent_custom(ryw_Event.FangChanIncome);
|
|
|
|
}
|
|
|
|
|
|
//领取收益重置
|
|
public static resetAllInComeMoney() {
|
|
let list = User.getFangchanShouyi()
|
|
for (let i = 0; i < list.length; i++) {
|
|
list[i] = 0
|
|
}
|
|
User.setFangchanShouyi(list)
|
|
}
|
|
|
|
|
|
public static resetInComeMoneyById(roomId) {
|
|
let list = User.getFangchanShouyi()
|
|
list[roomId] = 0
|
|
User.setFangchanShouyi(list)
|
|
}
|
|
|
|
public static getInComeMoneyById(roomId) {
|
|
let list = User.getFangchanShouyi()
|
|
return list[roomId]
|
|
}
|
|
|
|
//设置房间状态
|
|
|
|
public static setRoomState(roomId, state) {
|
|
let list = User.getFangchanList()
|
|
list[roomId] = state
|
|
User.setFangchanList(list)
|
|
}
|
|
|
|
}
|
|
|