MonsterBase.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  1. import EventMgr from "./EventMgr";
  2. import { GameEvent } from "./GameEvent";
  3. import { GameState } from "./GameState";
  4. import Hero, { GameInput } from "./Hero";
  5. import HurtTag from "./HurtTag";
  6. import Main from "./Main";
  7. import MonsterHit from "./MonsterHit";
  8. import ResMgr from "./ResMgr";
  9. import SoundMgr from "./SoundMgr";
  10. import Weapon from "./Weapon";
  11. const { ccclass, property } = cc._decorator;
  12. // 状态
  13. export enum MonsterState {
  14. none = "none",
  15. born = "born",//刚出生,无敌
  16. stand = "stand",
  17. move = "move",
  18. // run = ''
  19. attack = "attack",
  20. hurt = "hurt",
  21. dead = "dead",
  22. win = "win",
  23. }
  24. // 动画名称
  25. export enum MonsterAnima {
  26. // idle = 'idle2',
  27. walk = 'walk',
  28. attack1 = 'atk',
  29. hurt = 'hurt',
  30. hurtDizzy = 'wolfHurtDizzy',
  31. dead = 'die',
  32. win = 'win',
  33. }
  34. export enum MonsterFace {
  35. left = "left",
  36. right = "right",
  37. }
  38. @ccclass
  39. export default class MonsterBase extends cc.Component {
  40. // hero状态
  41. // @property(cc.Node)
  42. // tmp: cc.Node = null;
  43. // hero状态
  44. @property(cc.Node)
  45. weaponAttach: cc.Node = null;
  46. @property(cc.Integer)
  47. hp: number = 5;
  48. /**无尽模式死亡基础分*/
  49. @property(cc.Integer)
  50. private baseScore:number = 0;
  51. // /**无尽模式死亡得分*/
  52. // private get score(){
  53. // return 1;
  54. // }
  55. /** 移动方向 1:向右, -1向左, 0不动*/
  56. protected dirX: number = 0;
  57. _enemySate: MonsterState = null;
  58. set state(val: MonsterState){
  59. // console.error("状态设置:"+val);
  60. this._enemySate = val;
  61. }
  62. get state(){
  63. return this._enemySate;
  64. }
  65. anim: cc.Animation = null;
  66. protected hitCom:MonsterHit;
  67. animName: string = null
  68. // combo: number = 0;
  69. // 刚体在世界坐标下的(线性速度)
  70. lv: cc.Vec2 = null
  71. // moveLeft: boolean = false;
  72. // moveRight: boolean = false;
  73. tt: number = 0;
  74. /**生存时间 */
  75. private lifeTime: number = 0;
  76. /**上一次攻击时间 */
  77. private atkLifeTime:number = 0;
  78. // 玩家节点
  79. hero: Hero = null;
  80. protected rigidBody:cc.RigidBody;
  81. isDestroy: boolean = false;
  82. private _id: string;
  83. public get id() {
  84. return this._id;
  85. }
  86. /**眩晕计时器 */
  87. private timeId_dizzy:string;
  88. // LIFE-CYCLE CALLBACKS:
  89. public get WPos() {
  90. return this.node.convertToWorldSpaceAR(cc.Vec2.ZERO);
  91. }
  92. protected get walkAnim(): string {
  93. return MonsterAnima.walk;
  94. }
  95. protected speed: number = 150;
  96. protected nearSpeed: number = 140;
  97. private hurtTag:HurtTag;
  98. // protected get initSpeed():number{
  99. // return 80;
  100. // }
  101. /**
  102. * 设置初始位置
  103. * @param x
  104. * @param y
  105. */
  106. public SetInitPos(x,y){
  107. this.node.setPosition(cc.v2(x, y))
  108. }
  109. private timerId_init;
  110. onLoad() {
  111. let me = this;
  112. me.state = MonsterState.none;
  113. me.node.active = false;
  114. me.isInvincible = true;
  115. this.nearSpeed = Util.random(130,150);
  116. // this.timerId_init = Ticker.registerDelay(() => {
  117. me.node.active = true;
  118. me.init();
  119. // }, Util.randomArr([0, 100, 200, 300], 1)[0]);//延迟初始化,会导致监听到的消息处理出问题
  120. EventMgr.Instance.add_event_listenner(GameEvent.HeroDie, this, this.OnHeroDie);
  121. // console.error(this.id+" monster base 开始监听");
  122. EventMgr.Instance.add_event_listenner(GameEvent.HeroSuperSkill,this,this.OnHeroSuperSkill);
  123. Ticker.register(this.tickFun,this);
  124. if (Main.Ins.IsGuide) {
  125. EventMgr.Instance.add_event_listenner(GameEvent.GuideStepWolfStop, this, this.OnGuideStepWolfStop);
  126. }
  127. }
  128. OnGuideStepWolfStop(GuideStepEnd: GameEvent, isStop) {
  129. // if (guide == 5) {
  130. // this.stopMove();
  131. // }
  132. Main.Ins.guideLog("是否冷冻:"+isStop);
  133. if (isStop) {
  134. this.stopMove();
  135. }else{
  136. this.repuseMove();
  137. }
  138. }
  139. protected init() {
  140. let me = this;
  141. this._id = this.node.uuid;
  142. // this.speed = this.initSpeed;//
  143. this.state = MonsterState.move;
  144. this.animName = this.walkAnim;// this.walkAnim;;// Anima.idle
  145. this.hero = Main.Ins.hero;//noeds.filter(e => e.group == 'enemy');// cc.find('Canvas/bg/hero')
  146. // this.lv = this.node.getComponent(cc.RigidBody).linearVelocity
  147. this.anim = this.node.getChildByName('body').getComponent(cc.Animation);
  148. this.hitCom = this.node.getChildByName('body').getComponent(MonsterHit);
  149. this.faceHero();
  150. this.anim.on(cc.Animation.EventType.FINISHED, this.onFinishAnima, this)
  151. // this.moveLeft = false;
  152. // this.enemyAction();
  153. this.rigidBody = this.node.getComponent(cc.RigidBody);
  154. // this.weapon.node.active = true;
  155. let hurtTagNode:cc.Node= cc.instantiate(ResMgr.Instance.getAsset("LifePrefab", "hurtTag"));
  156. hurtTagNode.parent = this.node;
  157. this.hurtTag = hurtTagNode.getComponent(HurtTag);
  158. this.hurtTag.init(false);
  159. }
  160. /**英雄必杀 */
  161. OnHeroSuperSkill() {
  162. // console.error(this.id+" 收到大招0 monster base");
  163. this.hurt(Math.random()>0.5,true,false,true);
  164. }
  165. protected OnHeroDie() {
  166. this.logErr(" enemy =英雄死了");
  167. let me = this;
  168. if (this.state == MonsterState.dead) { return; }
  169. this.state = MonsterState.win;
  170. if (!this.node) { return; }
  171. // 静止
  172. this.dirX = 0;
  173. this.setSpeed();
  174. // Ticker.registerDelay(() => {
  175. me.setAnima(MonsterAnima.win);
  176. // }, 2000);
  177. }
  178. onDestroy() {
  179. this.removeListerner();
  180. }
  181. onFinishAnima(e: string, data: cc.AnimationState) {
  182. let aniName = data.name;
  183. this.logErr("动画结束:" + aniName);
  184. if (aniName == MonsterAnima.attack1)//||aniName == MonsterAnima.hurtDizzy)
  185. {
  186. // 继续移动
  187. this.state = MonsterState.move
  188. // 清空记录的动画,避免不能连续攻击
  189. this.animName = null;
  190. }
  191. }
  192. // start () {}
  193. tickFun(dt: number) {
  194. if (this.isStop) {return;}
  195. if (Main.Ins.State != GameState.inGame && Main.Ins.State != GameState.inGuide) { return; }
  196. if (this.state == MonsterState.none) {
  197. return;
  198. }
  199. if (this.hp == 0 || this.state == MonsterState.win) {
  200. return;
  201. }
  202. this.lifeTime +=dt;
  203. this.updateAction(dt)
  204. }
  205. protected updateAction(dt: number){
  206. this.tt += dt;
  207. if (this.tt >= 0.1 && (this.state == MonsterState.move || this.state == MonsterState.stand)) {
  208. this.enemyAction();
  209. this.tt = 0;
  210. }
  211. if (this.state == MonsterState.move) {
  212. this.onMove()
  213. } else if (this.state == MonsterState.attack) {
  214. this.onAttack()
  215. } else if (this.state == MonsterState.stand) {
  216. this.onStand()
  217. }
  218. }
  219. protected get heroDist() {
  220. let p_position = this.hero.node.position
  221. let e_position = this.node.position
  222. let distance = p_position.x - e_position.x;// cc.Vec2.distance(p_position, e_position)
  223. return distance;
  224. }
  225. protected get heroDisAbsolut() {
  226. return Math.abs(this.heroDist);
  227. }
  228. faceHero() {
  229. // let distance = this.heroDist;
  230. // console.error("faceHero:"+distance);
  231. let scaleX = Math.abs(this.node.scaleX)
  232. if (this.monsteFace == MonsterFace.left) {
  233. this.node.scaleX = -scaleX
  234. } else {
  235. this.node.scaleX = scaleX
  236. }
  237. }
  238. moveToHero() {
  239. }
  240. protected monsteFace;
  241. private time:number=0;
  242. // 敌人行为
  243. protected enemyAction() {
  244. let distance = this.heroDist;
  245. this.monsteFace = distance > 0 ? MonsterFace.right : MonsterFace.left;
  246. // // x相隔距离
  247. if (Math.abs(distance) <= 130) {
  248. // cc.log('attack')
  249. // 先调整方向, 面向玩家
  250. // // 静止
  251. // this.changeDirection(0)
  252. this.dirX = 0;
  253. this.setSpeed();
  254. if (Main.Ins.TryGuideStep(1)|| Main.Ins.TryGuideStep(2)) {
  255. Main.Ins.guideLog("开始引导-2");
  256. // this.state = MonsterState.stand;
  257. EventMgr.Instance.dispatch_event(GameEvent.GuideStepWolfStop,true);
  258. if (Main.Ins.TryGuideStep(1)) {
  259. Main.Ins.BallonGuide.showRight(true);
  260. Main.Ins.SetGuideIptPermit(GameInput.rightClick);
  261. }else if (Main.Ins.TryGuideStep(2)) {
  262. Main.Ins.BallonGuide.showLeft(true);
  263. Main.Ins.SetGuideIptPermit(GameInput.leftClick);
  264. }
  265. // Ticker.pause();
  266. // Main.Ins.guideView.show("右踩进行攻击",2,function(){
  267. // this.creatWolf(this.enermyNames[0],false);
  268. // }.bind(this));
  269. return;
  270. }
  271. if (Math.random() > 0.8 && this.lifeTime - this.atkLifeTime > 1.5) //两次攻击事件
  272. {
  273. this.state = MonsterState.attack;
  274. this.atkLifeTime = this.lifeTime;
  275. } else {
  276. this.state = MonsterState.stand;
  277. }
  278. } else //if (distance <= 150)
  279. {
  280. this.state = MonsterState.move;
  281. // cc.log('追击')
  282. // this.changeDirection(v.x)
  283. }
  284. // else{
  285. // cc.log('随机走 巡逻')
  286. // this.changeDirection(Math.random() > 0.5 ? 1 : -1)
  287. // }
  288. }
  289. // 移动
  290. onMove(): void {
  291. if (this.isStop ) {
  292. return;
  293. }
  294. let scaleX = Math.abs(this.node.getChildByName('body').scaleX)
  295. let annima = this.animName
  296. if (this.monsteFace == MonsterFace.left) {
  297. // <--
  298. this.dirX = -1
  299. this.node.scaleX = -scaleX
  300. annima = this.walkAnim;
  301. } else {
  302. this.dirX = 1
  303. this.node.scaleX = scaleX
  304. annima = this.walkAnim;
  305. }
  306. if (this.heroDisAbsolut < 180) {
  307. // this.sp.x = 0.7;//this.nearSpeed * this.sp.x;
  308. this.setSpeed(this.nearSpeed)
  309. } else {
  310. this.setSpeed()
  311. }
  312. // else {
  313. // this.sp.x = 0
  314. // annima = this.walkAnim;
  315. // }
  316. // 修改动画
  317. this.setAnima(annima)
  318. }
  319. onStand() {
  320. this.setAnima(this.walkAnim);
  321. if (this.state == MonsterState.stand) {
  322. return;
  323. }
  324. this.dirX = 0;
  325. this.setSpeed()
  326. // 修改动画
  327. this.setAnima(this.walkAnim);
  328. }
  329. // 攻击
  330. onAttack(): void {
  331. // return;
  332. this.dirX = 0
  333. this.setSpeed()
  334. let random = Math.random();
  335. // this.logErr("攻击:"+random);
  336. if (random < 0.3) {
  337. // 修改动画
  338. this.setAnima(MonsterAnima.attack1)
  339. }
  340. }
  341. // 改变速度(向量)
  342. setSpeed(forceSpeed = undefined): void {
  343. // console.error("setSpeed");
  344. if (!this.rigidBody) {return;}
  345. // 刚体
  346. // 刚体的线性速度
  347. this.lv = this.rigidBody.linearVelocity
  348. // if (forceSpeed) {
  349. // this.lv.x = forceSpeed;
  350. // }else{
  351. // 速度和方向
  352. if (this.dirX) {
  353. this.lv.x = this.dirX * (forceSpeed ? forceSpeed : this.speed);
  354. } else {
  355. this.lv.x = 0;
  356. }
  357. // }
  358. // 速度赋值
  359. this.rigidBody.linearVelocity = this.lv;
  360. }
  361. /**
  362. * 播放新动画
  363. * @param animiat
  364. */
  365. setAnima(animiat: string): void {
  366. if (this.animName == MonsterAnima.win) { return; }
  367. if (!animiat || this.animName == animiat) { return }
  368. // cc.log('动画改变 old {}, new {}',this.annima, animiat)
  369. this.animName = animiat
  370. // 播放新动画
  371. this.logErr("当前播放动画:" + animiat,true);
  372. this.setShowHurtWeapon(animiat == this.walkAnim || animiat == MonsterAnima.attack1);
  373. if (!this.anim) {
  374. this.logErr(this,true);
  375. }
  376. this.anim.play(animiat);
  377. }
  378. /**
  379. * 被武器击中后显示武器(正式版不需要此功能,注释掉)
  380. * @param isShow
  381. */
  382. private setShowHurtWeapon(isShow) {
  383. if (this.hurtWeapon) {
  384. // this.hurtWeapon.active = isShow;
  385. }
  386. }
  387. /**
  388. * 受击
  389. * @param hurtLeft true:左侧受击
  390. * @param isHeavy 是否重击(重击击退)
  391. * @param weaponHurt 是否武器攻击
  392. * @param mustKill 必杀
  393. * @returns
  394. */
  395. hurt(hurtLeft:boolean, isHeavy:boolean, weaponHurt:boolean,mustKill:boolean): boolean {
  396. // console.error(this.id+" 收到大招 1 monster base->isInvincible:"+this.isInvincible+" mustKill:"+mustKill);
  397. if (this.isInvincible && !mustKill) { return false; }
  398. // // 速度为0
  399. // this.sp.x = 0
  400. // this.setSpeed()
  401. // console.error(this.id+" 收到大招 2 monster base:"+this.state);
  402. // if (this.hp == 0) { return false; }
  403. if (this.state == MonsterState.dead||this.state == MonsterState.win) { return false; }
  404. this.onHurt(hurtLeft,isHeavy,weaponHurt,mustKill);
  405. return true;
  406. }
  407. protected onHurt(hurtLeft:boolean, isHeavy:boolean, weaponHurt:boolean,mustKill:boolean) {
  408. console.log(this.hp);
  409. let me = this;
  410. this.hp--;
  411. // cc.log('current hp is', this.hp)
  412. // console.error("狼受击音效");
  413. SoundMgr.Instance.play_effect("飞刀击中狼");
  414. this.onHurtSpeed();
  415. // this.changeDirection(0);
  416. EventMgr.Instance.dispatch_event(GameEvent.CamShake, 300);
  417. // 速度赋值
  418. // this.rigidBody.linearVelocity.x = 0;
  419. if (mustKill) {
  420. this.hp=0;
  421. }
  422. // console.error(this.id+" 收到大招 3 monster base ->mustKill:"+mustKill+" hp:"+this.hp);
  423. // this.log('hurt......' + this.hp);
  424. if (this.hp <= 0) {
  425. this.onHurtDie();
  426. } else {
  427. // if (!isWeapon) {
  428. this.onHurtStillLive(isHeavy,weaponHurt);
  429. }
  430. this.hurtTag.play(hurtLeft);
  431. }
  432. protected onHurtSpeed(){
  433. this.dirX = 0;
  434. this.setSpeed();
  435. }
  436. protected onHurtDie(){
  437. let me = this;
  438. this.logErr("onHurtDie",true);
  439. this.removeListerner();
  440. if (!Main.Ins.IsGuide) {//新手引导掉落武器会出问题
  441. this.dropWeapon();
  442. }
  443. Main.Ins.EnemyCount--;
  444. this.state = MonsterState.dead;
  445. this.setAnima(MonsterAnima.dead)
  446. SoundMgr.Instance.play_effect("狼死亡");
  447. EventMgr.Instance.dispatch_event(GameEvent.MonsterDie,this.baseScore);
  448. this.rigidBody.linearVelocity = cc.v2(this.monsteFace == MonsterFace.left ? 200 : -200, 400);
  449. // if (this.enemyAni) {
  450. // this.enemyAni.off(cc.Animation.EventType.FINISHED, this.onFinishAnima, this);
  451. // }
  452. this.logErr("怪物销毁",true);
  453. if (Main.Ins.TryGuideStep(1)||Main.Ins.TryGuideStep(2)) {
  454. Main.Ins.guideLog("开始引导-2");
  455. Main.Ins.SetGuideIptPermit();
  456. Main.Ins.BallonGuide.showRight(false);
  457. Main.Ins.BallonGuide.showLeft(false);
  458. if (Main.Ins.TryGuideStep(1)) {
  459. Main.Ins.GuideStepEnd(1);
  460. Main.Ins.Guide2();
  461. }else if (Main.Ins.TryGuideStep(2)) {
  462. Main.Ins.GuideStepEnd(2);
  463. Main.Ins.Guide3();
  464. }
  465. }else if (Main.Ins.GuideStep == 3) {
  466. Main.Ins.GuideStepEnd(3);
  467. Main.Ins.SetGuideIptPermit();
  468. Main.Ins.Guide4();
  469. }
  470. }
  471. protected onHurtStillLive(isHeavy, weaponHurt){
  472. let me = this;
  473. this.state = MonsterState.hurt;
  474. if (isHeavy || weaponHurt)
  475. {
  476. Ticker.unregisterDelay(me.timeId_dizzy);
  477. this.setAnima(MonsterAnima.hurt);
  478. this.rigidBody.linearVelocity = cc.v2(this.monsteFace == MonsterFace.left ? 200 : -200, 400);
  479. } else {
  480. Ticker.unregisterDelay(me.timeId_dizzy);
  481. // console.error("眩晕");
  482. //普通受击原地眩晕1秒
  483. this.setAnima(MonsterAnima.hurtDizzy);
  484. me.timeId_dizzy = Ticker.registerDelay(() => {
  485. // console.error("眩晕结束");
  486. me.state = MonsterState.move;
  487. }, 300);
  488. }
  489. }
  490. /**被武器击中*/
  491. hurtWithWeapon( weapon: Weapon): boolean {
  492. // console.error("狼被武器击中");
  493. // console.error(weapon);
  494. let eWPosX = weapon.WPos.x;
  495. let hWposX = this.WPos.x;
  496. if (this.hurt(eWPosX <hWposX,false,true,false)) {
  497. if (this.state != MonsterState.dead) {
  498. // if (weapon.IsAttatch) {
  499. // this.hurtWeapon = weapon.Body();
  500. // this.hurtWeapon.parent = this.weaponAttach;
  501. // this.hurtWeapon.position = cc.v3(0, 0, 0);
  502. // this.hurtWeapon.angle = 0;
  503. // weapon.node.destroy();
  504. // }
  505. }
  506. return true;
  507. } else {
  508. return false;
  509. }
  510. }
  511. private hurtWeapon: cc.Node;
  512. public isDead() {
  513. return this.state == MonsterState.dead;
  514. }
  515. // private heroInLeft:boolean = false;
  516. /**
  517. * 掉落武器
  518. */
  519. protected dropWeapon() {
  520. // if (Math.random() < 0.3) {
  521. // let wPos = this.node.convertToWorldSpaceAR(cc.v2(100, 150));
  522. // this.logErr("掉落武器:" + this.monsteFace + " wPos:" + wPos);
  523. // // this.tmp.parent = this.node.parent;
  524. // // let lPos = this.tmp.parent.convertToNodeSpaceAR(wPos);
  525. // // this.tmp.position = cc.v3(lPos.x,lPos.y,0);
  526. // // this.tmp.active = true;
  527. // let weapon = cc.instantiate(this.weaponPrefab).getComponent(Weapon);
  528. // weapon.node.parent = this.node.parent;
  529. // weapon.SetWPos(wPos);
  530. // weapon.Drop();
  531. // }
  532. }
  533. onBeginContact(contact: cc.PhysicsContact, selfCollider: cc.PhysicsCollider, otherCollider: cc.PhysicsCollider) {
  534. this.logErr("onBeginContact :" + otherCollider.node.group + " " + this.isDestroy);
  535. if (this.isDestroy) { return; }
  536. let otherGroup = otherCollider.node.group;
  537. if (otherGroup == 'ground') {
  538. this.logErr("onBeginContact ground:" + this.state);
  539. if (this.state == MonsterState.born) {
  540. this.state = MonsterState.move;
  541. } else if (this.state == MonsterState.hurt) {
  542. this.state = MonsterState.move;
  543. } else if (this.state == MonsterState.dead) {
  544. this.isDestroy = true;
  545. this.dirX= 0;
  546. this.setSpeed();
  547. // this.changeDirection(0);
  548. Ticker.registerDelay(() => {
  549. if (selfCollider && selfCollider.node) {
  550. this.node.destroy();
  551. }
  552. }, 1000);
  553. }
  554. }
  555. }
  556. // 只在两个碰撞体结束接触时被调用一次
  557. onEndContact(contact: cc.PhysicsContact, selfCollider: cc.PhysicsCollider, otherCollider: cc.PhysicsCollider) {
  558. if (this.isDestroy) { return; }
  559. let otherGroup = otherCollider.node.group;
  560. if (otherGroup == 'board') {
  561. if (this.isInvincible ) {//因为有时候会调用两次
  562. this.moveInScreen();
  563. this.isInvincible = false;
  564. }
  565. }
  566. }
  567. /**出现在屏幕中了*/
  568. protected moveInScreen(){
  569. }
  570. /**无敌 */
  571. private isInvincible:boolean;
  572. /**定格*/
  573. still(){
  574. //暂止动画
  575. //暂停物理
  576. //暂停update
  577. this.anim.pause();
  578. // this.rigidBody.
  579. }
  580. /**取消定格 */
  581. cancelStill(){
  582. this.anim.resume();
  583. }
  584. protected removeListerner(){
  585. Ticker.unregister(this.tickFun,this);
  586. Ticker.unregisterDelay(this.timeId_dizzy);
  587. Ticker.unregisterDelay(this.timerId_init);
  588. // console.error(this.id+" 移除监听");
  589. EventMgr.Instance.remove_event_listenner(GameEvent.HeroDie, this, this.OnHeroDie);
  590. EventMgr.Instance.remove_event_listenner(GameEvent.HeroSuperSkill,this,this.OnHeroSuperSkill);
  591. EventMgr.Instance.remove_event_listenner(GameEvent.GuideStepWolfStop, this, this.OnGuideStepWolfStop);
  592. }
  593. private log(msg) {
  594. return;
  595. console.log(this.id+ "enemy--> " + msg)
  596. }
  597. private logWarn(msg) {
  598. return;
  599. console.warn(this.id+ "enemy--> " + msg)
  600. }
  601. private logErr(msg,forceShow = false) {
  602. if (!forceShow) {
  603. return;
  604. }
  605. return;
  606. console.error(this.id+ "enemy--> " + msg)
  607. }
  608. private isStop: boolean = false;
  609. private stopDirX: number;
  610. public stopMove() {
  611. // console.error("冷冻");
  612. this.isStop = true;
  613. this.stopDirX = this.dirX;
  614. this.dirX = 0
  615. this.setSpeed();
  616. }
  617. public repuseMove(){
  618. // console.error("恢复移动");
  619. this.isStop = false;
  620. this.dirX = this.stopDirX;
  621. this.setSpeed();
  622. }
  623. }