| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import { _decorator, Component, Label, Sprite, Animation, SpriteFrame, Color, color } from "cc";
- import { DataSystem } from "../../core/data/DataSystem";
- import { ResourceLoader } from "../../core/resourceManager/ResourceLoader";
- import { ConfigData } from "../../data/ConfigData";
- import { Formation } from "./Formation";
- import { FormationData } from "./FormationData";
- const { ccclass, property, requireComponent } = _decorator;
- /**
- * 八卦信息
- * @author 袁浩
- */
- @ccclass('BaguaItem')
- @requireComponent(ResourceLoader)
- export class BaguaItem extends Component {
- @property({ tooltip: "八卦图标", type: Sprite })
- public baguaIcon: Sprite;
- @property({ tooltip: "八卦动画", type: Animation })
- public baguaAni: Animation;
- @property({ tooltip: "太极动画", type: Animation })
- public taiji: Animation;
- @property({ tooltip: "描述文本", type: Label })
- public desLabel: Label;
- @property({ tooltip: "攻击加成文本", type: Label })
- public attackLabel: Label;
- @property({ tooltip: "暴击加成文本", type: Label })
- public criLabel: Label;
- @property({ tooltip: "未激活文本颜色", type: Color })
- public noActiveColor: Color = color(255, 255, 255, 255);
- start() {
- }
- /**
- * 当列表项渲染
- * @param item 项节点
- * @param index 项索引
- */
- public async onDataChange(data: any) {
- let buffConfig = DataSystem.getData(ConfigData).get("buff");
- let buffList = data.activeBuff.split(",");
- let attackPer = 0;
- let cri = 0;
- for (let i = 0; i < buffList.length; i++) {
- attackPer += (buffConfig[buffList[i]].attackPer || 0);
- cri += (buffConfig[buffList[i]].cri || 0);
- }
- this.taiji.node.active = this.baguaAni.node.active = data.isActive;
- this.desLabel.string = data.des;
- this.attackLabel.string = `+${attackPer / 100}%`;
- this.criLabel.string = `+${cri / 100}%`;
- if (!data.isActive) {
- this.desLabel.color = this.criLabel.color = this.attackLabel.color = this.noActiveColor;
- }
- this.baguaIcon.spriteFrame = await this.getComponent(ResourceLoader).load(`images/general/texture/${data.icon}/spriteFrame`, SpriteFrame);
- this.baguaIcon.grayscale = !data.isActive;
- }
- }
|