import { Component, _decorator } from "cc"; import { DataSystem } from "../core/data/DataSystem"; import { Http } from "../core/net/Http"; import { Hero_Client, UserHeroData } from "../hero/UserHeroData"; import { MarshalData, Skill } from "./MarshalData"; const { ccclass } = _decorator; /** * 统帅台界面 * @author 郑聂华 * @deprecated 弃用 请使用MarshalSkillSystem */ @ccclass('MarshalDataTool') export class MarshalDataTool extends Component { private marshalData: MarshalData; private get MarshalData(): MarshalData { if (!this.marshalData) this.marshalData = DataSystem.getData(MarshalData); return this.marshalData; } private set MarshalData(value: MarshalData) { this.marshalData = value; } /**更新统帅技能和通知队列数据*/ public updateNoticeQueue() { let starNum = 0; let userHeroData = DataSystem.getData(UserHeroData); for (let id of userHeroData.haveHeros) { let tempHero = userHeroData.get(id); starNum += tempHero.server.star; } let tempKeys = this.MarshalData.marshalSkillData.lvNeedStarsMap.keys(); for (let id of tempKeys) { let tempStarAry = this.MarshalData.marshalSkillData.lvNeedStarsMap.get(id); for (let i = 0; i < tempStarAry.length; i++) { if (tempStarAry[i] <= starNum) { let curLv = this.MarshalData.marshalSkillData.lvMarshalSkill.get(id); if (curLv < i + 1) { let param = { type: curLv <= 0 ? 1 : 2, id: id, lv: i + 1, lastLv: curLv }; this.MarshalData.skillNoticeQueue.push(param); this.MarshalData.skillUnlockLvUpQueue.push(param); this.MarshalData.marshalSkillData.lvMarshalSkill.set(id, i + 1); } } } } //打开技能解锁页面 通过检测skillNoticeQueue长度 自行调用最后一个数据展示弹窗 //newParam && WindowSystem.open("prefabs/ui/marshalStage/marshalSkillNotice", WindowOpenMode.NotCloseAndCover, newParam); } /** * 更新统帅技能等级数据 */ public async updateSkillLvData(http: Http) { let numStar = 0; let userHeroData = DataSystem.getData(UserHeroData); await userHeroData.pull(http); for (let id of userHeroData.haveHeros) { let tempHero = userHeroData.get(id); numStar += tempHero.server.star; } let tempKeys = this.MarshalData.marshalSkillData.lvNeedStarsMap.keys(); for (let id of tempKeys) { let tempStarAry = this.MarshalData.marshalSkillData.lvNeedStarsMap.get(id); for (let i = 0; i < tempStarAry.length; i++) { if (numStar >= tempStarAry[i]) this.MarshalData.marshalSkillData.lvMarshalSkill.set(id, i + 1); } } } /**获取技能效果值 * @param skill 技能对象 * @param lv 技能等级 */ public getSkillValue(skill: Skill, lv: number) { switch (skill.attType) { case 1: return; case 2: return; case 3: return (skill.skillValue[lv - 1]) / 10000; case 4: return; case 5: return skill.skillValue[lv - 1]; } } /**获取技能效果值字符串 * @param skill 技能对象 * @param lv 技能等级 */ public getSkillValueStr(skill: Skill, lv: number) { switch (skill.attType) { case 1: return; case 2: return; case 3: return ((skill.skillValue[lv - 1]) / 10000 * 100).toFixed(1) + "%"; case 4: return; case 5: return skill.skillValue[lv - 1] + "秒"; } } /** * 获取技能统帅加成值 * @param hero 统帅 */ getSkillAddValue(hero: Hero_Client) { return Math.pow(hero.commander / 100, 1.9); } /** * 获取技能统帅加成值字符串 * @param skill 技能 * @param lv 技能等级 * @param hero 武将 */ getSkillAddValueStr(skill: Skill, lv: number, hero: Hero_Client) { let addcommander = Math.pow(hero.commander / 100, 1.9); switch (skill.attType) { case 1: return; case 2: return; case 3: return (addcommander * skill.skillValue[lv - 1] / 10000 * 100).toFixed(1) + "%"; case 4: return; case 5: return (addcommander * skill.skillValue[lv - 1]).toFixed(1) + "秒"; } } }