76 lines
2.5 KiB
TypeScript
76 lines
2.5 KiB
TypeScript
import { _decorator, Component, Node } from 'cc';
|
|
import { LayoutManager } from '../LayoutManager';
|
|
import { UmClientEvent } from '../../../../cc-common/cc-util/UmOneToMultiListener';
|
|
import { EMOVE_MODE, GameDefine } from '../../config/GameDefine';
|
|
import { BossBase } from './BossBase';
|
|
import { Vec3 } from 'cc';
|
|
import { UmLog } from '../../../../cc-common/cc-util/UmLog';
|
|
import { UmUtil } from '../../../../cc-common/cc-util/UmUtil';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('Boss')
|
|
export class Boss 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;
|
|
}
|
|
}
|
|
}
|
|
|