import i18n from "../../../i18n/i18n"; import { GameViewType } from "../../../main/ViewManage"; import ViewObject from "../../../main/ViewObject"; import RadarChart,{RadarChartData} from "../../../util/RadarChart"; import FFCalAttr from "../../data/FFCalAttr"; import CardStarView from "./CardStarView"; import CardItem from "./item/CardItem"; /** * 神卡说明 */ const { ccclass, property } = cc._decorator; @ccclass export default class CardInfoView extends ViewObject { @property(CardItem) mCardItem: CardItem = null; @property(RadarChart) radarChart: RadarChart = null; @property(cc.Label) mAttrLable: cc.Label = null; @property([cc.Label]) mAttrValue: Array = []; public cardItem:CardItem public onLoad(){ this.flushRadarChart() } public exitDistroy(){ super.exitDistroy() this.cardItem.flushStar() } public init(cardItem:CardItem){ this.cardItem = cardItem } /** * 更新雷达图 */ public flushRadarChart(){ this.mCardItem.init(this.main,this.cardItem.godCardAttr) let fAttr = FFCalAttr.getGodCardAttr(this.main,this.cardItem.godCardAttr) let v1 = fAttr.thunder let v2 = fAttr.earth let v3 = fAttr.fire let v4 = fAttr.water let v5 = fAttr.wind if(v1 > 100){ v1 = 100 } if(v2 > 100){ v2 = 100 } if(v3 > 100){ v3 = 100 } if(v4 > 100){ v4 = 100 } if(v5 > 100){ v5 = 100 } let attrData = [v1,v2,v3,v4,v5] let values = [v1/100,v2/100,v3/100,v4/100,v5/100] for (let i = 0; i < attrData.length; i++) { const element = attrData[i]; this.mAttrValue[i].string = ''+element } let data:RadarChartData = { values:values } this.radarChart.draw(data) let job = ['','射手','法师','战士'] let _godCard = this.cardItem._godCard let jobStr = job[_godCard.job] let lableStr = '' if(fAttr.atk > 0){ lableStr += i18n.t(jobStr)+i18n.t('攻击')+'+'+fAttr.atk + '\n' } if(fAttr.def > 0){ lableStr += i18n.t(jobStr)+i18n.t('防御')+'+'+fAttr.def + '\n' } if(fAttr.hp > 0){ lableStr += i18n.t(jobStr)+i18n.t('气血')+'+'+fAttr.hp + '\n' } if(fAttr.sp > 0){ lableStr += i18n.t(jobStr)+i18n.t('敏捷')+'+'+fAttr.sp + '\n' } lableStr += _godCard.about this.mAttrLable.string = lableStr } /** * 神像升星 */ public openidol_sx(){ this.main.viewManage.loadFunc(GameViewType.god_card_star,(viewObject:ViewObject)=>{ let cardStarView:CardStarView = viewObject as CardStarView cardStarView.init(this) viewObject.show(this); }); } }