觉醒时刻
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.
 
 
 
juexingshike/assets/Scripts/Manager/InterfaceManager.ts

1181 lines
49 KiB

import User, { UserGameData } from "../../FrameWork/User/User";
import Common5 from "../../Platform/th/Common5";
// import DustbinManager from "./DustbinManager";
// import IceWorldManager from "./IceWorldManager";
// import KuaidiManager from "./KuaidiManager";
import ProbabilityManager from "./ProbabilityManager";
// import ShouLieManager from "./ShouLieManager";
import BuyShopManager from "./BuyShopManager";
// import TaoFenManager from "./TaoFenManager";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
import BagManager, { BagGoodsConfig, GoodsLocalProperty } from "./BagManager";
// import DiaoYuConfigManage from "../diaoyu/DiaoYuConfigManage";
// import FengWeiManager from "./FengWeiManager";
import TaskManager, { MainTaskIdEnum, SubTaskIdEnum } from "../JuQingChat/TaskManager";
import GMManager from "./GMManager";
import AppPlatform from "../../FrameWork/Util/AppPlatform";
import CommonDefine from "../../Platform/th/CommonDefine";
import UserManager from "./UserManager";
// import NewDataManage_nls from "../game_dls/NewDataManage_nls";
// import IndustryManager from "./IndustryManager";
// import ChaChangManager from "./ChaChangManager";
// import BaiCaoJiManager from "./BaiCaoJiManager";
// import JiaLiGongManager from "./JiaLiGongManager";
// import QinWangLingManager from "./QinWangLingManager";
// import XiuXianNongZhuangManager from "./XiuXianNongZhuangManager";
// import YouTingJiDiManager from "./YouTingJiDiManager";
import KuaiDiZhanManager from "../GameMethodRes/kuaidizhan/KuaiDiZhanManager";
// import ChongWuGuanManager from "../ChongWuGuan/ChongWuGuanManager";
// import CaiChaConfigManage from "../game/caicha/CaiChaConfigManage";
// import { GameSecondLevelManage_xpz } from "../XiPanZi/NewDataManage_xpz";
import EventMgr from "../../FrameWork/Event/EventMgr";
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import JiuPingHuiShouManager from "../JiuPingHuiShou/JiuPingHuiShouManager";
import IceWorldManager from "./IceWorldManager";
export default class InterfaceManager {
public static initManager() {
// IndustryManager.initIndustryManager()
// FengWeiManager.initFengWeiManager()
// GameSecondLevelManage_xpz.setStartCellData()
InterfaceManager.loadAllJson()
}
public static loadAllJson() {
// let DiaoYuConfigCallFunc = (callFunc)=>{
// DiaoYuConfigManage.loadAllJson(callFunc);
// }
let JiuPingHuiShouConfigCallFunc = (callFunc) => {
JiuPingHuiShouManager.initManager(callFunc)
}
let BuyShopConfigCallFunc = (callFunc) => {
BuyShopManager.initManager(callFunc)
}
// let ChongWuGuanConfigCallFunc = (callFunc)=>{
// ChongWuGuanManager.initManager(callFunc)
// }
// let DustbinConfigCallFunc = (callFunc)=>{
// DustbinManager.initManager(callFunc)
// }
let IceWorldConfigCallFunc = (callFunc) => {
IceWorldManager.initManager(callFunc)
}
// let KuaidiConfigCallFunc = (callFunc)=>{
// KuaidiManager.initManager(callFunc)
// }
// let ShouLieConfigCallFunc = (callFunc)=>{
// ShouLieManager.initManager(callFunc)
// }
// let TaoFenConfigCallFunc = (callFunc)=>{
// TaoFenManager.initManager(callFunc)
// }
// let ChaChangConfigCallFunc = (callFunc)=>{
// ChaChangManager.initManager(callFunc)
// }
// let BaiCaoJiConfigCallFunc = (callFunc)=>{
// BaiCaoJiManager.initManager(callFunc)
// }
// let JiaLiGongConfigCallFunc = (callFunc)=>{
// JiaLiGongManager.initManager(callFunc)
// }
// let QinWangLingConfigCallFunc = (callFunc)=>{
// QinWangLingManager.initManager(callFunc)
// }
// let XiuXianNongChangConfigCallFunc = (callFunc)=>{
// XiuXianNongZhuangManager.initManager(callFunc)
// }
// let YouTingJiDiConfigCallFunc = (callFunc)=>{
// YouTingJiDiManager.initManager(callFunc)
// }
let KuaiDiZhanConfigCallFunc = (callFunc) => {
KuaiDiZhanManager.initManager(callFunc)
}
// let CaiChaConfigCallFunc = (callFunc)=>{
// CaiChaConfigManage.initManager(callFunc)
// }
//这里用递归的方式加载json,处理同时加载多个json情况
let loadJsonArr = [
JiuPingHuiShouConfigCallFunc, BuyShopConfigCallFunc, KuaiDiZhanConfigCallFunc, IceWorldConfigCallFunc
]
let loadIndex = 0
let loadCallFunc = (index) => {
if (index >= loadJsonArr.length) {
return
}
let time = new Date().getTime()
console.log('shaoyang_mainScene页加载当前json', index, time - Common5.shiJianChuo)
console.log('mainScene页loadAllJson_', index)
let callFunc = () => {
console.log('mainScene页单个json加载完毕,加载下一个')
loadCallFunc(++loadIndex)
}
loadJsonArr[index](callFunc)
}
loadCallFunc(loadIndex)
}
public static getAllEarnMoneyInterface() {
return 100
}
// public static getAllIndustryMoneyInterface(){
// let money1 = IndustryManager.allIndustryMoney()
// return money1
// }
// public static getIndustryConfigByIDInterface(id){
// return IndustryManager.getIndustryConfigByID(id)
// }
// public static initLoadManager(){
// let wanfaList = [GameType.NiFengKuaiDi, GameType.ShouLieChang, GameType.HJHA, GameType.ShouHuoji, GameType.BingHu, GameType.FanLaji, GameType.TaoFen]
// for(let i = 0; i<wanfaList.length;i++){
// let gameType = wanfaList[i]
// let list_ = null
// if(gameType == GameType.NiFengKuaiDi){
// list_ = KuaidiManager.getCurGoodList()
// }else if(gameType == GameType.ShouLieChang){
// list_ = ShouLieManager.getCurGoodList()
// }else if(gameType == GameType.HJHA){
// list_ = DiaoYuConfigManage.getCurGoodList()
// }else if(gameType == GameType.ShouHuoji){
// list_ = BuyShopManager.getCurGoodList()
// }else if(gameType == GameType.BingHu){
// list_ = IceWorldManager.getCurGoodList()
// }else if(gameType == GameType.FanLaji){
// list_ = DustbinManager.getCurGoodList()
// }else if(gameType == GameType.TaoFen){
// list_ = TaoFenManager.getCurGoodList()
// }
// for(let kk = 0; kk<list_.length; kk++){
// let goodId = list_[kk].goodId
// let bagConfig = {
// goodId:goodId,
// goodNum:1
// }
// BagManager.addBagList(bagConfig)
// }
// }
// }
public static getHaveKaiye(gameType) {
let list = User.getCanInterGameList()
for (let i = 0; i < list.length; i++) {
if (gameType == list[i]) {
return true
}
}
let Gm = GMManager.getToggleStatus_AllGameOpen()
if (Gm) {
return true
}
return false
}
// public static canInterGameList = []
public static getDaoyeTaskList() {
//任务倒爷
let subTaskInfo: any = TaskManager.getCurUnLockSubTaskInfo()
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
let daohuoList = []
console.log(subTaskInfo.Id, 'subTaskInfo.Id ++++====')
// if(mainId == MainTaskIdEnum.MainTask_203){
// let array= [1204]
// for(let i = 0; i<array.length;i++){
// let objData = BagManager.getGoodsProperty(array[i])
// daohuoList[daohuoList.length] = objData
// }
// }
// if(mainId == MainTaskIdEnum.MainTask_204){
// //换成洞洞鞋(1613),拖把头子(1607),鸡哥(1116),辣椒(1111),铁皮(1107),摆盘冻梨(1413),玉镯子(1437),易拉罐(1105)
// let array= [1613,1607,1116,1111,1107,1413,1437,1105]
// for(let i = 0; i<array.length;i++){
// let objData = BagManager.getGoodsProperty(array[i])
// daohuoList[daohuoList.length] = objData
// }
// }
return daohuoList
}
// public static getDaoyeList(gameType){
// //背包 + 7玩法++====
// let maxLength = 8
// let wanfaList = [GameType.NiFengKuaiDi, GameType.ShouLieChang, GameType.HJHA, GameType.XiaoMaibu, GameType.BingHu, GameType.FanLaji, GameType.TaoFen]
// let hetongData = User.getUserHeTong()
// let money = UserManager.getCurMoney()
// if(hetongData.isBuildChiTangFinish){
// wanfaList = [GameType.NiFengKuaiDi, GameType.ShouLieChang, GameType.HJHA, GameType.XiaoMaibu, GameType.BingHu, GameType.FanLaji, GameType.TaoFen]
// if(money<10000){
// wanfaList = [GameType.NiFengKuaiDi, GameType.ShouLieChang, GameType.HJHA, GameType.BingHu, GameType.FanLaji, GameType.TaoFen]
// }
// }else{
// wanfaList = [GameType.NiFengKuaiDi, GameType.ShouLieChang, GameType.XiaoMaibu, GameType.BingHu, GameType.FanLaji, GameType.TaoFen]
// if(money<10000){
// wanfaList = [GameType.NiFengKuaiDi, GameType.ShouLieChang, GameType.BingHu, GameType.FanLaji, GameType.TaoFen]
// }
// }
// let tempGameList = []
// let list = User.getCanInterGameList()
// for(let i = 0; i<list.length;i++){
// let game = list[i]
// if(wanfaList.indexOf(game)>=0){
// tempGameList[tempGameList.length] = game
// }
// }
// let bagList = BagManager.getBagProList()
// let daohuoList = []
// console.log(bagList, 'bagList+++==')
// let maxBagLength = bagList.length
// let goodidList = []
// if(bagList.length>0){
// if(maxBagLength>=4){
// maxBagLength = 4
// }
// bagList.sort(function(){
// return 0.5 - Math.random()
// })
// for(let i = 0; i<maxBagLength; i++){
// daohuoList[daohuoList.length] = bagList[i]
// goodidList[goodidList.length] = bagList[i].goodId
// }
// }
// let levelLength = maxLength-maxBagLength
// while(daohuoList.length<maxLength){
// if(tempGameList.length == 0){
// if(bagList.length>4){
// for(let i = daohuoList.length; i<bagList.length; i++){
// daohuoList[daohuoList.length] = bagList[i]
// if(daohuoList.length>=maxLength){
// break
// }
// }
// }
// return daohuoList
// }
// for(let i = 0; i<tempGameList.length;i++){
// let gameType = tempGameList[i]
// let list_ = null
// if(gameType == GameType.NiFengKuaiDi){
// list_ = KuaidiManager.getCurGoodList()
// }else if(gameType == GameType.ShouLieChang){
// list_ = ShouLieManager.getCurGoodList()
// }else if(gameType == GameType.HJHA){
// list_ = DiaoYuConfigManage.getCurGoodList()
// }else if(gameType == GameType.XiaoMaibu){
// list_ = BuyShopManager.getCurGoodList()
// }else if(gameType == GameType.BingHu){
// list_ = IceWorldManager.getCurGoodList()
// }else if(gameType == GameType.FanLaji){
// list_ = DustbinManager.getCurGoodList()
// }else if(gameType == GameType.TaoFen){
// list_ = TaoFenManager.getCurGoodList()
// }
// let random = Common5.getRandomNum(0, list_.length)
// let objData = list_[random]
// if(daohuoList.indexOf(objData)>=0){
// }else{
// console.log(objData, 'objData+++==')
// if(goodidList.indexOf(objData.goodId)<0){
// daohuoList[daohuoList.length] = objData
// if(daohuoList.length>=maxLength){
// break
// }
// }
// }
// }
// }
// return daohuoList
// }
public static setDaoyeList(gameType, index) {
let daohuoList = []
for (let i = 0; i < BagGoodsConfig.length; i++) {
if (gameType == BagGoodsConfig[i].gameType) {
let obj = {
goodId: BagGoodsConfig[i].goodId,
buyNum: BagGoodsConfig[i].buyNum,
buyPercent: 10,
gameType: BagGoodsConfig[i].gameType
}
daohuoList.push(obj)
}
}
User.setDaoyeIndex(index)
User.setDaoyeGoodList(daohuoList)
User.setDaoyeJiaoHuo(false)
User.setMaoYiFenHongTimes(5)
this.refreshChaoShiCaiDanStatus()
}
public static getDaoyeList() {
return User.getDaoyeGoodList()
}
public static refreshChaoShiCaiDanStatus() {
//无彩蛋状态
User.setCaiDanStatus(1, 0)
let index = User.getDaoyeIndex()
let rate = 0
if (index >= 1 && index <= 4) {
rate = 1
} else if (index >= 5 && index <= 8) {
rate = 5
} else if (index >= 9 && index <= 10) {
rate = 10
} else if (index == -1) {//全部单子完成后
rate = 100
}
if (GMManager.getToggleStatus_SRDD10()) {
rate = 100
}
console.log(`sy触发了第${index}张商人订单`)
let random = Math.floor(Math.random() * 100)
if (random < rate) {
//有彩蛋未完成状态
User.setCaiDanStatus(1, 1)
console.log('sy随机到了彩蛋11111')
} else {
console.log('sy未获得彩蛋22222')
}
EventMgr.emitEvent_custom(ryw_Event.RefreshChaoShiCaiDan)
}
public static getGoodInGame(goodsId) {
if (goodsId >= 1000 && goodsId <= 1099) {
return '售货机'
} else if (goodsId >= 1200 && goodsId <= 1299) {
return '长白山脉'
} else if (goodsId >= 1300 && goodsId <= 1399) {
return '顾氏水产'
} else if (goodsId >= 1400 && goodsId <= 1499) {
return '小卖部'
} else if (goodsId >= 1500 && goodsId <= 1599) {
return '冰雪世界'
} else if (goodsId >= 1100 && goodsId <= 1199) {
return '垃圾桶'
} else if (goodsId >= 1600 && goodsId <= 1699) {
return '顾氏环卫'
}
let config = BagManager.getJuQingGoodConfig(goodsId)
if (config) {
return config.gameType
}
}
public static getGoodInGameE(goodsId) {
if (goodsId >= 1000 && goodsId <= 1099) {
return 'ShouHuoJi'
} else if (goodsId >= 1200 && goodsId <= 1299) {
return 'ShouLie'
} else if (goodsId >= 1300 && goodsId <= 1399) {
return 'Diaoyu'
} else if (goodsId >= 1400 && goodsId <= 1499) {
return 'ShouHuoJi'
} else if (goodsId >= 1500 && goodsId <= 1599) {
return 'IceWorld'
} else if (goodsId >= 1100 && goodsId <= 1199) {
return 'Dustbin'
} else if (goodsId >= 1600 && goodsId <= 1699) {
return 'TaoFen'
} else if (goodsId == 1711 || goodsId == 1724 || goodsId == 2712) {
return 'Diaoyu'
}
}
public static DiTanSaleGoods(price) {
//let num = 1
User.setDitanSaleGoodsIndex(price)
}
public static changeList(gameType, goodArray, isCanchangeList, isAD) {
// let config = BagManager.getJuQingGoodConfig()
//保底生效,出GM物品
if (isCanchangeList) {
let goodIdTemp = 0
let gameTypeCompare = '-999'
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
let configData = null
//优先任务Gm
let isHaveTaskGm = false
if (mainId != MainTaskIdEnum.MainTask_None && mainId) {
configData = TaskManager.getTaskConfigById(mainId)
console.log(configData, 'config++++++++++++==')
if (configData.GMGoodIdArray && (configData.GMGameType == gameType)) {
// goodIdTemp = configData.GMGoodIdArray[0]
for (let i = 0; i < configData.GMGoodIdArray.length; i++) {
let goodId = configData.GMGoodIdArray[i]
if (BagManager.getBagGoodNums(goodId) <= 0) {
isHaveTaskGm = true
goodIdTemp = goodId
break
}
}
//goodIdTemp = configData.GMGoodIdArray[0]
gameTypeCompare = configData.GMGameType
}
}
if (!isHaveTaskGm) {
let daoYeList = InterfaceManager.getDaoyeList()
if (daoYeList.length > 0) {
// goodIdTemp = daoYeList[0].goodId
let config = BagManager.getJuQingGoodConfig(daoYeList[0].goodId)
gameTypeCompare = config.GMGameType
for (let i = 0; i < daoYeList.length; i++) {
let goodId = daoYeList[i].goodId
if (BagManager.getBagGoodNums(goodId) <= 0) {
goodIdTemp = goodId
break
}
}
}
}
console.log(goodIdTemp, gameTypeCompare, 'gameTypeCompare+++++++++++=====')
if (gameTypeCompare == gameType) {
console.log('正是这个玩法')
let goodId = goodIdTemp
let goodsNum = BagManager.getBagGoodNums(goodId)
if (goodsNum <= 0) {
let isHave = false
for (let i = 0; i < goodArray.length; i++) {
if (goodArray[i].goodId == goodIdTemp || goodIdTemp == 0) {
isHave = true
break
}
}
if (isHave) {
console.log('列表有任务物品不需要变换')
return goodArray
} else {
//商人收购单某些物品不能免费刷出,只能广告刷出
let juQingGoodConfig = BagManager.getJuQingGoodConfig(goodId)
let isCanOut = true
if (!isAD) {
if (juQingGoodConfig && !juQingGoodConfig.isCanFreeOut) {
isCanOut = false
}
}
if (isCanOut) {
for (let i = 0; i < goodArray.length; i++) {
goodArray[i].goodId = goodId
break
}
}
console.log('商人收购单某些物品不能免费刷出,只能广告刷出', goodId, isCanOut)
console.log('背包没有任务物品,变换完成', goodArray)
return goodArray
}
} else {
console.log('背包有任务物品不需要变换')
return goodArray
}
} else if (gameTypeCompare == '-999') {
console.log('不是这个玩法')
let daoyeGoodList = User.getDaoyeGoodList()
//判断倒爷的道具是这个玩法的并且数量不足的情况
console.log(daoyeGoodList, 'daoyeGoodList+++判断倒爷的道具是这个玩法的并且数量不足的情况++++++++=====')
// let daoyeJiaohuo = User.getDaoyeJiaoHuo()
if (daoyeGoodList.length == 0) {
//
console.log(goodArray, '倒爷已经提交货单了')
return goodArray
} else {
let tempList = []
for (let i = 0; i < daoyeGoodList.length; i++) {
let gameTypeGet = this.getGoodInGameE(daoyeGoodList[i].goodId)
if (gameTypeGet == gameType) {
tempList[tempList.length] = BagManager.getGoodsProperty(daoyeGoodList[i].goodId)
}
}
if (tempList.length == 0) {
console.log(goodArray, '提货单没有这个玩法的道具')
return goodArray
} else {
let goodIdTemp = 0
for (let i = 0; i < tempList.length; i++) {
let buyNum = tempList[i].buyNum || 0
let haveNum = BagManager.getBagGoodNums(tempList[i].goodId)
if (haveNum < buyNum) {
goodIdTemp = tempList[i].goodId
break
}
}
console.log(goodIdTemp, '替换这个道具')
// 开始改变list
let isHave = false
for (let i = 0; i < goodArray.length; i++) {
if (goodArray[i].goodId == goodIdTemp || goodIdTemp == 0) {
isHave = true
break
}
}
if (isHave) {
console.log(goodIdTemp, '正准备给了这个道具')
return goodArray
} else {
if (goodIdTemp == 0) {
console.log(goodArray, '没有匹配的goodId')
return goodArray
} else {
for (let i = 0; i < goodArray.length; i++) {
goodArray[i].goodId = goodIdTemp
break
}
console.log(goodIdTemp, '切换道具')
return goodArray
}
}
}
}
} else {
//
console.log('不需要变换')
return goodArray
}
} else {
return goodArray
}
}
public static changeList2(gameType, goodArray, isAD, AdRandomNum?) {
let goodsIdIndex = [];
let goodIdTemp = [];
let gameTypeCompare = '-999';
let isHaveTaskGm = false;
//先将所有可以出的放到数组中记录
let taskInfo: any = TaskManager.getCurUnLockMainTaskInfo();
if (taskInfo.Id != MainTaskIdEnum.MainTask_None && taskInfo.Id) {
let configData = TaskManager.getTaskConfigById(taskInfo.Id);
if (configData.GMGoodIdArray && (configData.GMGameType == gameType)) {
for (let i = 0; i < configData.GMGoodIdArray.length; i++) {
let goodId = configData.GMGoodIdArray[i];
if (BagManager.getBagGoodNums(goodId) <= 0) {
goodIdTemp.push(goodId);
goodsIdIndex.push(i);
}
}
isHaveTaskGm = true;
gameTypeCompare = configData.GMGameType;
}
}
if (!isHaveTaskGm) {
let daoYeList = InterfaceManager.getDaoyeList()
if (daoYeList.length > 0) {
let config = BagManager.getJuQingGoodConfig(daoYeList[0].goodId)
gameTypeCompare = config.GMGameType;
for (let i = 0; i < daoYeList.length; i++) {
let goodId = daoYeList[i].goodId;
if (BagManager.getBagGoodNums(goodId) <= 0) {
goodIdTemp.push(goodId);
goodsIdIndex.push(i);
}
}
}
}
if (goodIdTemp.length > 0) {
if (gameTypeCompare == gameType) {
console.log('正是这个玩法');
let isHave = false;
for (let i = 0; i < goodArray.length; i++) {
if (goodIdTemp.indexOf(goodArray[i].goodId) >= 0 || goodIdTemp.length == 0) {
isHave = true;
break;
}
}
if (isHave) {
console.log('列表有任务物品不需要变换');
return goodArray;
} else {
let arr = []
for (let i = 0; i < goodIdTemp.length; i++) {
let isCanOut = isAD;
let juQingGoodConfig = BagManager.getJuQingGoodConfig(goodIdTemp[i]);
if (!juQingGoodConfig || juQingGoodConfig.isCanFreeOut) {
if (ProbabilityManager.getCanChangeList_FreeGoods(gameType, goodsIdIndex[i])) {
isCanOut = true;
}
}
if (isCanOut) {
arr.push(goodIdTemp[i])
// goodArray[index].goodId = goodIdTemp[i];
// index++
}
}
//随机出个数
let num = arr.length
if (isAD && AdRandomNum) {
num = AdRandomNum
} else {
if (arr.length > goodArray.length) {
num = goodArray.length
}
if (num > 1) {
num = Math.floor(Math.random() * num) + 1
console.log('随机数量==', num)
}
}
for (let i = 0; i < num; i++) {
goodArray[i].goodId = arr[i]
}
// console.log('商人收购单某些物品不能免费刷出,只能广告刷出', goodIdTemp, isCanOut);
console.log('背包没有任务物品,变换完成', goodArray);
return goodArray;
}
} else if (gameTypeCompare == '-999') {
console.log('不是这个玩法')
return goodArray
let daoyeGoodList = User.getDaoyeGoodList()
//判断倒爷的道具是这个玩法的并且数量不足的情况
console.log(daoyeGoodList, 'daoyeGoodList+++判断倒爷的道具是这个玩法的并且数量不足的情况++++++++=====')
// let daoyeJiaohuo = User.getDaoyeJiaoHuo()
if (daoyeGoodList.length == 0) {
console.log(goodArray, '倒爷已经提交货单了')
return goodArray
} else {
let tempList = []
for (let i = 0; i < daoyeGoodList.length; i++) {
let gameTypeGet = this.getGoodInGameE(daoyeGoodList[i].goodId)
if (gameTypeGet == gameType) {
tempList[tempList.length] = BagManager.getGoodsProperty(daoyeGoodList[i].goodId)
}
}
if (tempList.length == 0) {
console.log(goodArray, '提货单没有这个玩法的道具')
return goodArray
} else {
let goodIdTemp = 0
for (let i = 0; i < tempList.length; i++) {
let buyNum = tempList[i].buyNum || 0
let haveNum = BagManager.getBagGoodNums(tempList[i].goodId)
if (haveNum < buyNum) {
goodIdTemp = tempList[i].goodId
break
}
}
console.log(goodIdTemp, '替换这个道具')
// 开始改变list
let isHave = false
for (let i = 0; i < goodArray.length; i++) {
if (goodArray[i].goodId == goodIdTemp || goodIdTemp == 0) {
isHave = true
break
}
}
if (isHave) {
console.log(goodIdTemp, '正准备给了这个道具')
return goodArray
} else {
if (goodIdTemp == 0) {
console.log(goodArray, '没有匹配的goodId')
return goodArray
} else {
for (let i = 0; i < goodArray.length; i++) {
goodArray[i].goodId = goodIdTemp
break
}
console.log(goodIdTemp, '切换道具')
return goodArray
}
}
}
}
} else {
console.log('不需要变换');
return goodArray;
}
} else {
console.log('没有道具,不需要变换!');
return goodArray;
}
}
public static getMangheGoodsListByType(gameType, goodsNum = 1, isAD = false, probabilityType = 'common') {
//根据游戏类型和是否广告获取配置的概率
let pro = ProbabilityManager.getMangHeProbability(gameType, goodsNum, isAD, probabilityType)
console.log(pro, 'pro+++++++++===')
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
console.log('getMangheGoodsListByType==', gameType, goodsNum, isAD, probabilityType)
//根据保底逻辑判断是否GM保底生效
let isCanchangeList = ProbabilityManager.getCanChangeList(gameType)
if (gameType == 'KuaiDiZhan') {
let list_ = KuaiDiZhanManager.getCurGoodList()
let goodArray = []
let goodIndex = []
while (goodArray.length < goodsNum) {
let index_ = Common5.getProbabilityResultIndex(pro)
let goods = list_[index_]
if (goodIndex.indexOf(index_) >= 0) {
} else {
goodIndex[goodIndex.length] = index_
let objData = {
goodId: goods.goodId,
goodNum: 1
}
goodArray[goodArray.length] = objData
}
}
console.log(goodArray, '快递站goodArray++++=====')
let goodArrayNew = this.changeList2(gameType, goodArray, isAD, 1);
return goodArrayNew
} else if (gameType == 'JiuPingHuiShou') {
let list_ = JiuPingHuiShouManager.getCurGoodList()
let goodArray = []
let goodIndex = []
while (goodArray.length < goodsNum) {
let index_ = Common5.getProbabilityResultIndex(pro)
let goods = list_[index_]
if (goodIndex.indexOf(index_) >= 0) {
} else {
goodIndex[goodIndex.length] = index_
let objData = {
goodId: goods.goodId,
goodNum: 1
}
goodArray[goodArray.length] = objData
}
}
console.log(goodArray, '废瓶回收goodArray++++=====')
let goodArrayNew = this.changeList2(gameType, goodArray, isAD);
return goodArrayNew
} else if (gameType == 'ShouHuoJi') {
let list_ = BuyShopManager.getCurGoodList()
let goodArray = []
let goodIndex = []
while (goodArray.length < goodsNum) {
let index_ = Common5.getProbabilityResultIndex(pro)
let goods = list_[index_]
if (goodIndex.indexOf(index_) >= 0) {
} else {
goodIndex[goodIndex.length] = index_
let objData = {
"saveNum": 15,
"buyNum": 14,
"goodId": 1401,
"descStr": "鸡蛋",
"goodName": "鸡蛋",
"priceNum": 2
}
objData.saveNum = goods.saveNum
objData.buyNum = goods.buyNum
objData.goodId = goods.goodId
objData.descStr = goods.descStr
objData.goodName = goods.goodName
objData.priceNum = goods.priceNum
goodArray[goodArray.length] = objData
}
}
console.log(goodArray, '售货机goodArray++++=====')
let goodArrayNew = this.changeList(gameType, goodArray, isCanchangeList, isAD)
goodArrayNew.sort(function () {
return 0.5 - Math.random()
})
return goodArrayNew
} else if (gameType == 'IceWorld') {
let goodArray = []
let list_ = IceWorldManager.getCurGoodList()
for (let i = 0; i < goodsNum; i++) {
let index_ = Common5.getProbabilityResultIndex(pro)
// if(i == goodsNum-1){
// if(GMManager.getToggleStatus_YANHU()){
// index_ = 1
// }
// }
let goods = list_[index_]
let data_ = { goodId: 0, goodNum: 1, goodIndex: 0 }
data_.goodId = goods.goodId
data_.goodIndex = index_
let isHaveData = false
for (let value of goodArray) {
if (value.goodId == data_.goodId && value.goodIndex == data_.goodIndex) {
isHaveData = true
value.goodNum++
break
}
}
if (!isHaveData) {
goodArray.push(data_)
}
}
let goodArrayNew = this.changeList(gameType, goodArray, isCanchangeList, isAD)
return goodArrayNew
}
}
public static getFixGoodListByIndex() {
let goodList = BuyShopManager.getCurGoodList()
return goodList
}
public static getXiaoMaibuConfigs(gameType, goodsNum = 1, isAD = false, probabilityType = 'common') {
let pro = ProbabilityManager.getMangHeProbability(gameType, goodsNum, isAD, probabilityType)
let isCanchangeList = ProbabilityManager.getCanChangeList(gameType)
let list_ = BuyShopManager.getCurGoodList()
let goodList = []
let goodIndex = []
while (goodList.length < goodsNum) {
let index_ = Common5.getProbabilityResultIndex(pro)
let goods = list_[index_]
if (goodIndex.indexOf(index_) >= 0) {
} else {
goodIndex[goodIndex.length] = index_
let objData = {
"saveNum": 15,
"buyNum": 14,
"goodId": 1401,
"descStr": "鸡蛋",
"goodName": "鸡蛋",
"priceNum": 2
}
objData.saveNum = goods.saveNum
objData.buyNum = goods.buyNum
objData.goodId = goods.goodId
objData.descStr = goods.descStr
objData.goodName = goods.goodName
objData.priceNum = goods.priceNum
goodList[goodList.length] = objData
}
}
console.log(goodList, 'goodList++++=====')
let goodArrayNew = this.changeListXMB(gameType, goodList, isCanchangeList)
goodArrayNew.sort(function () {
return 0.5 - Math.random()
})
console.log('goodArrayNew==', goodArrayNew)
return goodArrayNew
}
public static changeListXMB(gameType, goodArray, isCanchangeList) {
if (isCanchangeList) {
//完成任务107
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
let configData = null
if (mainId != MainTaskIdEnum.MainTask_None && mainId) {
configData = TaskManager.getTaskConfigById(mainId)
console.log(configData, 'config++++++++++++==')
}
let goodIdTemp = 0
let gameTypeCompare = '-999'
if (configData) {
if (configData.GMGoodIdArray && configData.GMGameType) {
goodIdTemp = configData.GMGoodIdArray[0]
gameTypeCompare = configData.GMGameType
}
}
console.log(goodIdTemp, gameTypeCompare, 'gameTypeCompare+++++++++++=====')
if (gameTypeCompare == gameType) {
console.log('正是这个玩法')
//这里有问题,等待时间处理
// let curTaskIdTemp = MainTaskIdEnum.MainTask_109
// if(gameType == 'XiaoMaibu' && curTaskIdTemp == mainId){
// let isHave = false
// let insertGoodid = 0
// let insertGoodid2 = 0
// //goodArray 小卖部的购买列表
// // 找出是否需要插入物品
// let isAllHave = true
// for(let i = 0; i<XinYuanQingDanConfigId.length;i++){
// if(BagManager.getBagGoodNums(XinYuanQingDanConfigId[i]) <= 0){
// insertGoodid = XinYuanQingDanConfigId[i]
// isAllHave = false
// break
// }
// }
// if(isAllHave){
// console.log('年货集齐完成')
// return goodArray
// }else{
// for(let i = 0; i<XinYuanQingDanConfigId.length;i++){
// if(BagManager.getBagGoodNums(XinYuanQingDanConfigId[i]) <= 0){
// if(insertGoodid != XinYuanQingDanConfigId[i]){
// insertGoodid2 = XinYuanQingDanConfigId[i]
// break
// }
// }
// }
// //找出没有的年货
// console.log('找出没有的年货', insertGoodid, insertGoodid2)
// for(let i = 0; i<goodArray.length;i++){
// if(goodArray[i].goodId == insertGoodid || insertGoodid == 0){
// isHave = true
// break
// }
// }
// let isHave2 = false
// for(let i = 0; i<goodArray.length;i++){
// if(goodArray[i].goodId == insertGoodid2|| insertGoodid2 == 0){
// isHave2 = true
// break
// }
// }
// if(isHave2){
// console.log('小卖部有这个年货2')
// }else{
// console.log('小卖部没有这个年货插入id'+insertGoodid2)
// for(let i = 0; i<goodArray.length;i++){
// if(goodArray[i].goodId != insertGoodid){
// goodArray[i].goodId = insertGoodid2
// break
// }
// }
// }
// if(isHave){
// console.log('小卖部有这个年货')
// return goodArray
// }else{
// for(let i = 0; i<goodArray.length;i++){
// if(goodArray[i].goodId != insertGoodid2){
// goodArray[i].goodId = insertGoodid
// break
// }
// }
// console.log('小卖部没有这个年货插入id', insertGoodid)
// return goodArray
// }
// }
// }
//其他任务的只有一个
let goodId = goodIdTemp
let goodsNum = BagManager.getBagGoodNums(goodId)
if (goodsNum <= 0) {
let isHave = false
for (let i = 0; i < goodArray.length; i++) {
if (goodArray[i].goodId == goodIdTemp) {
isHave = true
break
}
}
if (isHave) {
console.log('列表有任务物品不需要变换')
return goodArray
} else {
for (let i = 0; i < goodArray.length; i++) {
goodArray[i].goodId = goodId
break
}
console.log('背包没有任务物品,变换完成')
return goodArray
}
} else {
console.log('背包有任务物品不需要变换')
return goodArray
}
} else if (gameTypeCompare == '-999') {
console.log('不是这个玩法')
let daoyeGoodList = User.getDaoyeGoodList()
//判断倒爷的道具是这个玩法的并且数量不足的情况
console.log(daoyeGoodList, 'daoyeGoodList+++判断倒爷的道具是这个玩法的并且数量不足的情况++++++++=====')
// let daoyeJiaohuo = User.getDaoyeJiaoHuo()
if (daoyeGoodList.length == 0) {
//
console.log(goodArray, '倒爷已经提交货单了')
return goodArray
} else {
let tempList = []
for (let i = 0; i < daoyeGoodList.length; i++) {
let gameTypeGet = this.getGoodInGameE(daoyeGoodList[i].goodId)
if (gameTypeGet == gameType) {
tempList[tempList.length] = BagManager.getGoodsProperty(daoyeGoodList[i].goodId)
}
}
if (tempList.length == 0) {
console.log(goodArray, '提货单没有这个玩法的道具')
return goodArray
} else {
let goodIdTemp = 0
let goodIdTemp2 = 0
for (let i = 0; i < tempList.length; i++) {
let buyNum = tempList[i].buyNum || 0
let haveNum = BagManager.getBagGoodNums(tempList[i].goodId)
if (haveNum < buyNum) {
goodIdTemp = tempList[i].goodId
break
}
}
for (let i = 0; i < tempList.length; i++) {
let buyNum = tempList[i].buyNum || 0
let haveNum = BagManager.getBagGoodNums(tempList[i].goodId)
if (haveNum < buyNum && tempList[i].goodId != goodIdTemp) {
goodIdTemp2 = tempList[i].goodId
break
}
}
console.log(goodIdTemp, '替换这个道具goodIdTemp')
console.log(goodIdTemp2, '替换这个道具goodIdTemp2')
// 开始改变list
let isHave = false
let isHave2 = false
for (let i = 0; i < goodArray.length; i++) {
if (goodArray[i].goodId == goodIdTemp || goodIdTemp == 0) {
isHave = true
break
}
}
for (let i = 0; i < goodArray.length; i++) {
if (goodArray[i].goodId == goodIdTemp2 || goodIdTemp2 == 0) {
isHave2 = true
break
}
}
if (isHave2) {
console.log(goodIdTemp2, '有这个道具')
} else {
for (let i = 0; i < goodArray.length; i++) {
if (goodArray[i].goodId != goodIdTemp) {
goodArray[i].goodId = goodIdTemp2
break
}
}
}
if (isHave) {
console.log(goodIdTemp, '正准备给了这个道具')
return goodArray
} else {
if (goodIdTemp == 0) {
console.log(goodArray, '没有匹配的goodId')
return goodArray
} else {
for (let i = 0; i < goodArray.length; i++) {
if (goodArray[i].goodId != goodIdTemp2) {
goodArray[i].goodId = goodIdTemp
break
}
}
console.log(goodIdTemp, '切换道具')
return goodArray
}
}
}
}
} else {
//
console.log('不需要变换')
return goodArray
}
} else {
return goodArray
}
}
public static saveData(isShow = false) {
if (!AppPlatform.is_TT_GAME_custom()) {
if (Common5.saveTime == 0) {
Common5.saveTime = 30
console.log('保存数据')
let sendData = UserManager.sendDataToUrl()
if (isShow) {
PrefabManage.showTextTips('保存数据成功')
}
} else {
console.log('保存数据过于频繁请稍后再试')
if (isShow) {
PrefabManage.showTextTips('保存数据过于频繁')
}
}
} else {
if (Common5.saveTime == 0) {
let sendData = UserManager.sendDataToUrl()
CommonDefine.setServerData(sendData, () => {
Common5.saveTime = 30
console.log('保存数据成功')
if (isShow) {
PrefabManage.showTextTips('保存数据成功')
}
}, () => {
console.log('保存数据失败')
})
} else {
//PrefabManage.showTextTips('保存数据过于频繁请稍后再试')
console.log('保存数据过于频繁')
}
}
}
}