add new ui

This commit is contained in:
guoqing.zhu 2022-06-07 10:49:46 +08:00
parent a4e42ef0d2
commit 2610429236
13 changed files with 3607 additions and 303 deletions

6
.prettierrc Normal file
View File

@ -0,0 +1,6 @@
{
"semi":true,
"singleQuote": true,
"tabWidth": 4,
"useTabs": true
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
{
"ver": "1.0.1",
"uuid": "64258bea-dcc5-4c36-8cb7-5ba3143f6974",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
{
"ver": "1.0.1",
"uuid": "106245c2-8c36-4d50-9569-92a5b53ff57f",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"subMetas": {}
}

View File

@ -1,10 +1,7 @@
const { const { dropConfig, all_ItemConfig } = require('../../game/gameConfig');
dropConfig,
all_ItemConfig,
} = require('../../game/gameConfig');
const NetManage = require('../../manages/NetManage'); const NetManage = require('../../manages/NetManage');
const { type } = require('../../netBattle/net/proto/bytebuffer'); const { type } = require('../../netBattle/net/proto/bytebuffer');
var Utils = require("Utils") var Utils = require('Utils');
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
@ -20,54 +17,52 @@ cc.Class({
// type: cc.Node, // type: cc.Node,
// }, // },
missionTitle:{ missionTitle: {
default:null, default: null,
type:cc.Label type: cc.Label,
}, },
missionDesc:{ missionDesc: {
default:null, default: null,
type:cc.Label type: cc.Label,
}, },
herolistNode:{ herolistNode: {
default:null, default: null,
type:cc.Node type: cc.Node,
}, },
gunlistNode:{ gunlistNode: {
default:null, default: null,
type:cc.Node type: cc.Node,
}, },
rewardIcons:{ rewardIcons: {
default:null, default: null,
type:cc.Node type: cc.Node,
}, },
stars: {
stars:{ default: null,
default:null, type: cc.Node,
type:cc.Node
}, },
fullStarSpriteframe:{ fullStarSpriteframe: {
default:null, default: null,
type:cc.SpriteFrame type: cc.SpriteFrame,
},
ceg_num: {
default: null,
type: cc.Label,
}, },
ceg_num:{
default:null,
type:cc.Label
}
// needNode: { // needNode: {
// default: null, // default: null,
// type: cc.Node, // type: cc.Node,
// }, // },
}, },
initData(data,ceg_num) { initData(data, ceg_num) {
console.log('mission detail:' + JSON.stringify(data));
console.log("mission detail:"+JSON.stringify(data))
this.allChooseHero = new Array(); this.allChooseHero = new Array();
this.allChooseHero.length = 5; this.allChooseHero.length = 5;
this.allChooseGun = new Array(); this.allChooseGun = new Array();
@ -75,56 +70,54 @@ cc.Class({
this.missionData = data; this.missionData = data;
this.setRewards(data.reward) this.setRewards(data.reward);
console.log(data.param2) console.log(data.param2);
if(data.param2){ if (data.param2) {
for(let i=0;i<data.param2;i+=1){ for (let i = 0; i < data.param2; i += 1) {
console.log("set onmr ") console.log('set onmr ');
this.stars.children[i].getComponent(cc.Sprite).spriteFrame = this.fullStarSpriteframe this.stars.children[i].getComponent(cc.Sprite).spriteFrame =
this.fullStarSpriteframe;
} }
} }
if (data.param3) { if (data.param3) {
for(let i=0;i<this.herolistNode.children.length;i+=1){ for (let i = 0; i < this.herolistNode.children.length; i += 1) {
this.herolistNode.children[i].active = false this.herolistNode.children[i].active = false;
} }
for(let i=0;i<data.param3;i+=1){ for (let i = 0; i < data.param3; i += 1) {
this.herolistNode.children[i].active = true this.herolistNode.children[i].active = true;
} }
} }
if (data.param4) { if (data.param4) {
for(let i=0;i<this.gunlistNode.children.length;i+=1){ for (let i = 0; i < this.gunlistNode.children.length; i += 1) {
this.gunlistNode.children[i].active = false this.gunlistNode.children[i].active = false;
} }
for(let i=0;i<data.param4;i+=1){ for (let i = 0; i < data.param4; i += 1) {
this.gunlistNode.children[i].active = true this.gunlistNode.children[i].active = true;
} }
} }
this.ceg_num.string =`x${ceg_num}` this.ceg_num.string = `x${ceg_num}`;
}, },
setRewards(string){ setRewards(string) {
var config = dropConfig[string] var config = dropConfig[string];
var rewards = config.itemdata var rewards = config.itemdata;
// console.log(`reward---${JSON.stringify(rewards)}`) // console.log(`reward---${JSON.stringify(rewards)}`)
for(let i=0;i<rewards.length;i+=1){ for (let i = 0; i < rewards.length; i += 1) {
let id = rewards[i].id let id = rewards[i].id;
let num = rewards[i].num let num = rewards[i].num;
var tmp = this.rewardIcons.children[i] var tmp = this.rewardIcons.children[i];
tmp.active = true tmp.active = true;
tmp.children[0].getComponent(cc.Label).string = `x${num}` tmp.children[0].getComponent(cc.Label).string = `x${num}`;
// console.log(JSON.stringify(all_ItemConfig[id])) // console.log(JSON.stringify(all_ItemConfig[id]))
// Utils.setitem(this, id, tmp.children[1]); // Utils.setitem(this, id, tmp.children[1]);
} }
}, },
// initNeedIcon(param, index) { // initNeedIcon(param, index) {
@ -167,23 +160,21 @@ cc.Class({
onLoad() { onLoad() {
cc.Notifier.on('hasChooseHero', this, (data) => { cc.Notifier.on('hasChooseHero', this, (data) => {
if(this.herolistNode){ if (this.herolistNode) {
this.herolistNode.children[this.currentBtn] this.herolistNode.children[this.currentBtn]
.getComponent('mission_oneBox') .getComponent('mission_oneBox')
.init(data); .init(data);
this.allChooseHero[this.currentBtn] = data; this.allChooseHero[this.currentBtn] = data;
} }
}); });
cc.Notifier.on('hasChooseGun', this, (data) => { cc.Notifier.on('hasChooseGun', this, (data) => {
if(this.gunlistNode){ if (this.gunlistNode) {
this.gunlistNode.children[this.currentBtn] this.gunlistNode.children[this.currentBtn]
.getComponent('mission_oneBox') .getComponent('mission_oneBox')
.init(data); .init(data);
this.allChooseGun[this.currentBtn] = data; this.allChooseGun[this.currentBtn] = data;
} }
}); });
// cc.Notifier.on('ClearOneBox', this, (data) => { // cc.Notifier.on('ClearOneBox', this, (data) => {
@ -192,36 +183,34 @@ cc.Class({
// }); // });
}, },
close() { close() {
this.node.destroy(); this.node.destroy();
cc.Notifier.off('hasChooseHero', this); cc.Notifier.off('hasChooseHero', this);
cc.Notifier.off('hasChooseGun', this); cc.Notifier.off('hasChooseGun', this);
}, },
onClickAdd(event, param) { onClickAdd(event, param) {
this.currentBtn = param; this.currentBtn = param;
console.log(this.currentBtn) console.log(this.currentBtn);
this.mission_detail.active = true; this.mission_detail.active = true;
// set currentdata // set currentdata
console.log() console.log();
var type = 0; var type = 0;
if(event.currentTarget.parent.name=="Hero"){ if (event.currentTarget.parent.name == 'Hero') {
type = 0 type = 0;
}else{ } else {
type = 1 type = 1;
} }
this.mission_detail this.mission_detail
.getComponent('mission_chooseDetail') .getComponent('mission_chooseDetail')
.init(this.allChooseHero,this.allChooseGun,type); .init(this.allChooseHero, this.allChooseGun, type);
}, },
check() { check() {
return true return true;
// let toReturn = true; // let toReturn = true;
// this.allShowNode.forEach((element) => { // this.allShowNode.forEach((element) => {
// if (element.children[0].active == false) { // if (element.children[0].active == false) {
@ -258,7 +247,7 @@ cc.Class({
this.allChooseHero.forEach((element) => { this.allChooseHero.forEach((element) => {
if (element) { if (element) {
if (element.hero_uniid) { if (element.hero_uniid) {
heroNum+=1 heroNum += 1;
this.sendData += `${1}:${element.hero_uniid}|`; this.sendData += `${1}:${element.hero_uniid}|`;
} }
} }
@ -272,13 +261,12 @@ cc.Class({
} }
}); });
if(heroNum==0){ if (heroNum == 0) {
cc.uiHelper.showTips('Must choose a hero'); cc.uiHelper.showTips('Must choose a hero');
return return;
} }
if (this.sendData != '') {
if(this.sendData!=""){
NetManage.sendWantedMission( NetManage.sendWantedMission(
this.missionData.id, this.missionData.id,
this.sendData, this.sendData,
@ -291,7 +279,7 @@ cc.Class({
} }
} }
); );
}else{ } else {
cc.uiHelper.showTips('Not meeting the requirements'); cc.uiHelper.showTips('Not meeting the requirements');
} }
} else { } else {

View File

@ -1,6 +1,9 @@
const { dropConfig, all_ItemConfig } = require('../../game/gameConfig'); const { dropConfig, all_ItemConfig } = require('../../game/gameConfig');
const NetManage = require('../../manages/NetManage'); const NetManage = require('../../manages/NetManage');
var Utils = require("Utils") var Utils = require('Utils');
const { uimanger } = require('../UIManger');
const { CancelBoost } = require('../../tips/CancelBoost');
const { BoostTips } = require('../../tips/BoostTips');
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
@ -10,7 +13,7 @@ cc.Class({
default: null, default: null,
type: cc.Label, type: cc.Label,
}, },
allRewardNode:{ allRewardNode: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
@ -23,35 +26,45 @@ cc.Class({
type: cc.Label, type: cc.Label,
}, },
getNode:{ getNode: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
receiveNode:{ receiveNode: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
boostNode:{ boostNode: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
stars:{ stars: {
default:null, default: null,
type:cc.Node type: cc.Node,
}, },
fullStarSpriteframe:{ fullStarSpriteframe: {
default:null, default: null,
type:cc.SpriteFrame type: cc.SpriteFrame,
}, },
ceg_num:{ ceg_num: {
default:null, default: null,
type:cc.Label type: cc.Label,
} },
},
onLoad() {
cc.Notifier.on('boostcancel', this, this.hasCancelBoost.bind(this));
cc.Notifier.on('boostsuccess', this, this.boostsuccess.bind(this));
},
onDestroy() {
cc.Notifier.off('boostcancel', this, this.hasCancelBoost.bind(this));
cc.Notifier.off('boostsuccess', this, this.boostsuccess.bind(this));
}, },
onClickBtn() { onClickBtn() {
@ -63,26 +76,40 @@ cc.Class({
} }
if (this.missionState == 1) { if (this.missionState == 1) {
const node = cc.instantiate(this.missionPrefab); const node = cc.instantiate(this.missionPrefab);
node.getComponent('mission_choose').initData(this.wantedData,this.ceg); node.getComponent('mission_choose').initData(
this.wantedData,
this.ceg
);
cc.find('Canvas').addChild(node); cc.find('Canvas').addChild(node);
} }
if (this.missionState == 2) { if (this.missionState == 2) {
var data = {
NetManage.boostOfferRewardMission(this.missionId, () => { cegNum: 10,
this.node.destroy(); missionId: this.missionId,
cc.uiHelper.showTips('Boost Success!'); };
}); uimanger.showUI(BoostTips.prefabPath, data);
} }
}, },
onCancelBtn(){ onCancelBtn() {
uimanger.showUI(CancelBoost.prefabPath);
},
hasCancelBoost() {
NetManage.cancelOfferRewardMission(this.missionId, () => {
this.boostNode.active = false;
this.receiveNode.active = false;
this.getNode.active = true;
this.lb_time.node.parent.active = false;
cc.uiHelper.showTips('Boost cancel!'); cc.uiHelper.showTips('Boost cancel!');
NetManage.cancelOfferRewardMission(this.missionId,()=>{ });
this.boostNode.active = false },
this.receiveNode.active = false
this.getNode.active = true boostsuccess() {
this.lb_time.node.parent.active = false NetManage.boostOfferRewardMission(this.missionId, () => {
}) // this.node.destroy();
cc.uiHelper.showTips('Boost Success!');
});
}, },
formatSeconds(value) { formatSeconds(value) {
@ -108,12 +135,10 @@ cc.Class({
}, },
init(data, originData) { init(data, originData) {
if (data.param2) {
for (let i = 0; i < data.param2; i += 1) {
this.stars.children[i].getComponent(cc.Sprite).spriteFrame =
if(data.param2){ this.fullStarSpriteframe;
for(let i=0;i<data.param2;i+=1){
this.stars.children[i].getComponent(cc.Sprite).spriteFrame = this.fullStarSpriteframe
} }
} }
@ -121,19 +146,19 @@ cc.Class({
this.missionId = originData.mission_id; this.missionId = originData.mission_id;
if (originData.state == 0) { if (originData.state == 0) {
// this.btn_label.string = 'GET'; // this.btn_label.string = 'GET';
this.receiveNode.active = true this.receiveNode.active = true;
this.missionState = 0; this.missionState = 0;
} }
if (originData.state == 2) { if (originData.state == 2) {
if (originData.objects.length == 0) { if (originData.objects.length == 0) {
// this.btn_label.string = 'RECEIVE'; // this.btn_label.string = 'RECEIVE';
this.getNode.active = true this.getNode.active = true;
this.missionState = 1; this.missionState = 1;
} else { } else {
var leftTime = originData.lefttime; var leftTime = originData.lefttime;
this.lb_time.node.parent.active = true; this.lb_time.node.parent.active = true;
// this.btn_label.string = 'BOOST'; // this.btn_label.string = 'BOOST';
this.boostNode.active = true this.boostNode.active = true;
this.missionState = 2; this.missionState = 2;
this.lb_time.string = this.formatSeconds(leftTime); this.lb_time.string = this.formatSeconds(leftTime);
this.schedule(function () { this.schedule(function () {
@ -148,29 +173,25 @@ cc.Class({
this.node.destroy(); this.node.destroy();
} }
this.ceg = originData.ceg_num this.ceg = originData.ceg_num;
this.ceg_num.string =`x${originData.ceg_num}` this.ceg_num.string = `x${originData.ceg_num}`;
}, },
start(){ start() {
this.setRewards(this.wantedData.reward) this.setRewards(this.wantedData.reward);
}, },
setRewards(string) {
var config = dropConfig[string];
var rewards = config.itemdata;
setRewards(string){ for (let i = 0; i < rewards.length; i += 1) {
let id = rewards[i].id;
var config = dropConfig[string] let num = rewards[i].num;
var rewards = config.itemdata var tmp = this.allRewardNode.children[i];
tmp.active = true;
for(let i=0;i<rewards.length;i+=1){ tmp.children[0].getComponent(cc.Label).string = `x${num}`;
let id = rewards[i].id
let num = rewards[i].num
var tmp = this.allRewardNode.children[i]
tmp.active = true
tmp.children[0].getComponent(cc.Label).string = `x${num}`
// Utils.setitem(this, id, tmp.children[1]); // Utils.setitem(this, id, tmp.children[1]);
} }
}, },
}); });

View File

@ -30,9 +30,8 @@ window.connectOK = (account) => {
jclogin.getNonce(); jclogin.getNonce();
}; };
window.chainErr = ()=>{ window.chainErr = () => {
console.log("打开提示框") cc.Notifier.emit('chainerr');
cc.Notifier.emit("chainerr");
}; };
window.signApp = (sign) => { window.signApp = (sign) => {
@ -133,7 +132,6 @@ cc.Class({
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
onLoad() { onLoad() {
this.allCountry = ['Japan', 'Singapore', 'Turkey', 'USA']; this.allCountry = ['Japan', 'Singapore', 'Turkey', 'USA'];
this.cpa_icon = []; this.cpa_icon = [];
@ -147,8 +145,7 @@ cc.Class({
cc.Notifier.on('autologinsuccess', this, this.loadMain.bind(this)); cc.Notifier.on('autologinsuccess', this, this.loadMain.bind(this));
cc.Notifier.on("chainerr",this,this.showchainErrTip.bind(this)); cc.Notifier.on('chainerr', this, this.showchainErrTip.bind(this));
cc.debug.setDisplayStats(false); cc.debug.setDisplayStats(false);
@ -171,7 +168,7 @@ cc.Class({
} }
}, },
showchainErrTip(){ showchainErrTip() {
uimanger.showUI(ChainErrTip.prefabPath); uimanger.showUI(ChainErrTip.prefabPath);
}, },
@ -200,7 +197,7 @@ cc.Class({
cc.Notifier.off('sdkloginfail', this); cc.Notifier.off('sdkloginfail', this);
cc.Notifier.off('sdkLoginSuccess', this); cc.Notifier.off('sdkLoginSuccess', this);
cc.Notifier.off('autologinsuccess', this); cc.Notifier.off('autologinsuccess', this);
cc.Notifier.off("chainerr",this,this.showchainErrTip.bind(this)); cc.Notifier.off('chainerr', this, this.showchainErrTip.bind(this));
cc.loader.onProgress = null; cc.loader.onProgress = null;
SDKManage.logEvent('login_success', 'loginmain'); SDKManage.logEvent('login_success', 'loginmain');
}, },
@ -251,17 +248,13 @@ cc.Class({
// //
SDKManage.init('6516'); SDKManage.init('6516');
jcgamelog.addOperation(OperationType.LOGIN, 'gamestart');
jcgamelog.addOperation( jcgamelog.addOperation(
OperationType.LOGIN, OperationType.Login,
'gamestart', Config.mainConfig.packageid
); );
console.log(`current packageid `+ Config.mainConfig.packageid)
console.log(`current version `+ Config.mainConfig.version)
jcgamelog.addOperation(OperationType.Login,Config.mainConfig.packageid)
if (!localStorage.getItem('currentNet')) { if (!localStorage.getItem('currentNet')) {
localStorage.setItem('currentNet', allBaseNet.japan); localStorage.setItem('currentNet', allBaseNet.japan);
} else { } else {

View File

@ -0,0 +1,35 @@
import NetManage from '../manages/NetManage';
import { UIBase } from '../UI/UIBase';
const { ccclass, property } = cc._decorator;
@ccclass
export class BoostTips extends UIBase {
public static prefabPath = 'prefabs/tips/pb_Boost';
@property(cc.Label) cegLabel: cc.Label = null;
private indata: any;
init(data: any) {
// {
// cegNum
// missionid
// }
this.indata = data;
this.cegLabel.string = `x${data.cegNum}`;
}
onClose() {
this.node.destroy();
}
onOK() {
this.node.destroy();
cc.Notifier.emit('boostsuccess');
// NetManage.boostOfferRewardMission(this.indata.missionId, () => {
// this.node.destroy();
// cc.uiHelper.showTips('Boost Success!');
// });
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "2d1dad63-551e-423c-9807-8647f0bc7082",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,22 @@
import NetManage from '../manages/NetManage';
import { UIBase } from '../UI/UIBase';
const { ccclass, property } = cc._decorator;
@ccclass
export class CancelBoost extends UIBase {
public static prefabPath = 'prefabs/tips/pb_cancelBoost';
private indata: any;
init(data: any) {}
onClose() {
this.node.destroy();
}
onOK() {
this.node.destroy();
cc.Notifier.emit('boostcancel');
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.5",
"uuid": "e7f6257e-ede2-4576-a521-bbb6c70b9a7c",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}