const ADVCT = require("adventure_controller"); //处理方块边界碰撞问题 cc.Class({ extends: cc.Component, properties: { Left:{ default:null, type:cc.Node }, Right:{ default:null, type:cc.Node }, Ups:{ default:null, type:cc.Node }, Downs:{ default:null, type:cc.Node }, }, // LIFE-CYCLE CALLBACKS: onLoad () { this.index = null; }, start () { }, upCollision(index){ let data = ADVCT.getInstance().getRoomDataByIndex(index); let xy = data.room_id[0]; this.checkFogPath(xy); }, //检测解锁迷雾路径 checkFogPath(path){ //四面解锁的一定也是解锁的,所以不需要cloud //边缘地带的需要本身未解锁才能确认需不需要cloud let x = path.x; let y = path.y; let is_left = false; let is_right = false; let is_up = false; let is_down = false; let limit_index = 0; let up = [x,y + 1]; let updata = ADVCT.getInstance().getRoomDataByXY(up[0],up[1]); if(updata && updata.lock == 0){ limit_index++; is_up = true; } let down = [x,y - 1]; let dodata = ADVCT.getInstance().getRoomDataByXY(down[0],down[1]); if(dodata && dodata.lock == 0){ limit_index++; is_down = true; } let left = [x - 1,y]; let ldata = ADVCT.getInstance().getRoomDataByXY(left[0],left[1]); if(ldata && ldata.lock == 0){ limit_index++; is_left = true; } let right = [x + 1,y]; let rdata = ADVCT.getInstance().getRoomDataByXY(right[0],right[1]); if(rdata && rdata.lock == 0){ limit_index++; is_right = true; } if(limit_index == 4){//四面皆有 return; } this.Ups.active = is_up; this.Downs.active = is_down; this.Left.active = is_left; this.Right.active = is_right; }, // update (dt) {}, });