You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
6.1 KiB
175 lines
6.1 KiB
|
3 weeks ago
|
import { _decorator, Component, Node } from 'cc';
|
||
|
|
import { ChapterNewPlayTypeEnum } from '../../../game/ChapterPlayTypes';
|
||
|
|
import { SdfHoleController } from './SdfHoleController';
|
||
|
|
import { GEvent } from 'db://assets/mx/module/event/GEvent';
|
||
|
|
import { ObstacleType } from '../MapObstacle';
|
||
|
|
import { chuifengjiSchedule } from './chuifengjiSchedule';
|
||
|
|
const { ccclass, property } = _decorator;
|
||
|
|
/*
|
||
|
|
//需要shader
|
||
|
|
1、每过两波,浓雾会向下蔓延一段,最终蔓延到离玩家2-3格区域
|
||
|
|
2、浓雾覆盖区域,怪物看不见,可被击中
|
||
|
|
3、可摆放吹风机障碍物,吹散障碍物为中心的一片圆形区域一定时间,冷却一段时间再释放
|
||
|
|
4、美女以及下方默认驱散自身周围一片区域
|
||
|
|
5、浓雾不会覆盖编辑状态下的可编辑提示,以及怪物行进路线
|
||
|
|
*/
|
||
|
|
|
||
|
|
|
||
|
|
// //新机制大雾
|
||
|
|
// export class IFogAndWindProperty {
|
||
|
|
// //时间间隔
|
||
|
|
// limitNum: number = 0 //限制次数
|
||
|
|
// timeInterval: number = 0 //时间间隔
|
||
|
|
// //大雾下降的距离
|
||
|
|
// fogDownDistance: number = 0
|
||
|
|
// }
|
||
|
|
|
||
|
|
@ccclass('newMechanismFog')
|
||
|
|
export class newMechanismFog extends Component {
|
||
|
|
@property(Node)
|
||
|
|
fogNode: Node = null
|
||
|
|
|
||
|
|
limitNum: number=0;
|
||
|
|
timeInterval: number=0;
|
||
|
|
fogDownDistance: number=0;
|
||
|
|
limitNumFix: number=0;
|
||
|
|
statrTime = 0
|
||
|
|
|
||
|
|
fixedPoints: Node[] = []
|
||
|
|
fogController: SdfHoleController = null
|
||
|
|
|
||
|
|
isCanMove: boolean = true
|
||
|
|
fixPosi = 1000
|
||
|
|
fixPosi2 = 800
|
||
|
|
fixPosi3 = 200
|
||
|
|
onEnable(){
|
||
|
|
GEvent.Ins.on(GEvent.ChuifengjiEvent, this.moveToOriginalPosition, this)
|
||
|
|
}
|
||
|
|
onDisable(){
|
||
|
|
GEvent.Ins.off(GEvent.ChuifengjiEvent, this.moveToOriginalPosition, this)
|
||
|
|
}
|
||
|
|
|
||
|
|
moveToOriginalPosition(isCanMove: boolean){
|
||
|
|
this.isCanMove = false
|
||
|
|
if(!isCanMove){
|
||
|
|
this.stratWuqiAnim(this.fixPosi)
|
||
|
|
this.node.getChildByName('风扇').active = true
|
||
|
|
this.scheduleOnce(() => {
|
||
|
|
this.node.getChildByName('风扇').active = false
|
||
|
|
}, 3)
|
||
|
|
}else{
|
||
|
|
this.node.getChildByName('风扇').active = false
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
// setPoints(node: Node[]){
|
||
|
|
// this.fixedPoints.push(...node)
|
||
|
|
// }
|
||
|
|
start() {
|
||
|
|
this.fogController = this.fogNode.getComponent(SdfHoleController);
|
||
|
|
let children = gg.game.CurentBattle.Map.mapTargetParent.children
|
||
|
|
for(let child of children){
|
||
|
|
//创建effectNode
|
||
|
|
let meinv = child.getChildByName('美女')
|
||
|
|
if(meinv){
|
||
|
|
this.fixedPoints.push(meinv)
|
||
|
|
}else{
|
||
|
|
let obsSpr = child.getChildByName('obsSpr')
|
||
|
|
if(obsSpr){
|
||
|
|
this.fixedPoints.push(obsSpr)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
let IFogAndWindPropertyData = gg.data.project.getChapterNewPlayInfo(ChapterNewPlayTypeEnum.FogAndWind)
|
||
|
|
// console.log('IFogAndWindPropertyData',IFogAndWindPropertyData)
|
||
|
|
this.limitNum = 0
|
||
|
|
this.limitNumFix = IFogAndWindPropertyData.limitNum
|
||
|
|
this.timeInterval = IFogAndWindPropertyData.timeInterval
|
||
|
|
this.fogDownDistance = IFogAndWindPropertyData.fogDownDistance
|
||
|
|
this.stratWuqiAnim()
|
||
|
|
this.schedule(this.updateTemperature, 1)
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
updateTemperature(dt: number) {
|
||
|
|
//检测是不是可以移动
|
||
|
|
if (!gg.game.CurentBattle.canUpdateFrame()) return;
|
||
|
|
|
||
|
|
//检测有没有障碍物
|
||
|
|
// let arr = gg.game.CurentBattle.getObstaclesByType(ObstacleType.吹风机)
|
||
|
|
// if(arr.length>0 && !this.isCanMove){
|
||
|
|
// let isCanMove = true
|
||
|
|
// for(let item of arr){
|
||
|
|
// if(item.ObstacleNode){
|
||
|
|
// let chuifengji = item.ObstacleNode
|
||
|
|
// if(chuifengji && chuifengji.getComponent(chuifengjiSchedule)){
|
||
|
|
// isCanMove = chuifengji.getComponent(chuifengjiSchedule).getIsCanMove()
|
||
|
|
// if(!isCanMove){
|
||
|
|
// isCanMove = false
|
||
|
|
// break
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// if(!isCanMove){
|
||
|
|
// this.isCanMove = false
|
||
|
|
// }else{
|
||
|
|
|
||
|
|
// if(this.limitNum<this.limitNumFix){
|
||
|
|
|
||
|
|
// }else{
|
||
|
|
// this.limitNum = this.limitNumFix-1
|
||
|
|
// }
|
||
|
|
|
||
|
|
// console.log('this.fogDownDistance*this.limitNum',this.fogDownDistance*this.limitNumFix)
|
||
|
|
// //初始1000 ,从600开始位置 所以现在是400+下降距离*限制次数
|
||
|
|
// this.fogController.startMove(this.fixPosi3+this.fogDownDistance*this.limitNum, 8)
|
||
|
|
// this.fogController.checkAndActivateHoles(this.fixedPoints);
|
||
|
|
// this.isCanMove = true
|
||
|
|
// this.statrTime = 0
|
||
|
|
// }
|
||
|
|
|
||
|
|
// }else{
|
||
|
|
// if(arr.length == 0 && !this.isCanMove){
|
||
|
|
// this.isCanMove = true
|
||
|
|
// this.fogController.startMove(this.fixPosi2+this.fogDownDistance*this.limitNum,8)
|
||
|
|
// this.fogController.checkAndActivateHoles(this.fixedPoints);
|
||
|
|
// this.isCanMove = true
|
||
|
|
// this.statrTime = 0
|
||
|
|
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
//检测是不是
|
||
|
|
this.statrTime += dt * gg.game.CurentBattle.TimeScale;
|
||
|
|
//console.log('this.statrTime',this.statrTime, this.limitNum, this.timeInterval)
|
||
|
|
|
||
|
|
if(this.statrTime>=this.timeInterval && this.limitNum<this.limitNumFix){
|
||
|
|
this.statrTime=0
|
||
|
|
this.limitNum++
|
||
|
|
// console.log('this.limitNum',this.limitNum)
|
||
|
|
|
||
|
|
//开始移动
|
||
|
|
if (this.fogController && this.isCanMove) {
|
||
|
|
this.fogController.startMove(this.fogDownDistance)
|
||
|
|
this.fogController.checkAndActivateHoles(this.fixedPoints);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
stratWuqiAnim(moveY = this.fixPosi2){
|
||
|
|
this.fogController.returnToOriginalPosition(moveY)
|
||
|
|
}
|
||
|
|
|
||
|
|
// testClick(){
|
||
|
|
// // this.limitNum = 0
|
||
|
|
// this.statrTime = 0
|
||
|
|
// this.fogController.returnToOriginalPosition()
|
||
|
|
// }
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|