|
@@ -26,6 +26,8 @@ export default class UEGridMap extends UEBase {
|
|
|
cellPrefab: cc.Prefab = null!;
|
|
|
@property(cc.Prefab)
|
|
|
cubePrefab: cc.Prefab = null!;
|
|
|
+ @property(cc.Prefab)
|
|
|
+ cellSelectPrefab: cc.Prefab = null!;
|
|
|
@property(cc.Node)
|
|
|
gridLayer: cc.Node = null;
|
|
|
@property(cc.Node)
|
|
@@ -43,10 +45,14 @@ export default class UEGridMap extends UEBase {
|
|
|
private lastMoveCell: UECell = null!;
|
|
|
private clickCnt: number = 0;
|
|
|
private ueMergeTip: UEMergeTip;
|
|
|
+ private cellSelect: cc.Node = null!;
|
|
|
Init() {
|
|
|
this.ueMergeTip = AssetMgr.instantiateUE(UEMergeTip);
|
|
|
this.tipLayer.addChild(this.ueMergeTip.node);
|
|
|
this.ueMergeTip.node.active = false;
|
|
|
+ this.cellSelect = cc.instantiate(this.cellSelectPrefab);
|
|
|
+ this.tipLayer.addChild(this.cellSelect);
|
|
|
+ this.cellSelect.active = false;
|
|
|
GameDataCenter.gridMap.Init(this);
|
|
|
this.gridLayer.setContentSize(GridConstant.CELL_WIDTH * GridConstant.ROW, GridConstant.CELL_WIDTH * GridConstant.COL);
|
|
|
// 计算缩放比例
|
|
@@ -72,12 +78,23 @@ export default class UEGridMap extends UEBase {
|
|
|
this.initEvent(GridEvent.HC_INFO_RSP, this.LoadMapData);
|
|
|
this.initEvent(GridEvent.HC_MERGE_RSP, this.OnHcMergeRsp);
|
|
|
this.initEvent(GridEvent.HC_FIGHT_OVER, this.OnHcFightOver);
|
|
|
+ this.initEvent(GridEvent.HC_CELL_SELECT, this.OnHcCellSelect);
|
|
|
}
|
|
|
|
|
|
public GetCubeLayer() {
|
|
|
return this.cubeLayer;
|
|
|
}
|
|
|
|
|
|
+ /** 监听格子选中 */
|
|
|
+ private OnHcCellSelect(idx: number) {
|
|
|
+ if (!idx) {
|
|
|
+ this.cellSelect.active = false;
|
|
|
+ } else {
|
|
|
+ this.cellSelect.active = true;
|
|
|
+ this.cellSelect.setPosition(GameDataCenter.gridMap.GetPosByIdx(idx));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
/** 加载地图数据 */
|