优化敌人动态逻辑
This commit is contained in:
@@ -23,6 +23,8 @@ export class dpComponent extends Component {
|
|||||||
//飞行最大距离
|
//飞行最大距离
|
||||||
public dp_max:number = 12;
|
public dp_max:number = 12;
|
||||||
|
|
||||||
|
private mx: any = 1;
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
|
||||||
this.p_an.crossFade('p_an', .5);
|
this.p_an.crossFade('p_an', .5);
|
||||||
@@ -38,9 +40,14 @@ export class dpComponent extends Component {
|
|||||||
//20-60秒出现的敌人如果是单个 1/2随机一种,组合出现 0/2随机一种
|
//20-60秒出现的敌人如果是单个 1/2随机一种,组合出现 0/2随机一种
|
||||||
//60秒以上 单个1/2/3随机一种,组合0/1/2随机一种
|
//60秒以上 单个1/2/3随机一种,组合0/1/2随机一种
|
||||||
|
|
||||||
|
/** 此类中只对敌人路线做逻辑处理,子弹发射在子弹类中 */
|
||||||
|
if(this.node.position.x>3.8) this.mx = -1;
|
||||||
|
if(this.node.position.x<-3.8) this.mx = 1;
|
||||||
|
|
||||||
const pos = this.node.position;
|
const pos = this.node.position;
|
||||||
let movez = pos.z + this.dpSpeed;
|
let movez = pos.z + this.dpSpeed;
|
||||||
this.node.setPosition(pos.x, pos.y, movez);
|
|
||||||
|
this.node.setPosition(this.node.position.x + 0.03 * this.mx, pos.y, movez);
|
||||||
|
|
||||||
if(movez > this.dp_max) this.node.destroy();
|
if(movez > this.dp_max) this.node.destroy();
|
||||||
|
|
||||||
@@ -55,6 +62,7 @@ export class dpComponent extends Component {
|
|||||||
/**向我方z轴靠近 */
|
/**向我方z轴靠近 */
|
||||||
public moveToP(){
|
public moveToP(){
|
||||||
//控制this.node.x轴逐步接近玩家的x值
|
//控制this.node.x轴逐步接近玩家的x值
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,11 +111,11 @@ export class gameManager extends Component {
|
|||||||
let t = 1;
|
let t = 1;
|
||||||
if(randm === dpImpl.dpType.TYPE1){
|
if(randm === dpImpl.dpType.TYPE1){
|
||||||
p = this.dp1;
|
p = this.dp1;
|
||||||
speed = this.dp1_speed;
|
speed = this.dp1_speed+(math.randomRange(0.01,0.02)*(math.randomRangeInt(-1,2)));
|
||||||
t=1;
|
t=1;
|
||||||
}else{
|
}else{
|
||||||
p = this.dp2;
|
p = this.dp2;
|
||||||
speed = this.dp2_speed;
|
speed = this.dp2_speed+(math.randomRange(0.01,0.02)*(math.randomRangeInt(-1,2)));
|
||||||
t=2;
|
t=2;
|
||||||
}
|
}
|
||||||
const dp = instantiate(p);
|
const dp = instantiate(p);
|
||||||
@@ -135,7 +135,7 @@ export class gameManager extends Component {
|
|||||||
parr[i] = instantiate(randm==1?this.dp1:this.dp2);
|
parr[i] = instantiate(randm==1?this.dp1:this.dp2);
|
||||||
parr[i].setParent(this.node);
|
parr[i].setParent(this.node);
|
||||||
const dpc = parr[i].getComponent(dpComponent);
|
const dpc = parr[i].getComponent(dpComponent);
|
||||||
dpc._init(randm==1?this.dp1_speed:this.dp2_speed,n,1);
|
dpc._init(randm==1?this.dp1_speed+(math.randomRange(0.01,0.02)*(math.randomRangeInt(-1,2))):this.dp2_speed+(math.randomRange(0.01,0.02)*(math.randomRangeInt(-1,2))),n,1);
|
||||||
parr[i].setPosition(i*1.8-3.6, 1, -dpc.dp_max);
|
parr[i].setPosition(i*1.8-3.6, 1, -dpc.dp_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user