消消方块阵换皮表情
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.
 
 
 

376 lines
14 KiB

//*********************
// create by 流云
// time: Wed Sep 10 2025
// desc:
//*********************
import { _decorator, Component, Node, find, Label, instantiate, RichText, Sprite } from 'cc';
import { Auto_WeaponLevelUp } from './Auto_WeaponLevelUp';
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 { SkillDataManager } from '../../manager/SkillDataManager';
import { StatisticsType, TaskType } from '../../game/GameData';
import MTools from 'db://assets/mx/tools/MTools';
import { ConstEnum } from '../../manager/ConstManager';
import { sdkConfig } from '../../sdk/sdkConfig';
import { TargetTaskType } from '../../manager/TargetTaskManager';
const { ccclass, property } = _decorator;
@ccclass('UIWeaponLevelUp')
export class UIWeaponLevelUp extends Auto_WeaponLevelUp {
//武器id
weaponId: number = 0
//武器等级
weaponLevel: number = 1
//装备状态 0未拥有1已拥有2已装备
equippedStatus: number = 0
//在装备区的位置
equippedPos: number = -1
weaponSPNum: number = 0;
needNum: number = 0;
maxLevel = 50
isCloselayer = false
onLoad(): void {
super.onLoad();
}
onEnable(): void {
super.onEnable();
}
onDisable(): void {
super.onDisable();
}
onInit(): void {
this.showOpenCenterEff();
this.showOpenMaskEff(2);
this.weaponId = this.prema[0]
this.refreshView()
this.scheduleOnce(() => {
this.showGuide()
}, 0.3)
this.scheduleOnce(() => {
this.isCloselayer = true
}, 0.5)
}
showGuide() {
if (gg.data.getStatistics(StatisticsType.homeGuideIndex) == 3) {
let toggle = this.node.getChildByName('guideNode')
gg.ui.openPanel(UIID.NewGuideMask, {
data: [
[toggle],
[gg.lang.get('升级武器会增加基础属性,达到特定等级会解锁新技能')],
() => {
this.scheduleOnce(() => {
//点击升级
this.close()
//引导点击战斗
GEvent.Ins.emit(GEvent.homeGuideIndexEvent, 3)
}, 0.03)
},
true,
255
]
})
}
}
showLiulianGuide(){
if(gg.data.getStatistics(StatisticsType.LiulianGuideIndex) == 3){
gg.sdk.reportDY("inLevel", `章节1_5-引导点击使用`);
let toggle = this.node.getChildByName('guideNode2')
gg.ui.openPanel(UIID.NewGuideMask, {
data: [
[toggle],
[gg.lang.get('点击上阵榴莲')],
() => {
//引导替换武器
gg.data.setStatistics(StatisticsType.LiulianGuideIndex, 4)
setTimeout(()=>{
GEvent.Ins.emit(GEvent.LiulianGuideIndexEvent)
},50)
},
true,
255
]
})
}
}
/**刷新界面 */
refreshView() {
let conf = gg.data.project.getWeaponData(this.weaponId);
this.weaponLevel = gg.data.project.getWeaponLevel(this.weaponId);
this.weaponSPNum = gg.data.getItemNum(conf.scrapId); //已经拥有的碎片
this.needNum = gg.data.project.getWeaponFlagNumByLevel(this.weaponId)//需要的碎片升级
let maxLevel = gg.data.table.getConst(ConstEnum.WeaponMaxLevel);
this.maxLevel = maxLevel;
this.showProperty()
this.showSkillInfo()
}
/**显示属性 */
showProperty() {
let config: ITableWeapon2 = gg.data.project.getWeaponData(this.weaponId);
let itemData = gg.data.table.getItemData(config.itemID)
let levelPara = gg.data.project.getLevelParaByWeaponLevel(this.weaponLevel, this.weaponId)
this.lb_weaponName.string = gg.lang.get(config.name)
if (config.weapon_para) {
//攻击力
this.ui_center.getChildByName('生命值').active = false
this.lb_health.node.active = false
this.ui_center.getChildByName('攻击').active = true
this.lb_att.node.active = true
let attack = gg.data.getPlayerAtkCoefficient()
let allAttack = Math.floor(config.weapon_para * attack * levelPara)
this.lb_att.string = `${allAttack.toFixed(0)}`
}
if (config.weapon_para) {
//生命值
this.ui_center.getChildByName('攻击').active = false
this.lb_att.node.active = false
this.ui_center.getChildByName('生命值').active = true
this.lb_health.node.active = true
let attack = gg.data.getPlayerAtkCoefficient()
let allHealth = Math.floor(config.weapon_para * attack * levelPara)
this.lb_health.string = `${allHealth.toFixed(0)}`
}
//名称
this.lb_weaponName.string = gg.lang.get(config.name)
//冷却
let cdNum = gg.data.getPlayerCoolCoefficient()
// 这里不能先 floor,<1s 的 CD 会被截断成 0(显示 0.0s)
let jisuanCd = config.cd / (1 + cdNum / 10000)
this.lb_cd.string = `${jisuanCd.toFixed(1)}` + 's'
//射程
this.lb_dis.string = `${config.range}`
//icon信息
this.ui_iconInfo.getChildByName('itemSpr').getComponent(SpriteLoad).setSprite(GPath.WeaponLevelUp(`物品底${config.quality}`), GBundle.WeaponLevelUp);
this.ui_iconInfo.getChildByName('iconSpr').getComponent(SpriteLoad).setSprite(GPath.Item(itemData.icon), GBundle.Items);
this.ui_iconInfo.getChildByName('lb_level').getComponent(Label).string = `Lv.${this.weaponLevel}`
//this.curLevelLab.string = `LV.${this.weaponLevel} >> LV.${this.weaponLevel+1}`
this.lb_curLevel1.string = this.weaponLevel + ''
this.lb_curLevel2.string = (this.weaponLevel + 1) + ''
if (this.weaponLevel >= this.maxLevel) {
this.ui_iconInfo.getChildByName('lb_progress').getComponent(Label).string = gg.lang.get('已满级')
this.ui_iconInfo.getChildByName('progress').getComponent(Sprite).fillRange = 1
//this.curLevelLab.string = '已满级'
this.ui_dengjikuang.active = false
} else {
this.ui_iconInfo.getChildByName('lb_progress').getComponent(Label).string = `${this.weaponSPNum}/${this.needNum}`
this.ui_iconInfo.getChildByName('progress').getComponent(Sprite).fillRange = this.weaponSPNum / this.needNum
}
//按钮状态
let isflagNum = this.needNum <= this.weaponSPNum //碎片数满足
let isMax = this.weaponLevel >= this.maxLevel //是否满级
if (!gg.data.project.isWeaponUnlocked(this.weaponId)) {
//未拥有
this.btnLevelUp.active = false
this.btnLevelUpNo.active = false
this.btnUse.active = false
this.btnRemove.active = false
} else {
//已拥有
if (!isMax) {
this.btnLevelUp.active = isflagNum && this.weaponLevel < this.maxLevel
this.btnLevelUpNo.active = !this.btnLevelUp.active
} else {
this.btnLevelUp.active = false
this.btnLevelUpNo.active = false
this.btnLevelUpMax.active = true
}
this.btnUse.active = true
this.btnRemove.active = false
}
if (gg.data.project.isWeaponEquipped(this.weaponId) >= 0) {
//已装备
if (!isMax) {
this.btnLevelUp.active = isflagNum && this.weaponLevel < this.maxLevel
this.btnLevelUpNo.active = !this.btnLevelUp.active
} else {
this.btnLevelUp.active = false
this.btnLevelUpNo.active = false
this.btnLevelUpMax.active = true
}
this.btnUse.active = false
this.btnRemove.active = true
}
}
/**显示技能条 */
showSkillInfo() {
this.ui_content.destroyAllChildren()
let data: ITableWeapon2 = gg.data.project.getWeaponData(this.weaponId)
this.initSingleItem(data);
}
/**生成单个技能卡片 */
initSingleItem(weaponConfig: ITableWeapon2) {
//有解锁技能
//技能特殊技能skill 1,52;2,48;2,49;2,50;3,53;4,54;5,55;6,56
//等级this.weaponLevel < skill[i][0]
let skill = MTools.deepClone(weaponConfig.skill.split(';'))
//
let newSkill = []
//例如skill == 1,52;2,48;2,49;2,50;3,53;4,54;5,55;6,56, skill_des == 2,51, 合并为 1,52;2,51;3,53;4,54;5,55;6,56 合并新数组
if (weaponConfig.skill_des != '') {
let skill_des = MTools.deepClone(weaponConfig.skill_des.split(';'))
for (let i = 0; i < skill_des.length; i++) {
newSkill.push(skill_des[i])
}
for (let i = 0; i < skill.length; i++) {
let findItem = false
for (let j = 0; j < newSkill.length; j++) {
let skillItem = newSkill[j].split(',')
if (skillItem[0] == skill[i].split(',')[0]) {
findItem = true
break
}
}
if (!findItem) {
newSkill.push(skill[i])
}
}
// ['2,51', '1,52', '3,53', '4,54', '5,55', '6,56']
//根据前面的id排序
newSkill.sort((a, b) => {
let aItem = a.split(',')
let bItem = b.split(',')
return Number(aItem[0]) - Number(bItem[0])
})
} else {
for (let i = 0; i < skill.length; i++) {
//let skillItem = skill[i].split(',')
newSkill.push(skill[i])
}
}
// console.log(newSkill)
//排序
if (newSkill.length > 0) {
let skillConfig: ITableSkill = null
for (let j = 0; j < newSkill.length; j++) {
let newSkillItem = newSkill[j].split(',')
skillConfig = SkillDataManager.getSkillDataById(newSkillItem[1])
// console.log("skillConfig",JSON.stringify(skillConfig));
let item = instantiate(this.ui_singleItem)
item.active = true
item.parent = this.ui_content
item.getChildByName('itemSpr').getComponent(SpriteLoad).setSprite(GPath.WeaponLevelUp(`技能底${skillConfig.quality}`), GBundle.WeaponLevelUp);
item.getChildByName('iconSpr').getComponent(SpriteLoad).setSprite(GPath.SkillItem(skillConfig.icon), GBundle.Items);
item.getChildByName('lb_tag').getComponent(Label).string = gg.lang.get(skillConfig.icon_desc)
if (this.weaponLevel < newSkillItem[0]) {
//等级未解锁
item.getChildByName('未解锁').active = true
item.getChildByName('等级属性框未解锁').active = true
let strlang = gg.lang.get('解锁:')
item.getChildByName('desc_richText').getComponent(RichText).string = `<b><size=20><outline color=#3D3D3D width=2><color=#2BE794>LV${newSkillItem[0]}${strlang}` + gg.lang.get(skillConfig.desc)
} else {
//等级已解锁
item.getChildByName('等级属性框未解锁').active = false
item.getChildByName('未解锁').active = false
item.getChildByName('desc_richText').getComponent(RichText).string = gg.lang.get(skillConfig.desc)
}
}
}
}
/**关闭 */
click_closeArea() {
if (!this.isCloselayer) {
return
}
gg.audio.playEffect({ name: "点击音效" });
this.close(2)
}
/**不能升级 */
click_btnLevelUpNo() {
gg.audio.playEffect({ name: "点击音效" });
if (this.weaponSPNum < this.needNum) {
this.close(2)
gg.ui.openPanel(UIID.WeaponSuiPian)
} else {
gg.ui.showToast("已达到满级!");
}
}
/**升级 */
click_btnLevelUp() {
gg.audio.playEffect({ name: "升级" });
let level = this.weaponLevel + 1 //每次升1级
//消耗碎片
if (level >= this.maxLevel) {
level = this.maxLevel
}
let conf = gg.data.project.getWeaponData(this.weaponId);
gg.data.subItemNum(conf.scrapId, this.needNum)
gg.data.addDayTaskProgressData(TaskType.weaponUpgrade, 1)
gg.data.project.setWeaponLevel(this.weaponId, level);
this.refreshView()
gg.ui.showToast("升级成功!");
gg.sdk.reportDY("inLevel", `章节${gg.data.doc.chapter}-${this.lb_weaponName.string}${level}`)
gg.sdk.reportDY("inLevel", `武器升级-${this.lb_weaponName.string}${level}`)
//更新界面
this.shengjiSpine.active = true
this.scheduleOnce(() => {
if (this.shengjiSpine.isValid) {
this.shengjiSpine.active = false
}
}, 1)
//升级统计
gg.targetTaskManager.statisticalData(TargetTaskType.upgradeAnyWeapon, 1 )
GEvent.Ins.emit(GEvent.WeaponLevelUp, this.weaponId)
}
/**使用 */
click_btnUse() {
gg.audio.playEffect({ name: "点击音效" });
GEvent.Ins.emit(GEvent.WeaponUse, this.weaponId)
this.close(2)
}
/**移除 */
click_btnRemove() {
gg.audio.playEffect({ name: "点击音效" });
//彩虹飞弹不能移除
if ((!sdkConfig.isIAPVersion && this.weaponId == 1) || (sdkConfig.isIAPVersion && !gg.purchase.isCanUninstallRainbowBullet()) && this.weaponId == 1) {
gg.ui.showToast("该武器不能卸下");
return
}
GEvent.Ins.emit(GEvent.WeaponRemove, this.weaponId)
this.close(2)
}
}