123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- import { GameViewType } from "../../../main/ViewManage";
- import ViewObject from "../../../main/ViewObject";
- import RedPoint from "../../data/RedPoint";
- import Equip from "../../home/equip/Equip";
- import SetLeader from "../../home/equip/SetLeader";
- import FPanel from "./FPanel";
- /**
- * 头像
- */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class FPanelIcon extends FPanel {
- @property(cc.Sprite)
- mIcon: cc.Sprite = null;
- @property(cc.Node)
- mIconX: cc.Node = null;
- @property(cc.Node)
- mLeader: cc.Node = null;//队长标识
- public inGuide = false//当前是否处于引导中
- public guideStep: number = 0;
- /**
- * 引导中的点击回调
- */
- private guideCallback: () => void
- onLoad() {
- this.mIconX.active = false;
- }
- public setGuideCallback(guideCallback: () => void) {
- this.guideCallback = guideCallback
- }
- /**
- * 更新当前面板
- */
- public updatePanel() {
- if (this.sprite) {
- this.mHPBar.progress = this.sprite.hp / this.sprite.attrData.hp;
- if (this.mLabel) {
- this.mLabel.string = this.sprite.hp + '/' + this.sprite.attrData.hp;
- }
- if (this.sprite.hp <= 0) {
- this.mIconX.active = true;
- } else {
- this.mIconX.active = false;
- }
- }
- }
- public setCancel() {
- }
- public setClose() {
- }
- /**
- * 设置头像
- */
- public setIcon() {
- let ffAttr = this.sprite.attrData
- let headIcon = ffAttr.skin
- if (headIcon == '30000') {
- headIcon = '' + ffAttr.id
- }
- cc.resources.load('icon/role_head/' + headIcon, cc.SpriteFrame, (err, spriteFrame: cc.SpriteFrame) => {
- if (err) {
- cc.error(err);
- } else {
- this.mIcon.spriteFrame = spriteFrame;
- }
- });
- let main = this.sprite.ff.main
- let player = main.player
- if (this.sprite.attrData.id == player.role.leader) {
- this.mLeader.active = true;
- } else {
- this.mLeader.active = false;
- }
- }
- public onclick() {
- let res = this.sprite.map.ff.fres
- let nodes = res.mHudNode.children
- for (let i = 0; i < nodes.length; i++) {
- const element = nodes[i];
- RedPoint.removeRed(element)
- }
- let main = this.sprite.map.ff.main
- this.sprite.ff.pauseSprite(true)
- main.viewManage.loadFunc(GameViewType.equip, (viewObject: ViewObject) => {
- viewObject.show();
- let topNode = this.sprite.ff.main.topNode;
- topNode.active = true;
- let equip: Equip = viewObject as Equip
- equip.inGuide = this.inGuide
- equip.guideStep = this.guideStep;
- this.inGuide = false
- equip.openId = this.sprite.attrData.id
- let setLeader = equip.node.getComponent(SetLeader)
- setLeader.mSetButton.active = false
- equip.setCloseCallback(() => {
- if (this.sprite.isValid && this.sprite.ff.isValid) {
- this.sprite.ff.pauseSprite(false)
- this.sprite.map.ff.updateRole()
- }
- topNode.active = false;
- })
- });
- if (this.guideCallback) {
- this.guideCallback()
- }
- }
- }
|