// Learn cc.Class: // - https://docs.cocos.com/creator/manual/en/scripting/class.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html cc.Class({ extends: require("BaseItemConstroller"), properties: { itemName: cc.Label, itemGrade: cc.Label, itemMaster: cc.Label, sprite: cc.Sprite, mesh: cc.Node, }, // LIFE-CYCLE CALLBACKS: onLoad() { this._super(); this.init(); this.item_attached_nameArr = []; this.item_Attached_typeArr = []; this.item_attached_valueArr = []; this.item_type = this.random_num(0, 9); this.gradetype = this.random_num(0, 4); this.generate_properties(this.item_type, this.gradetype); this.mesh.on(cc.Node.EventType.TOUCH_START, function() { cc.audioEngine.playEffect(this.UiController.audioArr[0]); cc.find("Canvas/PanelResult").removeAllChildren(); if (cc.find("Canvas/Interface_Info").active) { return; } else { this.UiController.Panel_Botton.active = true; cc.find("Canvas/Interface_Against").active = true; } }, this) }, start() { cc.find("Canvas/PanelResult/interface_Box/GameBg/ProAdd").removeAllChildren(); this.box_table(); //#region // cc.loader.loadRes("texture/AvatarProps", cc.SpriteFrame, function(err, spriteFrames) { // console.log("图集:", spriteFrames); // spriteFrames.forEach(function(element) { // if (element.name === this.spriteFrame_name) { // this.sprite.getComponent(cc.Sprite).spriteFrame = element; // } // }); // }); //#endregion }, box_table() { this.itemName.string = this.item_name; //名字 //#region // if (this.item_grade < 5) this.itemGrade.node.color = cc.Color.WHITE; // else if(this.item_grade >= 5&&this.item_grade < 15)this.itemGrade.node.color = cc.Color.BLUE; // else if(this.item_grade >= 5&&this.item_grade < 15)this.itemGrade.node.color = cc.Color.BLUE; // else{this.itemGrade.node.color = cc.Color.RED;} //#endregion this.itemGrade.string = this.item_grade + "级"; //等级 this.itemMaster.string = this.item_master_type + '+' + this.item_master_value; //主属性+主属性数值 //物品图片 cc.resources.loadDir("texture/AvatarProps", cc.SpriteFrame, (err, spriteFrames) => { // ... spriteFrames.forEach((element) => { if (element.name === this.spriteFrame_name) { this.sprite.getComponent(cc.Sprite).spriteFrame = element; } }); }); // if (this.item_Attached_num == 0) { // //物品类型 品级 主属性类型 主属性数值 // // 副属性条数 副属性类型 副属性数值 // this.interfaceInfo.creatorItem(this.item_type, this.gradetype, this.item_master_type, this.item_master_value, // this.item_Attached_num, this._prop_name(this.item_Attached_type), this.gradetype_value(this.gradetype)); // return; // } else { for (let i = 0; i < this.item_Attached_num; i++) { cc.loader.loadRes("prefab/Items/ProBgAdd", (err, prefab) => { this.item_Attached_type = this.random_num(0, 9); // console.log(this.item_Attached_num + "++++词条数+"); // console.log(this.item_Attached_type + "+++++++随机值++++"); // console.log(this._prop_name(this.item_Attached_type) + "+++词条名字+"); // console.log(this.gradetype_value(this.gradetype) + "+++++词条数值+"); let _attached = cc.instantiate(prefab); cc.find("Canvas/PanelResult/interface_Box/GameBg/ProAdd").addChild(_attached); _attached.children[0].getComponent(cc.Label).string = this._prop_name(this.item_Attached_type) + '+' + this.gradetype_value(this.gradetype); this.item_Attached_typeArr[i] = this.item_Attached_type; this.item_attached_nameArr[i] = this._prop_name(this.item_Attached_type); this.item_attached_valueArr[i] = this.gradetype_value(this.gradetype); }); } this.interfaceInfo.creatorItem(this.item_type, this.gradetype, this.item_master_type, this.item_master_value, this.item_Attached_num, this.item_attached_nameArr, this.item_Attached_typeArr, this.item_attached_valueArr); // } }, // update (dt) {}, init() { this.itemtorScrop = cc.find("Canvas/ItemController").getComponent("ItemController"); this.interfaceInfo = cc.find("Canvas/Interface_Info").getComponent("Interface_Info"); //角色数据界面脚本 this.UiController = cc.find("Canvas/UiController").getComponent('UiController'); }, _prop_name(propnum) { //属性名字 if (propnum == 0) return "攻击"; if (propnum == 1) return "连击率"; if (propnum == 2) return "防御"; if (propnum == 3) return "血量"; if (propnum == 4) return "蓝量"; if (propnum == 5) return "格挡回血量"; if (propnum == 6) return "暴击率"; if (propnum == 7) return "闪避回蓝量"; if (propnum == 8) return "被动回蓝"; if (propnum == 9) return "被动回血"; }, gradetype_value(gradetype) { if (gradetype == 0) { return; } else { return this.random_num(1, gradetype); } // if (gradetype == 2) { // return this.random_num(1, 2); // } // if (gradetype == 3) { // return this.random_num(1, 3); // } // if (gradetype == 4) { // return this.random_num(1, 3); // } } });