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.
47 lines
1.5 KiB
47 lines
1.5 KiB
|
3 weeks ago
|
/**
|
||
|
|
* 地图生长藤蔓
|
||
|
|
*/
|
||
|
|
import { _decorator, Component } from 'cc';
|
||
|
|
import { ChapterNewPlayTypeEnum } from '../../../game/ChapterPlayTypes';
|
||
|
|
import { MapObstacle, ObstacleType } from '../MapObstacle';
|
||
|
|
const { ccclass } = _decorator;
|
||
|
|
|
||
|
|
@ccclass('MechanismVinesGrassSchedule')
|
||
|
|
export class MechanismVinesGrassSchedule extends Component {
|
||
|
|
|
||
|
|
_dt: number = 0
|
||
|
|
start() {
|
||
|
|
|
||
|
|
}
|
||
|
|
protected update(dt: number): void {
|
||
|
|
if (!gg.game.CurentBattle.canUpdateFrame()) return;
|
||
|
|
this._dt += dt * gg.game.CurentBattle.TimeScale;
|
||
|
|
if (this._dt >= 1) {
|
||
|
|
this._dt = 0
|
||
|
|
this.checkVinesGrassLaunchTime()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/**检查是否到了攻击时间 */
|
||
|
|
checkVinesGrassLaunchTime() {
|
||
|
|
let vinesGrassTimeArr = gg.data.project.getChapterNewPlayInfo(ChapterNewPlayTypeEnum.VinesGrass)
|
||
|
|
if (vinesGrassTimeArr && vinesGrassTimeArr.length > 0 && gg.game.CurentBattle.BattleTime >= vinesGrassTimeArr[0]) {
|
||
|
|
vinesGrassTimeArr.shift()
|
||
|
|
this.releaseVinesGrass()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
/**生长藤蔓 */
|
||
|
|
releaseVinesGrass() {
|
||
|
|
//随机释放1-3个
|
||
|
|
let num = 1
|
||
|
|
let randomPosArr = gg.game.CurentBattle.Map.getRandomCanPutObstacleMapGrids(num);
|
||
|
|
for (let i = 0; i < randomPosArr.length; i++) {
|
||
|
|
let grid = randomPosArr[i];
|
||
|
|
let comp = grid.getComponent(MapObstacle);
|
||
|
|
comp.setObstacle(ObstacleType.藤蔓);
|
||
|
|
grid.isCanPutGrid = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|