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.
548 lines
22 KiB
548 lines
22 KiB
|
|
//*********************
|
|
// create by 流云
|
|
// time: Tue Sep 09 2025
|
|
// desc:
|
|
//*********************
|
|
import { _decorator, Component, Node, find, instantiate, Label, tween, v3, Tween, Vec3, ProgressBar, sp, Sprite } from 'cc';
|
|
import { Auto_pageWeapon } from './Auto_pageWeapon';
|
|
import { SpriteLoad } from 'db://assets/mx/components/SpriteLoad';
|
|
import { GPath, GBundle, UIID } from '../../game/ConfigRes';
|
|
import { GEvent } from 'db://assets/mx/module/event/GEvent';
|
|
import { WeaponType } from '../../manager/WeaponDataManager';
|
|
import { OtherDataType, StatisticsType } from '../../game/GameData';
|
|
import { ConstEnum } from '../../manager/ConstManager';
|
|
import { sdkConfig } from '../../sdk/sdkConfig';
|
|
import { MonthCardType } from '../../purchase/Purchase';
|
|
import { TargetTaskType } from '../../manager/TargetTaskManager';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('UIpageWeapon')
|
|
export class UIpageWeapon extends Auto_pageWeapon {
|
|
weaponTypeList: ITableWeapon2[] = []
|
|
/**未拥有 */
|
|
noHaveArr: ITableWeapon2[] = []
|
|
/**已拥有 */
|
|
haveArr: ITableWeapon2[] = []
|
|
/**已装备 */
|
|
equippedArr: ITableWeapon2[] = []
|
|
/**装备区位置数量 */
|
|
equipPosAccount = 8
|
|
|
|
/**是否正在交换卡片 */
|
|
isExchangeCard: boolean = false
|
|
changeData: ITableWeapon2 = null
|
|
|
|
|
|
maxLevel: number = 50;
|
|
onLoad(): void {
|
|
super.onLoad();
|
|
}
|
|
|
|
onEnable(): void {
|
|
super.onEnable();
|
|
GEvent.Ins.on(GEvent.WeaponRemove, this.weaponRemove, this);
|
|
GEvent.Ins.on(GEvent.WeaponUse, this.weaponUse, this);
|
|
GEvent.Ins.on(GEvent.WeaponLevelUp, this.weaponLevelUp, this);
|
|
GEvent.Ins.on(GEvent.LiulianGuideIndexEvent, this.showLiulianGuide, this);
|
|
}
|
|
|
|
onDisable(): void {
|
|
super.onDisable();
|
|
GEvent.Ins.off(GEvent.WeaponRemove, this.weaponRemove, this);
|
|
GEvent.Ins.off(GEvent.WeaponUse, this.weaponUse, this);
|
|
GEvent.Ins.off(GEvent.LiulianGuideIndexEvent, this.showLiulianGuide, this);
|
|
GEvent.Ins.off(GEvent.WeaponLevelUp, this.weaponLevelUp, this);
|
|
|
|
}
|
|
showGuide() {
|
|
|
|
if (gg.data.getStatistics(StatisticsType.homeGuideIndex) == 2) {
|
|
|
|
let toggle = this.ui_equippedLayout.children[0]
|
|
gg.ui.openPanel(UIID.NewGuideMask, {
|
|
data: [
|
|
[toggle],
|
|
[''],
|
|
() => {
|
|
|
|
//点击彩虹飞弹
|
|
gg.data.setStatistics(StatisticsType.homeGuideIndex, 3)
|
|
},
|
|
true,
|
|
255
|
|
]
|
|
})
|
|
}else{
|
|
this.showLiulianGuide()
|
|
}
|
|
}
|
|
|
|
showLiulianGuide(){
|
|
if(gg.data.getStatistics(StatisticsType.LiulianGuideIndex) == 2){
|
|
gg.sdk.reportDY("inLevel", `章节1_5-引导点击榴莲`);
|
|
let toggle = this.ui_haveLayout.children[0]
|
|
gg.ui.openPanel(UIID.NewGuideMask, {
|
|
data: [
|
|
[toggle],
|
|
[''],
|
|
() => {
|
|
|
|
//点击榴莲换武器
|
|
gg.data.setStatistics(StatisticsType.LiulianGuideIndex, 3)
|
|
gg.ui.openPanel(UIID.WeaponLevelUp, { data: [12] });
|
|
},
|
|
true,
|
|
255
|
|
]
|
|
})
|
|
}else if(gg.data.getStatistics(StatisticsType.LiulianGuideIndex) == 4){
|
|
gg.sdk.reportDY("inLevel", `章节1_5-引导替换手掌`);
|
|
let toggle = this.ui_equippedLayout.children[5]
|
|
gg.ui.openPanel(UIID.NewGuideMask, {
|
|
data: [
|
|
[toggle],
|
|
[gg.lang.get('让我们来替换它')],
|
|
() => {
|
|
|
|
//
|
|
gg.data.setStatistics(StatisticsType.LiulianGuideIndex, 5)
|
|
//关闭引导立马打开引导界面有问题所以加点延迟
|
|
setTimeout(()=>{
|
|
GEvent.Ins.emit(GEvent.LiulianGuideIndexEvent)
|
|
},50)
|
|
},
|
|
true,
|
|
255
|
|
]
|
|
})
|
|
}
|
|
}
|
|
|
|
weaponLevelUp(weaponId: number) {
|
|
//刷新数据
|
|
this.playScaleAnim(false)
|
|
}
|
|
|
|
playScaleAnim(isPlayAnim) {
|
|
this.initData()
|
|
//this.ui_notHaveLayout/this.ui_haveLayout/this.ui_equippedLayout
|
|
if (this.ui_notHaveLayout.children.length > 0) {
|
|
//item播放动画
|
|
// this.refreshView()
|
|
|
|
for (let i = 0; i < this.ui_notHaveLayout.children.length; i++) {
|
|
let t = this.noHaveArr[i]
|
|
if (t) {
|
|
|
|
let level = gg.data.project.getWeaponLevel(t.weaponid);
|
|
|
|
let conf = gg.data.project.getWeaponData(t.weaponid);
|
|
let weaponSPNum = gg.data.getItemNum(conf.scrapId);
|
|
let needNum = gg.data.project.getWeaponFlagNumByLevel(t.weaponid);
|
|
let item = this.ui_notHaveLayout.children[i]
|
|
item.getChildByName('lb_level').getComponent(Label).string = `Lv.${level}`
|
|
if (level >= this.maxLevel) {
|
|
item.getChildByName('progress').getComponent(Sprite).fillRange = 1
|
|
item.getChildByName('lb_progress').getComponent(Label).string = gg.lang.get('已满级')//'已满级'
|
|
} else {
|
|
item.getChildByName('lb_progress').getComponent(Label).string = `${weaponSPNum}/${needNum}`
|
|
if (item.getChildByName('progress').getComponent(Sprite)) {
|
|
item.getChildByName('progress').getComponent(Sprite).fillRange = weaponSPNum / needNum
|
|
}
|
|
|
|
}
|
|
if (isPlayAnim) {
|
|
item.scale = v3(0.1, 0.1, 0.1)
|
|
tween(item)
|
|
.delay(i * 0.02)
|
|
.to(0.3, { scale: v3(1, 1, 1) }, { easing: 'elasticOut' })
|
|
.start()
|
|
}
|
|
}
|
|
|
|
|
|
//let item = this.ui_notHaveLayout.children[i]
|
|
|
|
|
|
}
|
|
}
|
|
if (this.ui_haveLayout.children.length > 0) {
|
|
//item播放动画
|
|
|
|
for (let i3 = 0; i3 < this.ui_haveLayout.children.length; i3++) {
|
|
let item = this.ui_haveLayout.children[i3]
|
|
let t = this.haveArr[i3]
|
|
let conf = gg.data.project.getWeaponData(t.weaponid);
|
|
let weaponSPNum = gg.data.getItemNum(conf.scrapId);
|
|
let needNum = gg.data.project.getWeaponFlagNumByLevel(t.weaponid);
|
|
let level = gg.data.project.getWeaponLevel(t.weaponid);
|
|
item.getChildByName('lb_level').getComponent(Label).string = `Lv.${level}`
|
|
|
|
if (needNum && needNum == -1) {
|
|
item.getChildByName('progress').getComponent(Sprite).fillRange = 1
|
|
item.getChildByName('lb_progress').getComponent(Label).string = gg.lang.get('已满级')//'已满级'
|
|
item.getChildByName('红点').active = false
|
|
item.getChildByName('碎片').active = true
|
|
} else {
|
|
item.getChildByName('lb_progress').getComponent(Label).string = `${weaponSPNum}/${needNum}`
|
|
if (item.getChildByName('progress').getComponent(Sprite)) {
|
|
item.getChildByName('progress').getComponent(Sprite).fillRange = weaponSPNum / needNum
|
|
}
|
|
if (weaponSPNum >= needNum) {
|
|
item.getChildByName('红点').active = true
|
|
item.getChildByName('碎片').active = false
|
|
} else {
|
|
item.getChildByName('红点').active = false
|
|
item.getChildByName('碎片').active = true
|
|
}
|
|
}
|
|
|
|
if (isPlayAnim && item) {
|
|
item.scale = v3(0.1, 0.1, 0.1)
|
|
tween(item)
|
|
.delay(i3 * 0.02)
|
|
.to(0.3, { scale: v3(1, 1, 1) }, { easing: 'elasticOut' })
|
|
.start()
|
|
}
|
|
}
|
|
}
|
|
if (this.ui_equippedLayout.children.length > 0) {
|
|
//item播放动画
|
|
for (let i2 = 0; i2 < this.equippedArr.length; i2++) {
|
|
let t = this.equippedArr[i2]
|
|
if (t) {
|
|
let conf = gg.data.project.getWeaponData(t.weaponid);
|
|
let weaponSPNum = gg.data.getItemNum(conf.scrapId);
|
|
let needNum = gg.data.project.getWeaponFlagNumByLevel(t.weaponid);
|
|
let pos = gg.data.project.isWeaponEquipped(t.weaponid);
|
|
let item = this.ui_equippedLayout.children[pos];
|
|
let level = gg.data.project.getWeaponLevel(t.weaponid);
|
|
if (item && item.children.length > 0) {
|
|
item.children[0].getChildByName('lb_level').getComponent(Label).string = `Lv.${level}`
|
|
if (level >= this.maxLevel) {
|
|
|
|
item.children[0].getChildByName('progress').getComponent(Sprite).fillRange = 1
|
|
item.children[0].getChildByName('lb_progress').getComponent(Label).string = gg.lang.get('已满级')//'已满级'
|
|
item.children[0].getChildByName('红点').active = false
|
|
item.children[0].getChildByName('碎片').active = true
|
|
} else {
|
|
item.children[0].getChildByName('lb_progress').getComponent(Label).string = `${weaponSPNum}/${needNum}`
|
|
if (item.children[0].getChildByName('progress').getComponent(Sprite)) {
|
|
item.children[0].getChildByName('progress').getComponent(Sprite).fillRange = weaponSPNum / needNum
|
|
}
|
|
|
|
}
|
|
if (weaponSPNum >= needNum) {
|
|
item.children[0].getChildByName('红点').active = true
|
|
item.children[0].getChildByName('碎片').active = false
|
|
} else {
|
|
item.children[0].getChildByName('红点').active = false
|
|
item.children[0].getChildByName('碎片').active = true
|
|
}
|
|
|
|
|
|
}
|
|
if (isPlayAnim && item && item.children.length > 0) {
|
|
item.children[0].scale = v3(0.1, 0.1, 0.1)
|
|
tween(item.children[0])
|
|
.delay(i2 * 0.02)
|
|
.to(0.3, { scale: v3(1, 1, 1) }, { easing: 'elasticOut' })
|
|
.start()
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onInit(): void {
|
|
|
|
// if (this.firtInGame) {
|
|
// this.refreshView()
|
|
// }
|
|
// if (!this.firtInGame) {
|
|
// this.firtInGame = true
|
|
// }
|
|
|
|
this.scheduleOnce(() => {
|
|
this.showGuide()
|
|
|
|
}, 0.1)
|
|
|
|
this.refreshView()
|
|
}
|
|
/**刷新界面 */
|
|
refreshView() {
|
|
|
|
this.initData()
|
|
this.initView()
|
|
}
|
|
/**刷新数据 */
|
|
initData() {
|
|
this.maxLevel = gg.data.table.getConst(ConstEnum.WeaponMaxLevel);
|
|
this.weaponTypeList = gg.data.project.getWeaponDataList();
|
|
this.noHaveArr = gg.data.project.getNoHaveWeaponDataList()
|
|
let haveList = gg.data.project.getHaveWeaponDataList()
|
|
this.equippedArr = gg.data.project.getEquippedWeaponDataList()
|
|
this.haveArr = haveList.filter(x => this.equippedArr.find(y => y.weaponid == x.weaponid) == null);
|
|
}
|
|
/**刷新界面 */
|
|
initView() {
|
|
this.refreshNoHaveView()
|
|
this.refreshHaveView()
|
|
this.refreshEquippedView()
|
|
}
|
|
/**刷新未拥有 */
|
|
refreshNoHaveView() {
|
|
this.ui_notHaveLayout.destroyAllChildren()
|
|
for (let i = 0; i < this.noHaveArr.length; i++) {
|
|
this.initSingleItem(this.noHaveArr[i], this.ui_notHaveLayout, 0.02 * i)
|
|
}
|
|
if(this.noHaveArr.length > 0){
|
|
this.ui_notHaveLayout.active = true;
|
|
}else{
|
|
this.ui_notHaveLayout.active = false;
|
|
}
|
|
}
|
|
/**刷新已拥有 */
|
|
refreshHaveView() {
|
|
this.ui_haveLayout.destroyAllChildren()
|
|
for (let i = 0; i < this.haveArr.length; i++) {
|
|
this.initSingleItem(this.haveArr[i], this.ui_haveLayout, 0.02 * i)
|
|
}
|
|
if(this.haveArr.length > 0){
|
|
this.ui_haveLayout.active = true;
|
|
}else{
|
|
this.ui_haveLayout.active = false;
|
|
}
|
|
}
|
|
/**刷新已装备 */
|
|
refreshEquippedView() {
|
|
for (let i = 0; i < this.equipPosAccount; i++) {
|
|
this.ui_equippedLayout.children[i].destroyAllChildren()
|
|
}
|
|
for (let i = 0; i < this.equippedArr.length; i++) {
|
|
let t = this.equippedArr[i]
|
|
let pos = gg.data.project.isWeaponEquipped(t.weaponid);
|
|
if (this.ui_equippedLayout.children[pos]) {
|
|
this.initSingleItem(this.equippedArr[i], this.ui_equippedLayout.children[pos], 0.02 * i, true, true)
|
|
}
|
|
}
|
|
}
|
|
/**生成单个卡片 */
|
|
initSingleItem(weaponDdata: ITableWeapon2, parent, delaytime, canClick = true, isShowSpecialKuang = false) {
|
|
|
|
let level = gg.data.project.getWeaponLevel(weaponDdata.weaponid);
|
|
let item = instantiate(this.ui_singleItem)
|
|
//增加动画
|
|
item.scale = v3(0.1, 0.1, 0.1)
|
|
tween(item)
|
|
.delay(delaytime)
|
|
.to(0.3, { scale: v3(1, 1, 1) }, { easing: 'elasticOut' })
|
|
.start()
|
|
item.active = true
|
|
item.parent = parent
|
|
let config = this.weaponTypeList.find(x => x.weaponid == weaponDdata.weaponid)
|
|
// console.log('config==', config.name)
|
|
// console.log('weaponDdata==', JSON.stringify(weaponDdata));
|
|
let itemData = gg.data.table.getItemData(config.itemID)
|
|
|
|
if (config.quality == 3) {
|
|
item.getChildByName('紫色').active = true
|
|
item.getChildByName('橙色').active = false
|
|
} else if (config.quality == 4) {
|
|
item.getChildByName('紫色').active = false
|
|
item.getChildByName('橙色').active = true
|
|
} else {
|
|
item.getChildByName('紫色').active = false
|
|
item.getChildByName('橙色').active = false
|
|
}
|
|
item.getChildByName('itemSpr').getComponent(SpriteLoad).setSprite(GPath.WeaponBottom(`颜色${config.quality}`), GBundle.Weapon);
|
|
item.getChildByName('iconSpr').getComponent(SpriteLoad).setSprite(GPath.Item(itemData.icon), GBundle.Items);
|
|
item.getChildByName('lb_name').getComponent(Label).string = gg.lang.get(config.name)
|
|
item.getChildByName('lb_level').getComponent(Label).string = `Lv.${level}`
|
|
item.getChildByName('锁定框2').active = weaponDdata.weaponid == 1
|
|
let weaponSPNum = gg.data.getItemNum(weaponDdata.scrapId);
|
|
let needNum = gg.data.project.getWeaponFlagNumByLevel(weaponDdata.weaponid)
|
|
item.getChildByName('碎片').active = true
|
|
if (level >= this.maxLevel) {
|
|
item.getChildByName('progress').getComponent(Sprite).fillRange = 1
|
|
item.getChildByName('lb_progress').getComponent(Label).string = gg.lang.get('已满级')//'已满级'
|
|
item.getChildByName('红点').active = false
|
|
item.getChildByName('碎片').active = true
|
|
} else {
|
|
item.getChildByName('lb_progress').getComponent(Label).string = `${weaponSPNum}/${needNum}`
|
|
if (item.getChildByName('progress').getComponent(Sprite)) {
|
|
item.getChildByName('progress').getComponent(Sprite).fillRange = weaponSPNum / needNum
|
|
}
|
|
if (weaponSPNum >= needNum && (gg.data.project.isWeaponUnlocked(weaponDdata.weaponid) || gg.data.project.isWeaponEquipped(weaponDdata.weaponid) >= 0)) {
|
|
item.getChildByName('红点').active = true
|
|
item.getChildByName('碎片').active = false
|
|
} else {
|
|
item.getChildByName('红点').active = false
|
|
item.getChildByName('碎片').active = true
|
|
}
|
|
}
|
|
|
|
item.getChildByName('锁定遮罩').active = gg.data.project.isWeaponUnlocked(weaponDdata.weaponid) == false;
|
|
if (canClick) {
|
|
item.attr({ bindId: config.weaponid })
|
|
item.on(Node.EventType.TOUCH_END, this.clickSingleItem, this);
|
|
}
|
|
if (item.getChildByName('锁定遮罩').active) {
|
|
item.getChildByName('lb_level').active = false
|
|
item.getChildByName('进度条框').active = false
|
|
item.getChildByName('progress').active = false
|
|
item.getChildByName('碎片').active = false
|
|
item.getChildByName('lb_progress').active = false
|
|
let descLab = item.getChildByName('锁定遮罩').getChildByName('descLab').getComponent(Label)
|
|
item.getChildByName('锁定遮罩').getChildByName('进度条框').active = false
|
|
|
|
|
|
|
|
//解锁条件替换读表格数据
|
|
if(weaponDdata.unlockdesc!=""){
|
|
descLab.string = gg.lang.get(weaponDdata.unlockdesc);
|
|
//橙武增加碎片显示
|
|
if(config.quality == 4 && config.weaponid != 16){
|
|
|
|
item.getChildByName('锁定遮罩').getChildByName('进度条框').active = true
|
|
let progress = find('进度条框/progress',item.getChildByName('锁定遮罩') )
|
|
|
|
let frag = gg.data.getItemNum(config.scrapId);
|
|
progress.getComponent(Sprite).fillRange = frag/3
|
|
descLab.string += `${gg.lang.get('碎片')}${frag}/3`
|
|
}
|
|
}
|
|
} else {
|
|
item.getChildByName('lb_level').active = true
|
|
item.getChildByName('进度条框').active = true
|
|
item.getChildByName('progress').active = true
|
|
// item.getChildByName('碎片').active = true
|
|
item.getChildByName('lb_progress').active = true
|
|
}
|
|
}
|
|
/**点击卡片 */
|
|
clickSingleItem(e, d) {
|
|
let id = e.target.bindId
|
|
if (this.isExchangeCard) {
|
|
//正在交换卡片
|
|
|
|
if ((!sdkConfig.isIAPVersion && id == 1) || (sdkConfig.isIAPVersion && !gg.purchase.isCanUninstallRainbowBullet()) && id == 1) {
|
|
gg.ui.showToast("该武器不能卸下");
|
|
return
|
|
}
|
|
|
|
let pos = gg.data.project.isWeaponEquipped(id);
|
|
if (pos >= 0) {
|
|
gg.data.project.equipWeapon(this.changeData.weaponid, pos);
|
|
gg.targetTaskManager.statisticalData(TargetTaskType.weaponInTeam, 1)
|
|
this.hideExchangeCard();
|
|
this.refreshView();
|
|
gg.data.saveToServer();
|
|
}
|
|
} else {
|
|
//正常打开卡片
|
|
gg.ui.openPanel(UIID.WeaponLevelUp, { data: [id] });
|
|
}
|
|
}
|
|
/**
|
|
* 武器移除
|
|
* @param weaponid 武器id
|
|
*/
|
|
weaponRemove(weaponid: number) {
|
|
let pos = gg.data.project.isWeaponEquipped(weaponid);
|
|
gg.data.project.unequipWeapon(pos);
|
|
this.refreshView();
|
|
}
|
|
/**
|
|
* 武器使用
|
|
* @param weaponid 武器id
|
|
*/
|
|
weaponUse(weaponid: number) {
|
|
//是否还有空位
|
|
let pos = gg.data.project.getEmptyPos();
|
|
if (pos >= 0) {
|
|
//有空位,将武器放入空位
|
|
gg.data.project.equipWeapon(weaponid, pos);
|
|
this.refreshView()
|
|
gg.targetTaskManager.statisticalData(TargetTaskType.weaponInTeam, 1)
|
|
} else {
|
|
//无空位
|
|
let data = gg.data.project.getWeaponData(weaponid);
|
|
this.showExchangeCard(data);
|
|
}
|
|
}
|
|
/**
|
|
* 展示交换卡片
|
|
* @param t 武器本地数据
|
|
*/
|
|
showExchangeCard(data: ITableWeapon2) {
|
|
this.changeData = data
|
|
this.isExchangeCard = true
|
|
this.ui_scrollView.active = false
|
|
this.ui_changeCardNode.active = true
|
|
//生成卡片
|
|
let parent = this.ui_changeCardNode.getChildByName('item_0')
|
|
parent.destroyAllChildren()
|
|
this.initSingleItem(data, parent, 0.02, false)
|
|
|
|
if (this.ui_equippedLayout.children.length > 0) {
|
|
//item播放动画
|
|
for (let i = 0; i < this.ui_equippedLayout.children.length; i++) {
|
|
let item = this.ui_equippedLayout.children[i]
|
|
let node = item.children[0]
|
|
//呼吸效果
|
|
//先停止所有动画
|
|
Tween.stopAllByTarget(node)
|
|
tween(node)
|
|
.to(1, { scale: v3(0.96, 0.96, 0.96) })
|
|
.to(1, { scale: Vec3.ONE })
|
|
.union()
|
|
.repeatForever()
|
|
.start()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
/**隐藏交换卡片 */
|
|
hideExchangeCard() {
|
|
this.isExchangeCard = false
|
|
this.ui_scrollView.active = true
|
|
this.ui_changeCardNode.active = false
|
|
//呼吸动画
|
|
if (this.ui_equippedLayout.children.length > 0) {
|
|
//item播放动画
|
|
for (let i = 0; i < this.ui_equippedLayout.children.length; i++) {
|
|
let item = this.ui_equippedLayout.children[i]
|
|
let node = item.children[0]
|
|
//呼吸效果
|
|
//先停止所有动画
|
|
Tween.stopAllByTarget(node)
|
|
node.scale = Vec3.ONE
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
click_btnSuiPian() {
|
|
gg.ui.openPanel(UIID.WeaponSuiPian)
|
|
}
|
|
/**取消交换卡片 */
|
|
click_btnCancelExchange() {
|
|
this.hideExchangeCard()
|
|
}
|
|
|
|
click_btnweaponsui() {
|
|
gg.ui.openPanel(UIID.WeaponSuiPian)
|
|
}
|
|
}
|
|
|