|
@@ -1,4 +1,4 @@
|
|
-import { _decorator, CCBoolean, CCFloat, Collider, Component, isValid, ITriggerEvent, Material, Node, PhysicsSystem, Quat, RigidBody, tween, Tween, Vec3 } from 'cc';
|
|
|
|
|
|
+import { _decorator, CCBoolean, CCFloat, Collider, Component, isValid, ITriggerEvent, Material, MeshRenderer, Node, PhysicsSystem, Quat, RigidBody, tween, Tween, Vec3 } from 'cc';
|
|
import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
|
|
import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
|
|
import { GameEvent } from '../Enum/GameEvent';
|
|
import { GameEvent } from '../Enum/GameEvent';
|
|
|
|
|
|
@@ -81,6 +81,15 @@ export class EnemyComponent extends Component {
|
|
// 检查是否是当前怪物节点被击中
|
|
// 检查是否是当前怪物节点被击中
|
|
if (this.node === hitNode && this.status === EnemyStatus.LIFE) {
|
|
if (this.node === hitNode && this.status === EnemyStatus.LIFE) {
|
|
this.status = EnemyStatus.DIE;
|
|
this.status = EnemyStatus.DIE;
|
|
|
|
+
|
|
|
|
+ // 修改所有部位材质为击中材质
|
|
|
|
+ this.changeMaterial(this.head);
|
|
|
|
+ this.changeMaterial(this.body);
|
|
|
|
+ this.changeMaterial(this.leftHand);
|
|
|
|
+ this.changeMaterial(this.rightHand);
|
|
|
|
+ this.changeMaterial(this.leftFoot);
|
|
|
|
+ this.changeMaterial(this.rightFoot);
|
|
|
|
+
|
|
this.playHitTwitch();
|
|
this.playHitTwitch();
|
|
this.scheduleOnce(() => {
|
|
this.scheduleOnce(() => {
|
|
this.rigidBody.isKinematic = false;
|
|
this.rigidBody.isKinematic = false;
|
|
@@ -89,6 +98,14 @@ export class EnemyComponent extends Component {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private changeMaterial(node: Node) {
|
|
|
|
+ if (!node || !this.hitMaterial) return;
|
|
|
|
+ const renderer = node.getComponent(MeshRenderer);
|
|
|
|
+ if (renderer) {
|
|
|
|
+ renderer.material = this.hitMaterial;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// 中枪抽搐效果
|
|
// 中枪抽搐效果
|
|
playHitTwitch() {
|
|
playHitTwitch() {
|
|
// 抖动参数配置
|
|
// 抖动参数配置
|