基于四方向A星寻路延展的连连看

本文探讨了如何将四向A星寻路算法应用于连连看游戏中,详细介绍了在加1限制条件下可能遇到的连线失败问题,并展示了实现效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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++;
                }
            }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值