增加个人逻辑
This commit is contained in:
@@ -931,8 +931,8 @@
|
||||
"__expectedType__": "cc.Prefab"
|
||||
},
|
||||
"zd_speed": 0.2,
|
||||
"new_zd_time": 0.2,
|
||||
"createDpTime": 2,
|
||||
"new_zd_time": 0.1,
|
||||
"createDpTime": 3,
|
||||
"dp1_speed": 0.05,
|
||||
"dp2_speed": 0.03,
|
||||
"_id": "aaX4RqMLVAKL2tbj7n23Tn"
|
||||
|
||||
@@ -14,6 +14,12 @@ export class dpComponent extends Component {
|
||||
@property
|
||||
public _dpType = dpImpl.dpType.TYPE1;
|
||||
|
||||
/**控制敌人运动和子弹类型的轮数 */
|
||||
private ns:number = 0;
|
||||
|
||||
/**是否是组合出现 */
|
||||
private isarr:number = 0;
|
||||
|
||||
//飞行最大距离
|
||||
public dp_max:number = 12;
|
||||
|
||||
@@ -23,6 +29,14 @@ export class dpComponent extends Component {
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
//敌人逻辑0:发射单排子弹,横线运动
|
||||
//敌人逻辑1:发射单排子弹,向我方p的z轴靠近
|
||||
//敌人逻辑2:发射散射子弹,横线运动
|
||||
//敌人逻辑3:发射散射子弹,向我方p的z轴靠近
|
||||
|
||||
//前10秒出现的单个敌人 0/1随机一种
|
||||
//20-60秒出现的敌人如果是单个 1/2随机一种,组合出现 0/2随机一种
|
||||
//60秒以上 单个1/2/3随机一种,组合0/1/2随机一种
|
||||
|
||||
const pos = this.node.position;
|
||||
let movez = pos.z + this.dpSpeed;
|
||||
@@ -32,9 +46,15 @@ export class dpComponent extends Component {
|
||||
|
||||
}
|
||||
|
||||
public _init(speed:number){
|
||||
public _init(speed:number,n:number,a:number){
|
||||
this.dpSpeed = speed;
|
||||
this.ns = n;
|
||||
this.isarr = a;
|
||||
}
|
||||
|
||||
/**向我方z轴靠近 */
|
||||
public moveToP(){
|
||||
//控制this.node.x轴逐步接近玩家的x值
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,20 +35,20 @@ export class gameManager extends Component {
|
||||
|
||||
/**发射子弹的间隔*/
|
||||
@property
|
||||
public new_zd_time = 0.2;
|
||||
public new_zd_time = 0.1;
|
||||
|
||||
/**当前发射子弹的间隔*/
|
||||
public _new_zd_time = 0;
|
||||
|
||||
/**敌人生成的间隔时间 */
|
||||
@property
|
||||
public createDpTime = 2;
|
||||
public createDpTime = 3;
|
||||
|
||||
/**当前敌人生成的时间 */
|
||||
public _createDpTime = 0;
|
||||
|
||||
/**组合间隔状态 */
|
||||
public _createDpArr = dpImpl.dpArr.dps1;
|
||||
public _createDpArr = 0;
|
||||
|
||||
@property
|
||||
public dp1_speed:number = 0.05;
|
||||
@@ -58,6 +58,8 @@ export class gameManager extends Component {
|
||||
|
||||
private _isTouch:boolean = false;
|
||||
|
||||
private lasttype:number = 0;
|
||||
|
||||
start() {
|
||||
this._new_zd_time = this.new_zd_time;
|
||||
this.changeDpMode();
|
||||
@@ -71,21 +73,37 @@ export class gameManager extends Component {
|
||||
this._new_zd_time = 0;
|
||||
}
|
||||
|
||||
if(this._createDpArr === dpImpl.dpArr.dps1){
|
||||
this._createDpTime += deltaTime;
|
||||
if(this._createDpArr <= 2){
|
||||
|
||||
this._createDpTime += deltaTime;
|
||||
if(this._createDpTime > this.createDpTime){
|
||||
this.cerateDp();
|
||||
this.cerateDp(0);
|
||||
this._createDpTime = 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
if(this._createDpTime > this.createDpTime * 0.8){
|
||||
let rm = math.randomRangeInt(1,3);
|
||||
|
||||
if(rm == 2 && this.lasttype == 0){
|
||||
this.cerateDpArr(this._createDpArr > 2 && this._createDpArr <= 6 ? 1:2);
|
||||
this.lasttype=1;
|
||||
}
|
||||
else{
|
||||
this.cerateDp(this._createDpArr > 2 && this._createDpArr <= 6 ? 1:2);
|
||||
this.lasttype=0;
|
||||
}
|
||||
|
||||
this._createDpTime = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public cerateDp() {
|
||||
|
||||
public cerateDp(n:number) {
|
||||
|
||||
let randm = math.randomRangeInt(1,3);
|
||||
let p:Prefab = null;
|
||||
@@ -103,12 +121,26 @@ export class gameManager extends Component {
|
||||
const dp = instantiate(p);
|
||||
dp.setParent(this.node);
|
||||
const dpc = dp.getComponent(dpComponent);
|
||||
dpc._init(speed);
|
||||
dpc._init(speed,n,0);
|
||||
let loc = math.randomRange(-3.8,3.8);
|
||||
dp.setPosition(loc, 1, -dpc.dp_max);
|
||||
|
||||
}
|
||||
|
||||
public cerateDpArr(n:number) {
|
||||
|
||||
let parr = new Array<Node>(5);
|
||||
for (let i = 0; i < parr.length; i++) {
|
||||
let randm = math.randomRangeInt(1,3);
|
||||
parr[i] = instantiate(randm==1?this.dp1:this.dp2);
|
||||
parr[i].setParent(this.node);
|
||||
const dpc = parr[i].getComponent(dpComponent);
|
||||
dpc._init(randm==1?this.dp1_speed:this.dp2_speed,n,1);
|
||||
parr[i].setPosition(i*1.8-3.6, 1, -dpc.dp_max);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public createZd(){
|
||||
const zd01 = instantiate(this.zd1);
|
||||
zd01.setParent(this.zdOut);
|
||||
|
||||
Reference in New Issue
Block a user