615 lines
21 KiB
JavaScript
615 lines
21 KiB
JavaScript
import LiveEntity from "../ts/core/LiveEntity";
|
|
import GameModel from "../ts/core/GameModel";
|
|
import SKUIUtil from "../ts/gear_2.3.4/util/SKUIUtil";
|
|
import { EDir } from "../ts/core/EEnum";
|
|
import SKDataUtil from "../ts/gear_2.3.4/util/SKDataUtil";
|
|
import GameUtil from "../ts/core/GameUtil";
|
|
import MsgAlert from "../ts/game/msg/MsgAlert";
|
|
import WeaponUtil from "../ts/weapon/WeaponUtil";
|
|
|
|
let CPubFunction = require('./PubFunction');
|
|
let CSpeak = require('./Speak');
|
|
let CMainPlayerInfo = require('./MainPlayerInfo');
|
|
let pTaskConfigMgr = require('./task_config').g_pTaskConfigMgr;
|
|
let EState = require('./task_config').EState;
|
|
let EEventType = require('./task_config').EEventType;
|
|
let pNpcMgr = require('./NpcMgr');
|
|
|
|
let ENpcKind = {
|
|
ERole: 1,
|
|
EThing: 2,
|
|
EBomb: 3,
|
|
EPao: 4,
|
|
ETower: 5,
|
|
};
|
|
|
|
cc.Class({
|
|
|
|
extends: LiveEntity,
|
|
|
|
properties: {
|
|
NpcFunUI: cc.Prefab,
|
|
},
|
|
|
|
onLoad() {
|
|
this._super();
|
|
this.nConfigID = 0;
|
|
this.obj_type = 0;
|
|
this.resid = 0;
|
|
this.run_type = 0;
|
|
|
|
this.move_speed = 280;
|
|
this.move_tiems = 0;
|
|
this.animationNode = this.node.getChildByName("role");
|
|
this.weaponNode = this.animationNode.getChildByName('weapon');
|
|
this.nameNode = this.node.getChildByName('name');
|
|
this.starTypeNameNode = this.node.getChildByName('starTypeName');
|
|
this.moveAngle = 0;
|
|
this.weaponname = '';
|
|
this.resUrl = '';
|
|
this.towerGangid = 0;
|
|
this.hp = 450
|
|
},
|
|
|
|
start() {
|
|
this.schedule(this.objUpdate, 1, cc.macro.REPEAT_FOREVER, 0.1);
|
|
},
|
|
|
|
onDestroy() {
|
|
},
|
|
|
|
clear() {
|
|
let weaponNode = this.weaponNode;
|
|
if (weaponNode) {
|
|
let clips = weaponNode.getComponent(cc.Animation).getClips();
|
|
for (const clip of clips) {
|
|
weaponNode.getComponent(cc.Animation).stop(clip.name);
|
|
weaponNode.getComponent(cc.Animation).removeClip(clip, true);
|
|
}
|
|
}
|
|
|
|
let animationNode = this.animationNode;
|
|
if (animationNode) {
|
|
let clips = animationNode.getComponent(cc.Animation).getClips();
|
|
for (const clip of clips) {
|
|
animationNode.getComponent(cc.Animation).stop(clip.name);
|
|
animationNode.getComponent(cc.Animation).removeClip(clip, true);
|
|
}
|
|
}
|
|
},
|
|
|
|
setInfo(objinfo) {
|
|
this.netInfo = objinfo;
|
|
if (this.netInfo.x < 0 || this.netInfo.y < 0) {
|
|
this.netInfo.x = 0;
|
|
this.netInfo.y = 0;
|
|
}
|
|
this.x = objinfo.x;
|
|
this.y = objinfo.y;
|
|
this.onlyid = objinfo.onlyid;
|
|
this.resid = objinfo.resid;
|
|
this.name = objinfo.name;
|
|
this.nConfigID = objinfo.npcconfig;
|
|
this.nameNode.getComponent(cc.Label).string = objinfo.name;
|
|
|
|
|
|
if (objinfo.type == 1) {
|
|
this.starTypeNameNode.getComponent(cc.Label).string = "地煞" + objinfo.level + "星";
|
|
this.nameNode.y = -37;
|
|
this.starTypeNameNode.active = true
|
|
}
|
|
else if (objinfo.type == 2) {
|
|
this.starTypeNameNode.getComponent(cc.Label).string = "星君下凡" + objinfo.level + "星";
|
|
this.nameNode.y = -37;
|
|
this.starTypeNameNode.active = true
|
|
} else if (objinfo.type == 3) {
|
|
this.starTypeNameNode.getComponent(cc.Label).string = objinfo.name + "星君";
|
|
this.nameNode.y = -37;
|
|
this.starTypeNameNode.active = true
|
|
} else if (objinfo.type == 8) {
|
|
this.starTypeNameNode.getComponent(cc.Label).string = "金蟾送福";
|
|
this.nameNode.y = -37;
|
|
this.starTypeNameNode.active = true;
|
|
} else if (objinfo.type == 9) {
|
|
this.starTypeNameNode.getComponent(cc.Label).string = "金蟾送寶";
|
|
this.nameNode.y = -37;
|
|
this.starTypeNameNode.active = true;
|
|
}
|
|
if (this.nConfigID >= 47205 && this.nConfigID <= 47208) {
|
|
this.initAnimation("die");
|
|
} else
|
|
this.initAnimation();
|
|
let nID = GameModel.conf_map[objinfo.mapid].mapid;
|
|
let mapinfo = GameModel.conf_map_list[nID];
|
|
this.gridInfoArr = mapinfo.mapInfo;
|
|
if (mapinfo.baseInfo.rows <= this.netInfo.y || mapinfo.baseInfo.lines <= this.netInfo.x) {
|
|
this.netInfo.x = mapinfo.startPos.x;
|
|
this.netInfo.y = mapinfo.startPos.y;
|
|
}
|
|
this.setObjPos(this.netInfo.x, this.netInfo.y);
|
|
if (GameModel.conf_res_anchor[this.resid]) {
|
|
this.animationNode.anchorX = CPubFunction.GetDefault(GameModel.conf_res_anchor[this.resid].anchorX, 0.5);
|
|
this.animationNode.anchorY = CPubFunction.GetDefault(GameModel.conf_res_anchor[this.resid].anchorY, 0.3);
|
|
}
|
|
if (this.gridInfoArr[this.netInfo.y][this.netInfo.x] == 2) {
|
|
this.node.opacity = 150;
|
|
}
|
|
|
|
if (this.nConfigID == 10050) {
|
|
var btn = this.node.getChildByName("Button");
|
|
btn.anchorX = 0.4
|
|
btn.anchorY = 0.72
|
|
btn.width = 370
|
|
btn.height = 300
|
|
this.nameNode.x = 35;
|
|
this.nameNode.y = -140;
|
|
}
|
|
if (this.nConfigID >= 7205 && this.nConfigID <= 7208) {
|
|
GameModel.towerNpcList[`${this.nConfigID}`] = this
|
|
|
|
GameModel.send("c2s_gang_tower", {
|
|
roleId: GameModel.player.roleid,
|
|
towerId: this.nConfigID
|
|
})
|
|
}
|
|
},
|
|
|
|
initAnimation(act = "stand", dir = 1, loop = true) {
|
|
if (!this.animationNode) return
|
|
this.animationNode.active = false;
|
|
this.resUrl = `shap/${this.resid}/${act}_${dir}`;
|
|
let self = this;
|
|
|
|
cc.loader.loadRes(this.resUrl, cc.SpriteAtlas, function (error, atlas) {
|
|
if (error) {
|
|
cc.warn(`$警告:加載NPC資源錯誤:${self.resUrl}`);
|
|
return;
|
|
}
|
|
if (!SKUIUtil.isValid(self.node)) {
|
|
return;
|
|
}
|
|
if (!atlas) {
|
|
return;
|
|
}
|
|
let curFrames = atlas.getSpriteFrames();
|
|
let fn = 10;
|
|
if (self.resid <= 4038) {
|
|
fn = 15;
|
|
}
|
|
let curClip = cc.AnimationClip.createWithSpriteFrames(curFrames, fn);
|
|
curClip.name = `${act}_${dir}`;
|
|
if (loop)
|
|
curClip.wrapMode = cc.WrapMode.Loop;
|
|
|
|
let nodeAni = self.animationNode.getComponent(cc.Animation);
|
|
nodeAni.stop()
|
|
nodeAni.addClip(curClip);
|
|
nodeAni.play(`${act}_${dir}`);
|
|
if (self.resid == 6142) {
|
|
|
|
} else {
|
|
self.scheduleOnce(() => {
|
|
let xDir = 1;
|
|
if (self.netInfo.dir == EDir.LEFT || self.netInfo.dir == EDir.RIGHT) {
|
|
xDir = -1;
|
|
}
|
|
if (self.resid != 7209) {
|
|
self.animationNode.scaleY = 450 / self.animationNode.height;
|
|
self.animationNode.scaleX = 450 / self.animationNode.width * xDir;
|
|
} else {
|
|
self.animationNode.scaleY = 1.28;
|
|
self.animationNode.scaleX = 1.28 * xDir;
|
|
if (GameModel.conf_res_anchor[self.resid] && act != "run") {
|
|
if (act == "attack" && dir == 1) {
|
|
self.animationNode.anchorX = 0.46;
|
|
self.animationNode.anchorY = 0.62;
|
|
} else {
|
|
self.animationNode.anchorX = CPubFunction.GetDefault(GameModel.conf_res_anchor[self.resid].anchorX, 0.5);
|
|
self.animationNode.anchorY = CPubFunction.GetDefault(GameModel.conf_res_anchor[self.resid].anchorY, 0.3);
|
|
}
|
|
}
|
|
}
|
|
}, 0);
|
|
}
|
|
self.animationNode.active = true;
|
|
|
|
//CPubFunction.addWeaponAnimation('', self.weaponNode, self.animationNode, self, self.resid, act, 1);
|
|
WeaponUtil.addWeaponAnimation('', self.weaponNode, self.animationNode, self, self.resid, act, 1, 1);
|
|
});
|
|
|
|
if (this.nConfigID >= 7205 && this.nConfigID <= 7208 && this.hp > 0) {
|
|
this.loadEff(`shap/${this.resid}/stand_1_ef`, true, -5, 75, null)
|
|
var hp = this.node.getChildByName("hp").getComponent(cc.ProgressBar);
|
|
hp.node.active = true
|
|
}
|
|
|
|
|
|
},
|
|
changeHp(value) {
|
|
if (!this.node) return
|
|
var hp = this.node.getChildByName("hp").getComponent(cc.ProgressBar);
|
|
this.hp = value
|
|
if (value > 0) {
|
|
hp.node.active = true
|
|
hp.progress = value / 450
|
|
} else {
|
|
hp.node.active = false
|
|
this.deleteEffNode()
|
|
this.initAnimation("die", 1, true)
|
|
}
|
|
},
|
|
loadEff(url, loop, x, y, cb) {
|
|
var self = this
|
|
self.deleteEffNode()
|
|
cc.loader.loadRes(url, cc.SpriteAtlas, function (error, atlas) {
|
|
if (error) {
|
|
cc.warn(`$警告:加載資源錯誤:${url}`);
|
|
return;
|
|
}
|
|
|
|
if (!atlas) {
|
|
return;
|
|
}
|
|
|
|
let curFrames = atlas.getSpriteFrames();
|
|
let curClip = cc.AnimationClip.createWithSpriteFrames(curFrames, 10);
|
|
curClip.name = `eff`;
|
|
if (loop)
|
|
curClip.wrapMode = cc.WrapMode.Loop;
|
|
else
|
|
curClip.wrapMode = cc.WrapMode.Normal;
|
|
|
|
|
|
|
|
cc.loader.loadRes("Prefabs/EffectFrame", cc.Prefab, (err, prefab) => {
|
|
if (err) {
|
|
console.log(err)
|
|
return;
|
|
}
|
|
let effNode = cc.instantiate(prefab);
|
|
effNode.name = "effNode"
|
|
effNode.x = x
|
|
effNode.y = y
|
|
effNode.parent = self.node
|
|
effNode.getComponent("Effect").CreateAndPlayAnimation(curClip, cb)
|
|
})
|
|
})
|
|
},
|
|
deleteEffNode() {
|
|
if (!this.node) return
|
|
for (let i = this.node.children.length - 1; i > 0; i--) {
|
|
if (this.node.children[i].name == "effNode")
|
|
this.node.children[i].destroy()
|
|
}
|
|
},
|
|
Npc_Init(strDefaultTalk, mapButton) {
|
|
this.strDefaultTalk = strDefaultTalk;
|
|
this.mapButton = mapButton;
|
|
this.mapTaskBtn = {};
|
|
},
|
|
|
|
ReconTaskBtnList() {
|
|
this.mapTaskBtn = {};
|
|
for (let key in CMainPlayerInfo.vecTaskState) {
|
|
let stTaskState = CMainPlayerInfo.vecTaskState[key];
|
|
let stTaskConfig = pTaskConfigMgr.GetTaskInfo(stTaskState.nTaskID);
|
|
|
|
for (let itStep in stTaskState.vecStepState) {
|
|
if (stTaskState.vecStepState[itStep].nState != EState.EDoing)
|
|
continue;
|
|
|
|
let stStep = stTaskConfig.vecEvent[itStep];
|
|
if (stStep.nEventType == EEventType.PlayerTalkNpc) {
|
|
if (stStep.vecNpc[0] != this.nConfigID)
|
|
continue;
|
|
let vecTmp = CPubFunction.GetTaskTalkList(stTaskConfig.nTaskID, itStep);
|
|
this.mapTaskBtn[stTaskConfig.strTaskName] = { vecTmp: vecTmp, nTaskID: stTaskState.nTaskID, nStep: itStep };
|
|
}
|
|
if (stStep.nEventType == EEventType.PlayerGiveNpcItem) {
|
|
if (stStep.nNpcConfigID != this.nConfigID)
|
|
continue;
|
|
|
|
let vecTmp = [];
|
|
this.mapTaskBtn[stTaskConfig.strTaskName] = { vecTmp: vecTmp, nTaskID: stTaskState.nTaskID, nStep: itStep };
|
|
}
|
|
if (stStep.nEventType == EEventType.PlayerKillNpc) {
|
|
for (let it2 in stStep.vecNpc) {
|
|
if (stStep.vecNpc[it2] != this.nConfigID)
|
|
continue;
|
|
this.mapTaskBtn[stTaskConfig.strTaskName] = { vecTmp: [], nTaskID: stTaskState.nTaskID, nStep: itStep };
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
checklevelLimit() {
|
|
|
|
},
|
|
|
|
CloseCurUI() {
|
|
CPubFunction.FindAndDeleteNode(cc.find('Canvas/MainUI'), "NpcFunUI");
|
|
CPubFunction.FindAndHidenNode(cc.find('Canvas/MainUI'), { nX: 0, nY: -1000 });
|
|
},
|
|
|
|
OpenFunctionUI() {
|
|
let npcName = cc.find('name', this.node).getComponent(cc.Label).string;
|
|
let goNpcFunUI = SKUIUtil.createSubNode(cc.find('Canvas/MainUI'), cc.v2(300, 0), this.NpcFunUI, 'NpcFunUI');
|
|
let npcFunUI = goNpcFunUI.getComponent('NpcFunUI');
|
|
if (npcFunUI) {
|
|
npcFunUI.NpcFunUI_Init(this.GetOnlyID(), this.nConfigID, npcName, this.strDefaultTalk, this.GetFunctionMapBtn(), this.mapTaskBtn);
|
|
}
|
|
},
|
|
OpenTowerFunctionUI(data) {
|
|
GameModel.towerNpc = null
|
|
let npcName = cc.find('name', this.node).getComponent(cc.Label).string;
|
|
let goNpcFunUI = SKUIUtil.createSubNode(cc.find('Canvas/MainUI'), cc.v2(300, 0), this.NpcFunUI, 'NpcFunUI');
|
|
let npcFunUI = goNpcFunUI.getComponent('NpcFunUI');
|
|
var talk = "";
|
|
if (this.towerGangid == GameModel.player.bangid) {
|
|
talk = `這是我方的能量塔,補充能量可以開砲哦`
|
|
} else {
|
|
talk = `這是敵方能量塔,耐久剩餘${data.durable}`
|
|
}
|
|
if (npcFunUI) {
|
|
npcFunUI.NpcFunUI_Init(this.GetOnlyID(), this.nConfigID, npcName, talk, this.GetFunctionMapBtn(), this.mapTaskBtn);
|
|
}
|
|
},
|
|
GetOnlyID() {
|
|
let valid = SKUIUtil.isValid(this.node);
|
|
if (!valid) {
|
|
return 0;
|
|
}
|
|
let npc = this.node.getComponent('Npc');
|
|
if (npc) {
|
|
let result = npc.onlyid;
|
|
return result;
|
|
}
|
|
return 0;
|
|
},
|
|
|
|
IsGrass() {
|
|
let resid = this.node.getComponent('Npc').resid;
|
|
if (resid == 2003)
|
|
return true;
|
|
|
|
return false;
|
|
},
|
|
|
|
|
|
GetKind() {
|
|
let stConfig = pNpcMgr.GetNpcConfigInfo(this.nConfigID);
|
|
return stConfig.nKind;
|
|
},
|
|
|
|
OnGrassClick() {
|
|
GameUtil.createWaitTip('採集', 1, () => {
|
|
GameModel.send('c2s_act_npc', { nOnlyID: this.GetOnlyID(), nNpcConfigID: this.nConfigID, });
|
|
});
|
|
},
|
|
|
|
OnBombClick() {
|
|
GameModel.send('c2s_trigle_npc_bomb', { nNpcConfigID: this.nConfigID, nNpcOnlyID: this.GetOnlyID() });
|
|
},
|
|
OnPaoClick() {
|
|
if (GameModel.needKeep) return
|
|
if (GameModel.player.isleader && GameModel.player.teamInfo) {
|
|
var roleNum = 0;
|
|
for (let i in GameModel.player.teamInfo.objlist) {
|
|
if (SKDataUtil.hasProperty(GameModel.player.teamInfo.objlist[i], "accountid"))
|
|
roleNum++
|
|
}
|
|
if (roleNum < 1) {
|
|
MsgAlert.addMsg("需要組隊且三人及以上才行哦")
|
|
return
|
|
}
|
|
} else {
|
|
MsgAlert.addMsg("需要組隊且三人及以上才行哦")
|
|
return
|
|
}
|
|
GameModel.paoNpc = this;
|
|
GameModel.send("c2s_ask_fortifications", {
|
|
roleId: GameModel.player.roleid,
|
|
type: 1,
|
|
serial: 1,
|
|
is: 0
|
|
})
|
|
GameModel.needKeepType = 1
|
|
GameModel.serial = 1
|
|
},
|
|
// 大砲蓄力
|
|
OnPaoClickCB() {
|
|
if (GameModel.needKeep) return
|
|
this.initAnimation("run")
|
|
this.animationNode.anchorX = 0.4;
|
|
this.animationNode.anchorY = 0.495;
|
|
|
|
GameUtil.createWaitTip2('蓄力中', 20, () => {
|
|
GameModel.needKeep = false
|
|
});
|
|
|
|
GameModel.needKeep = true
|
|
},
|
|
|
|
paoBoom(data) {
|
|
GameUtil.breakWaitTip2(false);
|
|
GameUtil.waitNode.stopAllActions()
|
|
GameUtil.waitNode.destroy()
|
|
var dir = data.direction == "L" ? 1 : 3
|
|
this.initAnimation("attack", dir, false)
|
|
GameModel.needKeep = false
|
|
this.scheduleOnce(() => {
|
|
this.initAnimation()
|
|
}, 1.2)
|
|
if (dir == 3)
|
|
this.scheduleOnce(() => {
|
|
this.loadEff(`shap/7209/attack_${dir}_ef`, false, 440, 290)
|
|
}, 0.4)
|
|
else
|
|
this.scheduleOnce(() => {
|
|
this.loadEff(`shap/7209/attack_${dir}_ef`, false, 50, -20)
|
|
}, 0.5)
|
|
},
|
|
OnTowerClick() {
|
|
GameModel.towerNpc = this;
|
|
GameModel.send("c2s_gang_tower", {
|
|
roleId: GameModel.player.roleid,
|
|
towerId: this.nConfigID
|
|
})
|
|
},
|
|
// 砲塔蓄力
|
|
OnTowerKeepCB() {
|
|
GameModel.towerNpc = null;
|
|
GameModel.needKeep = true
|
|
GameUtil.createWaitTip3('蓄力中', 20, () => {
|
|
GameModel.needKeep = false
|
|
});
|
|
},
|
|
GetFunctionMapBtn() {
|
|
let mapTmp = Object.assign({}, this.mapButton);
|
|
for (let key in mapTmp) {
|
|
if (key.indexOf('daily') == -1)
|
|
continue;
|
|
if (this.nConfigID == 10067) { // 牛百色變色功能屏掉
|
|
delete mapTmp(key);
|
|
continue;
|
|
}
|
|
if (this.nConfigID == 30062 && GameModel.player.race != 1) // 菩提祖師-人族
|
|
{
|
|
delete mapTmp[key];
|
|
continue;
|
|
}
|
|
|
|
if (this.nConfigID == 10118 && GameModel.player.race != 2) // 太上老君-仙族
|
|
{
|
|
delete mapTmp[key];
|
|
continue;
|
|
}
|
|
|
|
if (this.nConfigID == 30063 && GameModel.player.race != 3) // 牛魔王-魔族
|
|
{
|
|
delete mapTmp[key];
|
|
continue;
|
|
}
|
|
|
|
if (this.nConfigID == 30065 && GameModel.player.race != 4) // 聶小倩-鬼族
|
|
{
|
|
delete mapTmp[key];
|
|
continue;
|
|
}
|
|
|
|
if (this.nConfigID == 70006 && GameModel.player.race != 5) // 龍首木-龍族
|
|
{
|
|
delete mapTmp[key];
|
|
continue;
|
|
}
|
|
|
|
if (this.nConfigID == 10240 && GameModel.player.level < 28) // 程咬金
|
|
{
|
|
delete mapTmp[key];
|
|
continue;
|
|
}
|
|
|
|
let vecTmp = key.split(":");
|
|
if (CMainPlayerInfo.IsAlreadyHasThisGropTask(vecTmp[1])) {
|
|
delete mapTmp[key];
|
|
continue;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
// 自定義去掉按鈕
|
|
for (let key in mapTmp) {
|
|
if (this.nConfigID == 10240 && GameModel.player.level < 28) // 程咬金
|
|
{
|
|
delete mapTmp[key];
|
|
// 自定義對話
|
|
this.strDefaultTalk = "聽聞孫悟空的金箍棒也是厲害的很,你說和我的三板斧比怎樣?"
|
|
continue;
|
|
}
|
|
}
|
|
|
|
for (let key in mapTmp) {
|
|
if (this.nConfigID >= 7205 && this.nConfigID <= 7208) // 幫戰塔
|
|
{
|
|
if (this.towerGangid == GameModel.player.bangid && mapTmp[key] == "果斷開打")
|
|
delete mapTmp[key];
|
|
if (this.towerGangid != GameModel.player.bangid && mapTmp[key] == "開始補充")
|
|
delete mapTmp[key];
|
|
continue;
|
|
}
|
|
}
|
|
return mapTmp;
|
|
|
|
},
|
|
|
|
OnHumanClick() {
|
|
if (this.nConfigID == 10055) {
|
|
// 判斷是否再幫戰比武場
|
|
var inBox = GameUtil.pnpoly(4, [167, 194, 169, 141], [39, 24, 12, 26], GameModel.player.x, GameModel.player.y)
|
|
if (!inBox) {
|
|
let stSpeak = new CSpeak(this.node.getComponent('Npc').resid, this.strDefaultTalk, cc.find('name', this.node).getComponent(cc.Label).string, 2); // Npc 默認的自言自語黑框
|
|
CPubFunction.CreateNpcTalk([stSpeak], null);
|
|
return
|
|
}
|
|
}
|
|
this.ReconTaskBtnList();
|
|
|
|
if (CPubFunction.GetMapLen(this.GetFunctionMapBtn()) > 0) {
|
|
this.OpenFunctionUI();
|
|
return;
|
|
}
|
|
|
|
if (CPubFunction.GetMapLen(this.mapTaskBtn) > 1) {
|
|
this.OpenFunctionUI();
|
|
}
|
|
|
|
else if (CPubFunction.GetMapLen(this.mapTaskBtn) == 1) {
|
|
let pSelf = this;
|
|
|
|
let stData = CPubFunction.GetMapDataByIndex(this.mapTaskBtn, 0);
|
|
CPubFunction.CreateNpcTalk(stData.vecTmp, (data) => {
|
|
GameModel.send('c2s_task_talk_npc', { nTaskID: stData.nTaskID, nStep: stData.nStep, nNpcConfigID: pSelf.nConfigID, nNpcOnlyID: pSelf.GetOnlyID() });
|
|
});
|
|
|
|
}
|
|
else //沒有功能 沒有任務
|
|
{
|
|
if (this.strDefaultTalk && this.strDefaultTalk != '') {
|
|
let stSpeak = new CSpeak(this.node.getComponent('Npc').resid, this.strDefaultTalk, cc.find('name', this.node).getComponent(cc.Label).string, 2); // Npc 默認的自言自語黑框
|
|
CPubFunction.CreateNpcTalk([stSpeak], null);
|
|
}
|
|
}
|
|
},
|
|
|
|
OnNpcClick() {
|
|
if (GameModel.player.getLogic().isBing) {
|
|
MsgAlert.addMsg("冰凍中,不可進行操作")
|
|
return
|
|
}
|
|
let comRole = this.node.getComponent('Npc');
|
|
let nDistance = SKDataUtil.distance({ x: GameModel.player.x, y: GameModel.player.y }, { x: comRole.x, y: comRole.y });
|
|
if (nDistance >= 20)
|
|
return;
|
|
this.CloseCurUI();
|
|
let nKind = this.GetKind();
|
|
if (nKind == ENpcKind.ERole) {
|
|
this.OnHumanClick();
|
|
}
|
|
if (nKind == ENpcKind.EThing) {
|
|
this.OnGrassClick();
|
|
}
|
|
if (nKind == ENpcKind.EBomb) {
|
|
this.OnBombClick();
|
|
}
|
|
if (nKind == ENpcKind.EPao) {
|
|
this.OnPaoClick();
|
|
}
|
|
if (nKind == ENpcKind.ETower) {
|
|
this.OnTowerClick();
|
|
}
|
|
},
|
|
});
|