import WingData from "./WingData"; import GameModel from "../core/GameModel"; import SKAnimation from "../gear_2.3.4/gui/SKAnimation"; import SKDataUtil from "../gear_2.3.4/util/SKDataUtil"; // 坐騎模型 export default class WingUtil { static shared: WingUtil = new WingUtil(); wingList: { [key: number]: WingData }; constructor() { } // 獲得偏移 private static getOffset(roleId: number, horseId: number, dir: number): cc.Vec3 { let result = cc.v3(22, -70, 0); if (horseId == 0) { // 面朝下 result = cc.v3(18, 40, 0); if (roleId == 4008) { // 零轉鬼女 result = cc.v3(8, 20, 0); } if (dir == 3) { // 面朝上 if (roleId == 2003) { // 零轉仙男 result = cc.v3(-20, 50, 0); } else if (roleId == 2004) { // 零轉仙女 result = cc.v3(-12, 38, 0); } else if (roleId == 3005) { // 零轉魔男 result = cc.v3(8, 45, 0); } else if (roleId == 4007) { // 零轉鬼男 result = cc.v3(-6, 42, 0); } else if (roleId == 4008) { // 零轉鬼女 result = cc.v3(-6, 32, 0); } else if (roleId == 1002) { // 零轉人女 result = cc.v3(-17, 35, 0); } else if (roleId == 1101) { // 零轉龍男 result = cc.v3(0, 40, 0); } else if (roleId == 1102) { // 零轉龍女 result = cc.v3(-16, 35, 0); } else { result = cc.v3(-12, 42, 0); } } return result; } if (dir == 1) { if (roleId == 1002 || roleId == 1011) { //零轉一轉人男 result = cc.v3(18, -74, 0); } else if (roleId == 1031) { //三轉人男 result = cc.v3(16, -12, 0); } else if (roleId == 1032) { // 三轉人女 result = cc.v3(18, -4, 0); } else if (roleId == 2004 || roleId == 2014) { // 零轉一轉仙女 result = cc.v3(14, -64, 0); } else if (roleId == 2034) { // 三轉仙女 result = cc.v3(16, -74, 0); } else if (roleId == 2003 || roleId == 2013) { // 零轉一轉仙男 result = cc.v3(18, -70, 0); } else if (roleId == 2033) { // 三轉仙男 result = cc.v3(18, -8, 0); } else if (roleId == 3005) { // 零轉魔男 result = cc.v3(34, -82, 0); } else if (roleId == 3015) { // 一轉魔男 result = cc.v3(16, -64, 0); } else if (roleId == 3035) { // 三轉魔男 result = cc.v3(16, -6, 0); } else if (roleId == 3006 || roleId == 3016) { // 零轉一轉魔女 result = cc.v3(18, -64, 0); } else if (roleId == 3036) { // 三轉魔女 result = cc.v3(16, -8, 0); } else if (roleId == 4037) { // 三轉鬼男 result = cc.v3(18, -8, 0); } else if (roleId == 4008 || roleId == 4018) { // 零轉一轉鬼女 result = cc.v3(16, -64, 0); } else if (roleId == 4038) { // 三轉鬼女 result = cc.v3(18, -8, 0); } } else if (dir == 3) { if (roleId == 1001 || roleId == 1011) { //零轉一轉人男 result = cc.v3(-20, -54, 0); } else if (roleId == 1031) { // 三轉人男 result = cc.v3(-16, 6, 0); } else if (roleId == 1002) { // 零轉人女 result = cc.v3(-20, -54, 0); } else if (roleId == 1012) { // 一轉人女 result = cc.v3(-16, -54, 0); } else if (roleId == 1032) { // 三轉人女 result = cc.v3(-14, 8, 0); } else if (roleId == 2003) { // 零轉仙男 result = cc.v3(-12, -40, 0); } else if (roleId == 2013) { // 一轉仙男 result = cc.v3(-12, -16, 0); } else if (roleId == 2033) { // 三轉仙男 result = cc.v3(-12, -6, 0); } else if (roleId == 2004) { // 零轉仙女 result = cc.v3(-4, -44, 0); } else if (roleId == 3005) { // 零轉魔男 result = cc.v3(4, -85, 0); } else if (roleId == 3015) { // 一轉魔男 result = cc.v3(-6, -52, 0); } else if (roleId == 3035) { // 三轉魔男 result = cc.v3(-8, 8, 0); } else if (roleId == 3006 || roleId == 3016) { // 零轉一轉魔女 result = cc.v3(-16, -54, 0); } else if (roleId == 3036) { // 三轉魔女 result = cc.v3(-16, 6, 0); } else if (roleId == 4037) { // 三轉鬼男 result = cc.v3(-14, 6, 0); } else if (roleId == 4008) { // 零轉一轉鬼女 result = cc.v3(-20, -60, 0); } else if (roleId == 4018) { // 零轉一轉鬼女 result = cc.v3(-16, -48, 0); } else if (roleId == 4038) { // 三轉鬼女 result = cc.v3(-16, 6, 0); } else if (roleId == 1101) { // 零轉龍男 result = cc.v3(-18, -60, 0); } else if (roleId == 1102) { // 零轉龍女 result = cc.v3(-10, -70, 0); } else { result = cc.v3(-22, -44, 0); } } return result; } static hideWing(node: cc.Node) { let wing_behind_1 = node.getChildByName("wing_behind_1"); let wing_behind_2 = node.getChildByName("wing_behind_2"); let wing_front_1 = node.getChildByName("wing_front_1"); let wing_front_2 = node.getChildByName("wing_front_2"); if (wing_behind_1) wing_behind_1.active = false; if (wing_behind_2) wing_behind_2.active = false; if (wing_front_1) wing_front_1.active = false; if (wing_front_2) wing_front_2.active = false; } static playAni(node: cc.Node, roleId: number, dir: number, action: string, horseId: number, wingId: number) { console.log(node.name) for (let index = 0; index < node.children.length; index++) { console.log(node.children[index]) } if (!node) { console.log("no win node") return; } let roleNode = node.getChildByName("role"); if (!roleNode) { roleNode = node.getChildByName("frame"); if (!roleNode){ console.log(" no role node") return; } } let wing_behind_1 = node.getChildByName("wing_behind_1"); let wing_behind_2 = node.getChildByName("wing_behind_2"); let wing_front_1 = node.getChildByName("wing_front_1"); let wing_front_2 = node.getChildByName("wing_front_2"); if (wingId < 1) { if (wing_behind_1) { wing_behind_1.active = false; } if (wing_behind_2) { wing_behind_2.active = false; } if (wing_front_1) { wing_front_1.active = false; } if (wing_front_2) { wing_front_2.active = false; } return; } let data = SKDataUtil.dictByDict(GameModel.game_conf, "wing", wingId); if (!data) { console.log("no wing data....", wingId) return; } let rolePos = roleNode.position; let offset = this.getOffset(roleId, horseId, dir); if (action.indexOf("run_3") != -1) { if (roleId == 1001) { offset.x = -24 offset.y = 60 } else if (roleId == 1002) { offset.x = -20 offset.y = 50 } else if (roleId == 2004) { offset.x = -10 offset.y = 44 } else if (roleId == 3005) { offset.x = 4 offset.y = 50 } else if (roleId == 3006) { offset.x = -16 offset.y = 46 } else if (roleId == 4008) { offset.x = -10 offset.y = 40 } else if (roleId == 1101) { offset.x = -12 offset.y = 42 } else if (roleId == 1102) { offset.x = -16 offset.y = 45 } } if (wing_behind_1) { wing_behind_1.setPosition(rolePos.add(offset)); } if (wing_behind_2) { wing_behind_2.setPosition(rolePos.add(offset)); } if (wing_front_1) { wing_front_1.setPosition(rolePos.add(offset)); } if (wing_front_2) { wing_front_2.setPosition(rolePos.add(offset)); } action = "stand"; if (dir == 1) { if (wing_front_1) { wing_front_1.active = false; } if (wing_front_2) { wing_front_2.active = false; } if (!wing_behind_1 || !wing_behind_2) { console.log("no wing behind..") return; } console.log("play success") wing_behind_1.active = true; SKAnimation.playAni(wing_behind_1, `wing/${data.resid}/${action}_${dir}_part1`); wing_behind_2.active = true; SKAnimation.playAni(wing_behind_2, `wing/${data.resid}/${action}_${dir}_part2`); } else { if (wing_behind_1) { wing_behind_1.active = false; } if (wing_behind_2) { wing_behind_2.active = false; } if (!wing_front_1 || !wing_front_2) { return; } wing_front_1.active = true; SKAnimation.playAni(wing_front_1, `wing/${data.resid}/${action}_${dir}_part1`); wing_front_2.active = true; SKAnimation.playAni(wing_front_2, `wing/${data.resid}/${action}_${dir}_part2`); } } }