Commit 3aaa6993 authored by haiyoucuv's avatar haiyoucuv

init

parent a0ce4989
...@@ -41,6 +41,15 @@ export class AISnake extends Snake { ...@@ -41,6 +41,15 @@ export class AISnake extends Snake {
private assistTarget: AISnake = null; // 正在协助的AI蛇 private assistTarget: AISnake = null; // 正在协助的AI蛇
death() {
super.death();
this.node.removeFromParent();
this.destroy();
MainGame.ins.initAnimal(1);
}
private get difficultyParams() { private get difficultyParams() {
return { return {
reactionTime: math.lerp(0.8, 0.2, (this.difficulty - 1) / 4), reactionTime: math.lerp(0.8, 0.2, (this.difficulty - 1) / 4),
...@@ -560,7 +569,7 @@ export class AISnake extends Snake { ...@@ -560,7 +569,7 @@ export class AISnake extends Snake {
} }
private executeEscaping() { private executeEscaping() {
if (!this.escapeTarget) { if (!this.escapeTarget?.isLife) {
// 如果没有特定的逃离目标,检查并避开所有潜在威胁 // 如果没有特定的逃离目标,检查并避开所有潜在威胁
this.avoidAllThreats(); this.avoidAllThreats();
return; return;
......
...@@ -154,6 +154,8 @@ export class Snake extends Component { ...@@ -154,6 +154,8 @@ export class Snake extends Component {
.call(() => { .call(() => {
PoolManager.instance.putNode(otherCollider.node); PoolManager.instance.putNode(otherCollider.node);
if (!this.isLife) return;
if (foodType == FoodType.FOOD) { if (foodType == FoodType.FOOD) {
this.addEnergy(1); this.addEnergy(1);
} }
...@@ -306,6 +308,7 @@ export class Snake extends Component { ...@@ -306,6 +308,7 @@ export class Snake extends Component {
this.node.active = false; this.node.active = false;
this.initFond(this.bodyArr.length); this.initFond(this.bodyArr.length);
} }
protected getNewPos(angle: number, dt: number, currentPos: Vec3, speed: number = this.speed): Vec3 { protected getNewPos(angle: number, dt: number, currentPos: Vec3, speed: number = this.speed): Vec3 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment