123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import { Animation, Button, SpriteFrame, Tween, tween, Vec3, _decorator } from 'cc';
- import { NodeEx } from '../../framework/pool/NodeEx';
- import { StringUtil } from '../../framework/util/StringUtil';
- import { GameConf } from '../data/GameConf';
- const { ccclass, property } = _decorator;
- @ccclass('PropNode')
- export class PropNode extends NodeEx {
- private callBack: Function = null
- private itemData: any = null
- private propType = null
- private originData: any = null
- /**
- * 初始化道具
- * @param propInfo
- * @param type 1-载具
- */
- init(propInfo: any) {
- this.originData = propInfo
- //普通道具
- this.initIconItemRes(1)
- }
- /**
- * 初始化道具sprite
- * @param iconId
- * @param type 根据类型 判读路径 1 载具 如果空则为通用道具 2 包裹图片
- */
- private initIconItemRes(iconId: number, quality?: number) {
- let path = `texture/common/equip/${iconId}/SpriteFrame`
- this.load("package", path, SpriteFrame, (res: SpriteFrame) => {
- this.Sprite.item.spriteFrame = res
- })
- }
- public setCallBack(cb: Function) {
- this.callBack = cb
- }
- public setCount(count: number) {
- this.Label.count.node.active = true
- if (count > 1) {
- this.Label.count.string = `${count}`
- } else {
- this.Label.count.node.active = false
- }
- }
- // 设置品级
- public showQuality(isShow: boolean, path?: string) {
- this.Sprite.quality.node.active = isShow
- if (isShow) {
- this.load("package", path, SpriteFrame, (sp: SpriteFrame) => {
- this.Sprite.quality.spriteFrame = sp
- })
- }
- }
- public showSelect(isShow: boolean, path?: string) {
- this.Sprite.select.node.active = isShow
- if (isShow) {
- this.load("package", path, SpriteFrame, (sp: SpriteFrame) => {
- this.Sprite.select.spriteFrame = sp
- })
- }
- }
- public getCountLable() {
- return this.Label.count
- }
- // 点击
- public onClickBtn(resulut?: boolean) {
- }
- public setSwallowTouches(isTouch: boolean) {
- this.Sprite.item.getComponent(Button).enabled = isTouch
- }
- //如果使用了池中的节点,在该函数内归还,该函数会在onDestroy前调用
- onClose() {
- }
- // public setItemData(data: GameConf.ItemData) {
- // this.itemData = data
- // this.initIconItemRes(this.itemData.id)
- // }
- public getItemData() {
- return this.itemData
- }
- public getPropType() {
- return this.propType
- }
- public getOriginData() {
- return this.originData
- }
- public getIsPackage() {
- if (this.originData.id >= 1065 && this.originData.id <= 1070) {
- return true
- } else {
- return false
- }
- }
- }
|