import { _decorator, Component, Node } from 'cc'; import { UmUtil } from '../../../../cc-common/cc-util/UmUtil'; import { Vec3 } from 'cc'; import { EnemyMove } from '../enemy/EnemyMove'; import { UmLog } from '../../../../cc-common/cc-util/UmLog'; import { EMOVE_MODE } from '../../config/GameDefine'; import { BossBase } from './BossBase'; const { ccclass, property } = _decorator; @ccclass('BossMelee') export class BossMelee extends BossBase { setMoveData(data) { super.setMoveData(data); this.changeMoveMode(EMOVE_MODE.FREE); UmLog.log("BossMelee => setmovedata"); } setIsContactObstacle(isContact) { // UmLog.log("[CreepMove] => setIsContactObstacle ", isContact); this.isContactObstacle = isContact; } setIsSensorHero(isContact) { this.isSensorHero = isContact; this.speed = this.isSensorHero ? this.moveSpeed * 4 : this.moveSpeed; if (isContact && this.heroTarget) { // UmLog.log("setIsSensorHero attackType = ", this.attackType); this.changeMoveMode(EMOVE_MODE.RANGE); } else { this.changeMoveMode(EMOVE_MODE.FREE); } } setIsContactHero(isContact) { // UmLog.log("setIsContactHero => ", isContact); this.isContactHero = isContact; if (isContact) { this.changeMoveMode(EMOVE_MODE.RANGE); } else { if (this.isSensorHero && this.heroTarget) {// && this.attackType == EATTACK_TYPE.MELEE this.changeMoveMode(EMOVE_MODE.RANGE); } else { this.changeMoveMode(EMOVE_MODE.FREE); } } } protected updateMove(dt: number): void { if (this.moveMode == EMOVE_MODE.FREE) { this.node.position = this.getMoveTowardPoint(this.nextDestinationMove, dt); if ((this.isContactObstacle && !this.isContactHero) || Vec3.distance(this.node.position, this.nextDestinationMove) < 1) this.makeNewRandomTarget(); return; } if (this.moveMode == EMOVE_MODE.RANGE && this.heroTarget) { UmLog.log("move range"); var direction = UmUtil.subtractTwoVector3(this.node.position, this.heroTarget.position); this.node.position = this.getMoveTowardPoint(UmUtil.plusTwoVector3(this.node.position, direction), dt); return; } } }