// 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: cc.Component, properties: { }, // LIFE-CYCLE CALLBACKS: onLoad() {}, start() { }, // update (dt) {}, //各品级生成随机属性 /** * 左手武器:主属性加攻击 0 * 右手武器:主属性加连击率 1 * 衣服:主属性加防御 2 * 裤子:主属性加血 3 * 腰带:主属性加蓝 4 * 头盔:主属性加格挡回血量 5 * 项链:主属性加暴击率 6 * 鞋子:主属性加闪避回蓝量 7 * 手套:主属性被动回蓝 8 * 护膝:主属性被动回血 9 */ //装备类型、、品级、、属性/ // generate_properties(item_type, gradetype) { if (item_type == 0) { this.item_name = "左手拳套"; this.item_grade = 0; this.item_master_type = "攻击"; //主属性类型 //白 * (白色装备:主属性1) if (gradetype == 0) { this.spriteFrame_name = "left_gloves1"; this.item_master_value = 1; this.item_Attached_num = 0; //附属属性数量 if (this.item_Attached_num == 0) return; else { for (let i = 0; i < this.item_Attached_num; i++) { this.item_Attached_type[i] = 0; //10种类型附属属性 this.item_Attached_value[i] = 0; //附属属性类型值 } } } //* (绿色装备:主属性随机1-2,随机一条副属性1-1) //绿 主属性值随机1-2 随机副属性条数 副属性随机属性 副属性随机属性值 if (gradetype == 1) { this.spriteFrame_name = "left_gloves2"; this.item_master_value = this.random_num(1, 2); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 1); //附属属性类型值 } //蓝* (蓝色装备:主属性随机1-3,随机一条副属性1-2) if (gradetype == 2) { this.spriteFrame_name = "left_gloves3"; this.item_master_value = this.random_num(1, 3); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 2); //附属属性类型值 } //黄 * (黄色装备:主属性随机1-4,随机两条副属性1-3) if (gradetype == 3) { this.spriteFrame_name = "left_gloves4"; this.item_master_value = this.random_num(1, 4); //主属性值 this.item_Attached_num = this.random_num(2, 2); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 3); //附属属性类型值 } //红 * (红色装备:主属性随机1-5,随机三条副属性1-4) if (gradetype == 4) { this.item_master_value = this.random_num(1, 5); //主属性值 this.item_Attached_num = this.random_num(3, 3); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 4); //附属属性类型值 this.spriteFrame_name = "left_gloves5"; } } if (item_type == 1) { this.item_name = "右手拳套"; this.item_grade = 0; this.item_master_type = "连击率"; //主属性类型 //白 * (白色装备:主属性1) if (gradetype == 0) { this.item_master_value = 1; this.item_Attached_num = 0; //附属属性数量 this.item_Attached_type = 0; //10种类型附属属性 this.item_Attached_value = 0; //附属属性类型值 this.spriteFrame_name = "right_gloves1"; } //* (绿色装备:主属性随机1-2,随机一条副属性1-1) //绿 主属性值随机1-2 随机副属性条数 副属性随机属性 副属性随机属性值 if (gradetype == 1) { this.item_master_value = this.random_num(1, 2); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 1); //附属属性类型值 this.spriteFrame_name = "right_gloves2"; } //蓝* (蓝色装备:主属性随机1-3,随机一条副属性1-2) if (gradetype == 2) { this.item_master_value = this.random_num(1, 3); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 2); //附属属性类型值 this.spriteFrame_name = "right_gloves3"; } //黄 * (黄色装备:主属性随机1-4,随机两条副属性1-3) if (gradetype == 3) { this.item_master_value = this.random_num(1, 4); //主属性值 this.item_Attached_num = this.random_num(2, 2); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 3); //附属属性类型值 this.spriteFrame_name = "right_gloves4"; } //红 * (红色装备:主属性随机1-5,随机三条副属性1-4) if (gradetype == 4) { this.item_master_value = this.random_num(1, 5); //主属性值 this.item_Attached_num = this.random_num(3, 3); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 4); //附属属性类型值 this.spriteFrame_name = "right_gloves5"; } } if (item_type == 2) { this.item_name = "衣服"; this.item_grade = 0; this.item_master_type = "防御"; //主属性类型 //白 * (白色装备:主属性1) if (gradetype == 0) { this.item_master_value = 1; this.item_Attached_num = 0; //附属属性数量 this.item_Attached_type = 0; //10种类型附属属性 this.item_Attached_value = 0; //附属属性类型值 this.spriteFrame_name = "clothes1"; } //* (绿色装备:主属性随机1-2,随机一条副属性1-1) //绿 主属性值随机1-2 随机副属性条数 副属性随机属性 副属性随机属性值 if (gradetype == 1) { this.item_master_value = this.random_num(1, 2); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 1); //附属属性类型值 this.spriteFrame_name = "clothes2"; } //蓝* (蓝色装备:主属性随机1-3,随机一条副属性1-2) if (gradetype == 2) { this.item_master_value = this.random_num(1, 3); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 2); //附属属性类型值 this.spriteFrame_name = "clothes3"; } //黄 * (黄色装备:主属性随机1-4,随机两条副属性1-3) if (gradetype == 3) { this.item_master_value = this.random_num(1, 4); //主属性值 this.item_Attached_num = this.random_num(2, 2); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 3); //附属属性类型值 this.spriteFrame_name = "clothes4"; } //红 * (红色装备:主属性随机1-5,随机三条副属性1-4) if (gradetype == 4) { this.item_master_value = this.random_num(1, 5); //主属性值 this.item_Attached_num = this.random_num(3, 3); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 4); //附属属性类型值 this.spriteFrame_name = "clothes5"; } } if (item_type == 3) { this.item_name = "裤子"; this.item_grade = 0; this.item_master_type = "血量"; //主属性类型 //白 * (白色装备:主属性1) if (gradetype == 0) { this.item_master_value = 1; this.item_Attached_num = 0; //附属属性数量 this.item_Attached_type = 0; //10种类型附属属性 this.item_Attached_value = 0; //附属属性类型值 this.spriteFrame_name = "trousers1"; } //* (绿色装备:主属性随机1-2,随机一条副属性1-1) //绿 主属性值随机1-2 随机副属性条数 副属性随机属性 副属性随机属性值 if (gradetype == 1) { this.item_master_value = this.random_num(1, 2); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 1); //附属属性类型值 this.spriteFrame_name = "trousers2"; } //蓝* (蓝色装备:主属性随机1-3,随机一条副属性1-2) if (gradetype == 2) { this.item_master_value = this.random_num(1, 3); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 2); //附属属性类型值 this.spriteFrame_name = "trousers3"; } //黄 * (黄色装备:主属性随机1-4,随机两条副属性1-3) if (gradetype == 3) { this.item_master_value = this.random_num(1, 4); //主属性值 this.item_Attached_num = this.random_num(2, 2); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 3); //附属属性类型值 this.spriteFrame_name = "trousers4"; } //红 * (红色装备:主属性随机1-5,随机三条副属性1-4) if (gradetype == 4) { this.item_master_value = this.random_num(1, 5); //主属性值 this.item_Attached_num = this.random_num(3, 3); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 4); //附属属性类型值 this.spriteFrame_name = "trousers5"; } } if (item_type == 4) { this.item_name = "腰带"; this.item_grade = 0; this.item_master_type = "蓝量"; //主属性类型 //白 * (白色装备:主属性1) if (gradetype == 0) { this.item_master_value = 1; this.item_Attached_num = 0; //附属属性数量 this.item_Attached_type = 0; //10种类型附属属性 this.item_Attached_value = 0; //附属属性类型值 this.spriteFrame_name = "belt1"; } //* (绿色装备:主属性随机1-2,随机一条副属性1-1) //绿 主属性值随机1-2 随机副属性条数 副属性随机属性 副属性随机属性值 if (gradetype == 1) { this.item_master_value = this.random_num(1, 2); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 1); //附属属性类型值 this.spriteFrame_name = "belt2"; } //蓝* (蓝色装备:主属性随机1-3,随机一条副属性1-2) if (gradetype == 2) { this.item_master_value = this.random_num(1, 3); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 2); //附属属性类型值 this.spriteFrame_name = "belt3"; } //黄 * (黄色装备:主属性随机1-4,随机两条副属性1-3) if (gradetype == 3) { this.item_master_value = this.random_num(1, 4); //主属性值 this.item_Attached_num = this.random_num(2, 2); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 3); //附属属性类型值 this.spriteFrame_name = "belt4"; } //红 * (红色装备:主属性随机1-5,随机三条副属性1-4) if (gradetype == 4) { this.item_master_value = this.random_num(1, 5); //主属性值 this.item_Attached_num = this.random_num(3, 3); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 4); //附属属性类型值 this.spriteFrame_name = "belt5"; } } if (item_type == 5) { this.item_name = "头盔"; this.item_grade = 0; this.item_master_type = "格挡回血量"; //主属性类型 //白 * (白色装备:主属性1) if (gradetype == 0) { this.item_master_value = 1; this.item_Attached_num = 0; //附属属性数量 this.item_Attached_type = 0; //10种类型附属属性 this.item_Attached_value = 0; //附属属性类型值 this.spriteFrame_name = "helmet1"; } //* (绿色装备:主属性随机1-2,随机一条副属性1-1) //绿 主属性值随机1-2 随机副属性条数 副属性随机属性 副属性随机属性值 if (gradetype == 1) { this.item_master_value = this.random_num(1, 2); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 1); //附属属性类型值 this.spriteFrame_name = "helmet2"; } //蓝* (蓝色装备:主属性随机1-3,随机一条副属性1-2) if (gradetype == 2) { this.item_master_value = this.random_num(1, 3); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 2); //附属属性类型值 this.spriteFrame_name = "helmet3"; } //黄 * (黄色装备:主属性随机1-4,随机两条副属性1-3) if (gradetype == 3) { this.item_master_value = this.random_num(1, 4); //主属性值 this.item_Attached_num = this.random_num(2, 2); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 3); //附属属性类型值 this.spriteFrame_name = "helmet4"; } //红 * (红色装备:主属性随机1-5,随机三条副属性1-4) if (gradetype == 4) { this.item_master_value = this.random_num(1, 5); //主属性值 this.item_Attached_num = this.random_num(3, 3); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 4); //附属属性类型值 this.spriteFrame_name = "helmet5"; } } if (item_type == 6) { this.item_name = "项链"; this.item_grade = 0; this.item_master_type = "暴击率"; //主属性类型 //白 * (白色装备:主属性1) if (gradetype == 0) { this.item_master_value = 1; this.item_Attached_num = 0; //附属属性数量 this.item_Attached_type = 0; //10种类型附属属性 this.item_Attached_value = 0; //附属属性类型值 this.spriteFrame_name = "necklace1"; } //* (绿色装备:主属性随机1-2,随机一条副属性1-1) //绿 主属性值随机1-2 随机副属性条数 副属性随机属性 副属性随机属性值 if (gradetype == 1) { this.item_master_value = this.random_num(1, 2); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 1); //附属属性类型值 this.spriteFrame_name = "necklace2"; } //蓝* (蓝色装备:主属性随机1-3,随机一条副属性1-2) if (gradetype == 2) { this.item_master_value = this.random_num(1, 3); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 2); //附属属性类型值 this.spriteFrame_name = "necklace3"; } //黄 * (黄色装备:主属性随机1-4,随机两条副属性1-3) if (gradetype == 3) { this.item_master_value = this.random_num(1, 4); //主属性值 this.item_Attached_num = this.random_num(2, 2); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 3); //附属属性类型值 this.spriteFrame_name = "necklace4"; } //红 * (红色装备:主属性随机1-5,随机三条副属性1-4) if (gradetype == 4) { this.item_master_value = this.random_num(1, 5); //主属性值 this.item_Attached_num = this.random_num(3, 3); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 4); //附属属性类型值 this.spriteFrame_name = "necklace5"; } } if (item_type == 7) { this.item_name = "鞋子"; this.item_grade = 0; this.item_master_type = "闪避回蓝量"; //主属性类型 //白 * (白色装备:主属性1) if (gradetype == 0) { this.item_master_value = 1; this.item_Attached_num = 0; //附属属性数量 this.item_Attached_type = 0; //10种类型附属属性 this.item_Attached_value = 0; //附属属性类型值 this.spriteFrame_name = "shoe1"; } //* (绿色装备:主属性随机1-2,随机一条副属性1-1) //绿 主属性值随机1-2 随机副属性条数 副属性随机属性 副属性随机属性值 if (gradetype == 1) { this.item_master_value = this.random_num(1, 2); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 1); //附属属性类型值 this.spriteFrame_name = "shoe2"; } //蓝* (蓝色装备:主属性随机1-3,随机一条副属性1-2) if (gradetype == 2) { this.item_master_value = this.random_num(1, 3); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 2); //附属属性类型值 this.spriteFrame_name = "shoe3"; } //黄 * (黄色装备:主属性随机1-4,随机两条副属性1-3) if (gradetype == 3) { this.item_master_value = this.random_num(1, 4); //主属性值 this.item_Attached_num = this.random_num(2, 2); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 3); //附属属性类型值 this.spriteFrame_name = "shoe4"; } //红 * (红色装备:主属性随机1-5,随机三条副属性1-4) if (gradetype == 4) { this.item_master_value = this.random_num(1, 5); //主属性值 this.item_Attached_num = this.random_num(3, 3); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 4); //附属属性类型值 this.spriteFrame_name = "shoe5"; } } if (item_type == 8) { this.item_name = "手套"; this.item_grade = 0; this.item_master_type = "被动回蓝"; //主属性类型 //白 * (白色装备:主属性1) if (gradetype == 0) { this.item_master_value = 1; this.item_Attached_num = 0; //附属属性数量 this.item_Attached_type = 0; //10种类型附属属性 this.item_Attached_value = 0; //附属属性类型值 this.spriteFrame_name = "wristsupport1"; } //* (绿色装备:主属性随机1-2,随机一条副属性1-1) //绿 主属性值随机1-2 随机副属性条数 副属性随机属性 副属性随机属性值 if (gradetype == 1) { this.item_master_value = this.random_num(1, 2); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 1); //附属属性类型值 this.spriteFrame_name = "wristsupport2"; } //蓝* (蓝色装备:主属性随机1-3,随机一条副属性1-2) if (gradetype == 2) { this.item_master_value = this.random_num(1, 3); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 2); //附属属性类型值 this.spriteFrame_name = "wristsupport3"; } //黄 * (黄色装备:主属性随机1-4,随机两条副属性1-3) if (gradetype == 3) { this.item_master_value = this.random_num(1, 4); //主属性值 this.item_Attached_num = this.random_num(2, 2); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 3); //附属属性类型值 this.spriteFrame_name = "wristsupport4"; } //红 * (红色装备:主属性随机1-5,随机三条副属性1-4) if (gradetype == 4) { this.item_master_value = this.random_num(1, 5); //主属性值 this.item_Attached_num = this.random_num(3, 3); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 4); //附属属性类型值 this.spriteFrame_name = "wristsupport5"; } } if (item_type == 9) { this.item_name = "护膝"; this.item_grade = 0; this.item_master_type = "被动回血"; //主属性类型 //白 * (白色装备:主属性1) if (gradetype == 0) { this.item_master_value = 1; this.item_Attached_num = 0; //附属属性数量 this.item_Attached_type = 0; //10种类型附属属性 this.item_Attached_value = 0; //附属属性类型值 this.spriteFrame_name = "kneecap1"; } //* (绿色装备:主属性随机1-2,随机一条副属性1-1) //绿 主属性值随机1-2 随机副属性条数 副属性随机属性 副属性随机属性值 if (gradetype == 1) { this.item_master_value = this.random_num(1, 2); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 1); //附属属性类型值 this.spriteFrame_name = "kneecap2"; } //蓝* (蓝色装备:主属性随机1-3,随机一条副属性1-2) if (gradetype == 2) { this.item_master_value = this.random_num(1, 3); //主属性值 this.item_Attached_num = this.random_num(1, 1); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 2); //附属属性类型值 this.spriteFrame_name = "kneecap3"; } //黄 * (黄色装备:主属性随机1-4,随机两条副属性1-3) if (gradetype == 3) { this.item_master_value = this.random_num(1, 4); //主属性值 this.item_Attached_num = this.random_num(2, 2); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 3); //附属属性类型值 this.spriteFrame_name = "kneecap4"; } //红 * (红色装备:主属性随机1-5,随机三条副属性1-4) if (gradetype == 4) { this.item_master_value = this.random_num(1, 5); //主属性值 this.item_Attached_num = this.random_num(3, 3); //附属属性数量 this.item_Attached_type = this.random_num(0, 9); //10种类型附属属性 this.item_Attached_value = this.random_num(1, 4); //附属属性类型值 this.spriteFrame_name = "kneecap5"; } } }, //return Math.floor(Math.random() * (max - min + 1)) + min;[min max]; //随机物品类型 random_num(minnum, maxnum) { return Math.floor(Math.random() * (maxnum - minnum + 1)) + minnum; }, _item_name(itemnum) { //物品名字 if (itemnum == 0) return "左手拳套"; if (itemnum == 1) return "右手拳套"; if (itemnum == 2) return "衣服"; if (itemnum == 3) return "裤子"; if (itemnum == 4) return "腰带"; if (itemnum == 5) return "头盔"; if (itemnum == 6) return "项链"; if (itemnum == 7) return "鞋子"; if (itemnum == 8) return "手套"; if (itemnum == 9) return "护膝"; } // //随机品级 // random_grade(maxnum) { //max 5 // return Math.floor(Math.random() * maxnum); //[0-4] // }, // //随机属性条数 // random_argu(maxnum) { //max 4 // return Math.floor(Math.random() * maxnum + 1); //[1-3] // }, // //随机属性类型 // random_argu_type() { // return Math.floor(Math.random() * 10); //[0-9] // }, // //随机值[0-(maxnum-1)]+1 [1,maxnum] // random_Num(maxnum) { //max 5 // return Math.floor(Math.random() * maxnum + 1); //[1-5] // }, });