var t = require; var e = module; var i = exports; var s, e = (this && this.__decorate) || function (t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }; Object.defineProperty(i, "__esModule", {value: !0}); const r = t("MapType"), u = t("MapRoadUtils"), {ccclass: o} = cc._decorator; t = s = class extends cc.Component { constructor() { super(...arguments), (this._roadPointDic = {}), (this._roadNodeDic = {}), (this._graphicDic = {}), (this._roadTypeShowDic = {}), (this._type = 1), (this._gsize = 16), (this.blockScale = 0.95); } onLoad() { (this._roadTypeShowDic[0] = !0), (this._roadTypeShowDic[1] = !0), (this._roadTypeShowDic[2] = !0), (this._roadTypeShowDic[3] = !0), (this._roadTypeShowDic[4] = !0), (this._roadTypeShowDic[5] = !0), (this._roadTypeShowDic[6] = !0), (this._roadTypeShowDic[7] = !0), (this._roadTypeShowDic[8] = !0), (this._roadTypeShowDic[9] = !0); } initRoadPointInfo(i) { if ((this.clear(), i.roadDataArr && 0 != i.roadDataArr.length)) { var t = i.roadDataArr.length, s = i.roadDataArr[0].length; for (let e = 0; e < t; e++) for (let t = 0; t < s; t++) { const o = i.roadDataArr[e][t], a = u.default.instance.getNodeByDerect(t, e); (a.value = o), 1 != a.value && (this._roadNodeDic[a.dx + "_" + a.dy] = a); } this.drawRointPoint(); } } getRoadPointInfo() { for (var t = u.default.instance.row, e = u.default.instance.col, i = [], s = 0; s < 2 * t; s++) { i[s] = []; for (var o = 0; o < e; o++) null == this._roadNodeDic[o + "_" + s] ? (i[s][o] = 1) : (i[s][o] = this._roadNodeDic[o + "_" + s].value); } return i; } drawRointPoint() { var t = u.default.instance.row, e = u.default.instance.col, i = u.default.instance.mapType, s = t / this._gsize; i == r.MapType.angle45 && (s = (2 * t) / this._gsize); for (var o = e / this._gsize, a = 0; a < s; a++) for (var n = 0; n < o; n++) this.drawGraphic(n, a); } drawGraphic(t, i, e = !0) { var s = this.getGraphic(t + "_" + i); e && s.clear(); var o = u.default.instance.halfNodeWidth, a = u.default.instance.halfNodeHeight, n = u.default.instance.mapType, r = "00ff0050", l = t * this._gsize, h = l + this._gsize, i = i * this._gsize, c = i + this._gsize; for (let e = i; e < c; e++) for (let t = l; t < h; t++) { var d = this._roadNodeDic[t + "_" + e]; d && this._roadTypeShowDic[d.value] && (0 == d.value ? (r = "#00ff0050") : 1 == d.value ? (r = "#d4d4d450") : 2 == d.value ? (r = "#0000ff50") : 3 == d.value && (r = "#ffff0050"), 0 == n && this.draw45AngleMapRoadPoint(s, d, r, o, a), 1 == n ? this.draw90AngleMapRoadPoint(s, d, r, o, a) : 2 == n && this.drawHoneycombMapRoadPoint(s, d, r, o, a)); } } getGraphic(t) { var e; return ( this._graphicDic[t] || (((e = new cc.Node()).parent = this.node), (e.position = cc.v2(0, 0)), (e = e.addComponent(cc.Graphics)), (this._graphicDic[t] = e)), this._graphicDic[t] ); } draw45AngleMapRoadPoint(t, e, i, s, o) { t.fillColor.fromHEX(i), t.moveTo(-s * this.blockScale + e.px, 0 + e.py), t.lineTo(0 + e.px, -o * this.blockScale + e.py), t.lineTo(s * this.blockScale + e.px, 0 + e.py), t.lineTo(0 + e.px, o * this.blockScale + e.py), t.fill(); } draw90AngleMapRoadPoint(t, e, i, s, o) { t.fillColor.fromHEX(i), t.rect( -s * this.blockScale + e.px, -o * this.blockScale + e.py, s * this.blockScale * 2, o * this.blockScale * 2 ), t.fill(); } drawHoneycombMapRoadPoint(t, e, i, s, o) { t.fillColor.fromHEX(i); var a = u.default.instance.nodeWidth * this.blockScale, n = u.default.instance.nodeHeight * this.blockScale, r = a / 4, l = 3 * r, h = n / 2, c = -2 * r, i = -h; t.moveTo(c + r + e.px, i + e.py), t.lineTo(c + l + e.px, i + e.py), t.lineTo(c + a + e.px, h + i + e.py), t.lineTo(c + l + e.px, n + i + e.py), t.lineTo(c + r + e.px, n + i + e.py), t.lineTo(0 + c + e.px, h + i + e.py), t.lineTo(c + r + e.px, i + e.py), t.fill(); } addRoadPoint(t) { this._roadNodeDic[t.dx + "_" + t.dy] = t; var e = Math.floor(t.dx / this._gsize), t = Math.floor(t.dy / this._gsize); this.drawGraphic(e, t); } addRoadPoints(t) { for (var e, i = {}, s = 0; s < t.length; s++) { this._roadNodeDic[t[s].dx + "_" + t[s].dy] = t[s]; var o = Math.floor(t[s].dx / this._gsize), a = Math.floor(t[s].dy / this._gsize); i[o + "_" + a] = [o, a]; } for (e in i) this.drawGraphic(i[e][0], i[e][1]); } removeRoadPoint(t) { null != this._roadNodeDic[t.dx + "_" + t.dy] && ((this._roadNodeDic[t.dx + "_" + t.dy] = null), delete this._roadNodeDic[t.dx + "_" + t.dy]); var e = Math.floor(t.dx / this._gsize), t = Math.floor(t.dy / this._gsize); this.drawGraphic(e, t); } removeRoadPoints(t) { for (var e, i = {}, s = 0; s < t.length; s++) { null != this._roadNodeDic[t[s].dx + "_" + t[s].dy] && ((this._roadNodeDic[t[s].dx + "_" + t[s].dy] = null), delete this._roadNodeDic[t[s].dx + "_" + t[s].dy]); var o = Math.floor(t[s].dx / this._gsize), a = Math.floor(t[s].dy / this._gsize); i[o + "_" + a] = [o, a]; } for (e in i) this.drawGraphic(i[e][0], i[e][1]); } changeRoadPointStyle() { for (var t in (this._type++, (this._type = this._type % 3), this._roadPointDic)) { var e = this._roadPointDic[t]; e && e.reset(e.node, this._type); } } hiddenUnWalkAbleRoadPoint() { var t, e; if (((s.hiddenUnWalkAble = !s.hiddenUnWalkAble), s.hiddenUnWalkAble)) for (t in this._roadPointDic) (e = this._roadPointDic[t]) && 1 == e.node.value && e.clear(); else for (t in this._roadPointDic) (e = this._roadPointDic[t]) && 1 == e.node.value && e.reset(e.node, this._type); } clear() { for (var t in this._roadPointDic) this._roadPointDic[t].destroy(), (this._roadPointDic[t] = null), delete this._roadPointDic[t]; for (t in this._graphicDic) this._graphicDic[t] && (this._graphicDic[t].clear(), this._graphicDic[t].destroy(), (this._graphicDic[t] = null), delete this._roadNodeDic[t]); this._roadNodeDic = {}; } }; (t.hiddenUnWalkAble = !1), (t = s = e([o], t)), (i.default = t = s);