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

View File

@ -1,6 +1,9 @@
const { dropConfig, all_ItemConfig } = require('../../game/gameConfig');
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({
extends: cc.Component,
@ -10,7 +13,7 @@ cc.Class({
default: null,
type: cc.Label,
},
allRewardNode:{
allRewardNode: {
default: null,
type: cc.Node,
},
@ -23,35 +26,45 @@ cc.Class({
type: cc.Label,
},
getNode:{
getNode: {
default: null,
type: cc.Node,
},
receiveNode:{
receiveNode: {
default: null,
type: cc.Node,
},
boostNode:{
boostNode: {
default: null,
type: cc.Node,
},
stars:{
default:null,
type:cc.Node
stars: {
default: null,
type: cc.Node,
},
fullStarSpriteframe:{
default:null,
type:cc.SpriteFrame
fullStarSpriteframe: {
default: null,
type: cc.SpriteFrame,
},
ceg_num:{
default:null,
type:cc.Label
}
ceg_num: {
default: null,
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() {
@ -63,26 +76,40 @@ cc.Class({
}
if (this.missionState == 1) {
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);
}
if (this.missionState == 2) {
NetManage.boostOfferRewardMission(this.missionId, () => {
this.node.destroy();
cc.uiHelper.showTips('Boost Success!');
});
var data = {
cegNum: 10,
missionId: this.missionId,
};
uimanger.showUI(BoostTips.prefabPath, data);
}
},
onCancelBtn(){
cc.uiHelper.showTips('Boost cancel!');
NetManage.cancelOfferRewardMission(this.missionId,()=>{
this.boostNode.active = false
this.receiveNode.active = false
this.getNode.active = true
this.lb_time.node.parent.active = false
})
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!');
});
},
boostsuccess() {
NetManage.boostOfferRewardMission(this.missionId, () => {
// this.node.destroy();
cc.uiHelper.showTips('Boost Success!');
});
},
formatSeconds(value) {
@ -101,19 +128,17 @@ cc.Class({
: Math.floor(result % 60);
let res = '';
res += `${h}:`;
res += `${m}:`;
res += `${h}:`;
res += `${m}:`;
res += `${s}`;
return res;
},
init(data, originData) {
if(data.param2){
for(let i=0;i<data.param2;i+=1){
this.stars.children[i].getComponent(cc.Sprite).spriteFrame = this.fullStarSpriteframe
if (data.param2) {
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;
if (originData.state == 0) {
// this.btn_label.string = 'GET';
this.receiveNode.active = true
this.receiveNode.active = true;
this.missionState = 0;
}
if (originData.state == 2) {
if (originData.objects.length == 0) {
// this.btn_label.string = 'RECEIVE';
this.getNode.active = true
this.getNode.active = true;
this.missionState = 1;
} else {
var leftTime = originData.lefttime;
this.lb_time.node.parent.active = true;
// this.btn_label.string = 'BOOST';
this.boostNode.active = true
this.boostNode.active = true;
this.missionState = 2;
this.lb_time.string = this.formatSeconds(leftTime);
this.schedule(function () {
@ -148,29 +173,25 @@ cc.Class({
this.node.destroy();
}
this.ceg = originData.ceg_num
this.ceg_num.string =`x${originData.ceg_num}`
this.ceg = originData.ceg_num;
this.ceg_num.string = `x${originData.ceg_num}`;
},
start(){
this.setRewards(this.wantedData.reward)
start() {
this.setRewards(this.wantedData.reward);
},
setRewards(string) {
var config = dropConfig[string];
var rewards = config.itemdata;
setRewards(string){
var config = dropConfig[string]
var rewards = config.itemdata
for(let i=0;i<rewards.length;i+=1){
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}`
for (let i = 0; i < rewards.length; i += 1) {
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]);
}
},
});

View File

@ -30,9 +30,8 @@ window.connectOK = (account) => {
jclogin.getNonce();
};
window.chainErr = ()=>{
console.log("打开提示框")
cc.Notifier.emit("chainerr");
window.chainErr = () => {
cc.Notifier.emit('chainerr');
};
window.signApp = (sign) => {
@ -133,7 +132,6 @@ cc.Class({
// LIFE-CYCLE CALLBACKS:
onLoad() {
this.allCountry = ['Japan', 'Singapore', 'Turkey', 'USA'];
this.cpa_icon = [];
@ -147,8 +145,7 @@ cc.Class({
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);
@ -171,7 +168,7 @@ cc.Class({
}
},
showchainErrTip(){
showchainErrTip() {
uimanger.showUI(ChainErrTip.prefabPath);
},
@ -200,7 +197,7 @@ cc.Class({
cc.Notifier.off('sdkloginfail', this);
cc.Notifier.off('sdkLoginSuccess', 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;
SDKManage.logEvent('login_success', 'loginmain');
},
@ -250,18 +247,14 @@ cc.Class({
// this.btn_wallet.active = true;
//
SDKManage.init('6516');
jcgamelog.addOperation(OperationType.LOGIN, 'gamestart');
jcgamelog.addOperation(
OperationType.LOGIN,
'gamestart',
OperationType.Login,
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')) {
localStorage.setItem('currentNet', allBaseNet.japan);
} 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": {}
}