module ui {
export interface BlockData {
x: number,/**横向第几位 */
y: number,/**竖向第几位 */
tag: number,/**能否通过,0可以,1不行 */
}
export interface TagData {
tag: number,
index: number
}
export enum Direction {
up = 1,
down = 2,
left = 3,
right = 4
}
export class AStarUI extends eui.Component implements network.IMessage {
private blockGroup: eui.Group;
private line_group: eui.Group;
private btnReset: eui.Button;
private mask_rect: eui.Rect;
public static startBlock: ui.Block = null;
public static endBlock: ui.Block = null;
private blockMap: { [ind: number]: ui.Block } = {};
private openList: ui.Block[] = [];
private closeList: ui.Block[] = [];
constructor() {
super();
this.addEventListener(eui.UIEvent.COMPLETE, this.uiComplete, this);
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.addToStage, this);
this.skinName = "resource/ui/aStarWin.exml";
}
private uiComplete(): void {
this.mask_rect.visible = false;
this.blockGroup.removeChildren();
let x1 = 1,
y1 = 1;
let tagArr = this.getTagArr();
for (let i = 0; i < 100; i++) {/**设置一10x10地图块 */
let data: ui.BlockData = { x: x1, y: y1, tag: tagArr[i].tag };
let block: ui.Block = new ui.Block(data);
this.blockGroup.addChild(block);
this.blockMap[x1 + "" + y1] = block;/**块对应键存入 */
x1++;
if (x1 == 11) {
x1 = 1;
y1++;
}
}