import SKAnimation from "../gear_2.3.4/gui/SKAnimation"; import GameModel from "../core/GameModel"; import HorseData from "./HorseData"; // 坐騎模型 export default class HorseUtil { static shared: HorseUtil = new HorseUtil(); private _horseMap: { [key: number]: HorseData }; constructor() { } get horseMap(): { [key: number]: HorseData } { if (this._horseMap == null) { let list = GameModel.game_conf.horse; this._horseMap = {}; for (let key in list) { let item = list[key]; let data = new HorseData(); data.name = item.name; data.resId = item.resid; data.race = item.race; this._horseMap[data.resId] = data; } } return this._horseMap; } static playAni(node: cc.Node, roleId: number, dir: number, action: string, resId: number) { console.log(`roleId:${roleId} dir:${dir} action:${action} resId:${resId}`) if (!node) { return; } let data = this.shared.horseMap[resId]; console.log(resId) console.log(this.shared.horseMap) console.log(data) if (!data) { return; } data.roleId = roleId; node.y = data.offsetY; let url = data.getClipURL(dir, action, "b",resId); let behindNode = node.getChildByName("ride_behind"); if (behindNode) { console.log("play ride_behind ", url) behindNode.position = data.getOffset(dir, action, "b"); SKAnimation.playAni(behindNode, url); } url = data.getClipURL(dir, action, "b2",resId); let behindNode2 = node.getChildByName("ride_behind2"); if (behindNode2) { console.log("play ride_behind2 ", url) behindNode2.position = data.getOffset(dir, action, "b2"); SKAnimation.playAni(behindNode2, url); } url = data.getClipURL(dir, action, "b3",resId); let behindNode3 = node.getChildByName("ride_behind3"); if (behindNode3) { console.log("play ride_behind3 ", url) behindNode3.position = data.getOffset(dir, action, "b3"); SKAnimation.playAni(behindNode3, url); } url = data.getRoleURL(dir, action); let roleNode = node.getChildByName("role"); if (roleNode) { console.log("play role ", url) let rolePos = data.getRoleOffset(dir, action); roleNode.position = rolePos; SKAnimation.playAni(roleNode, url); // let imgTitleNode = node.getChildByName("imgTitle"); // if (imgTitleNode) { // imgTitleNode.y = roleNode.y + 60 // } // let labelTitleNode = node.getChildByName("labTitle"); // if (labelTitleNode) { // labelTitleNode.y = roleNode.y + 60 // } } //坐騎人物染色 url = data.getRolersURL(dir, action); var rolersNode = roleNode.getChildByName("mask"); if (rolersNode) { console.log("play mask ", url) SKAnimation.playAni(rolersNode, url); } //坐騎影子 url=data.getRoleyzURL(dir,action); var roleyzNode=node.getChildByName("ride_shadow"); if(roleyzNode){ console.log("play ride_shadow ", url) let roleyzPos = data.getRoleyzOffset(dir, action); roleyzNode.position = roleyzPos; roleyzNode.scale = data.getzuoqiyzscale(dir,action); SKAnimation.playAni(roleyzNode,url); } url = data.getClipURL(dir, action, "f",resId); var frontNode = node.getChildByName("ride_front"); if (frontNode) { console.log("play ride_front ", url) frontNode.position = data.getOffset(dir, action, "f"); SKAnimation.playAni(frontNode, url); } url = data.getClipURL(dir, action, "f1",resId); var frontNode1 = node.getChildByName("ride_front1"); if (frontNode1) { console.log("play ride_front1 ", url) frontNode1.position = data.getOffset(dir, action, "f1"); SKAnimation.playAni(frontNode1, url); } } }