|
@@ -63,14 +63,14 @@ export default class MyMap extends cc.Component {
|
|
|
}
|
|
|
|
|
|
//更新自己位置数据的间隔s
|
|
|
- UpMyindexInterval: number = 1
|
|
|
+ UpMyindexInterval: number = 0.1
|
|
|
|
|
|
|
|
|
//更新自己位置数据的间隔s
|
|
|
NeedUpdataIndexData: NeedUpdataIndex[] = []
|
|
|
|
|
|
protected start(): void {
|
|
|
- this.Load('2')
|
|
|
+ this.Load('3')
|
|
|
}
|
|
|
|
|
|
public Load(level: string) {
|
|
@@ -90,7 +90,13 @@ export default class MyMap extends cc.Component {
|
|
|
console.log(error.message);
|
|
|
return;
|
|
|
}
|
|
|
- this.MapjsonData = resource.json;
|
|
|
+
|
|
|
+ if (window['map99']) {
|
|
|
+ this.MapjsonData = window['map99']
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.MapjsonData = resource.json;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
if (this.MapjsonData) {
|
|
@@ -154,6 +160,16 @@ export default class MyMap extends cc.Component {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+ let wordpos = this.node.getChildByName('bg' + this.MapjsonData['BronID']).convertToWorldSpaceAR(
|
|
|
+ cc.v2(this.MapjsonData['BronX'], this.MapjsonData['BronY']))
|
|
|
+
|
|
|
+ // []}],"mapX":3,"mapY":3,"BronID":0,"BronX":55,"BronY":55}
|
|
|
+
|
|
|
+ this.CharacterNode.setPosition(this.CharacterNode.parent.convertToNodeSpaceAR(wordpos))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return
|
|
|
|
|
|
|
|
@@ -212,53 +228,90 @@ export default class MyMap extends cc.Component {
|
|
|
|
|
|
let MyIndex = cc.v2(this.CurrentMapPosData.index_x, this.CurrentMapPosData.index_y);
|
|
|
|
|
|
- bronMap.push({ x: MyIndex.x - 1, y: MyIndex.y + 1, Id: this.CurrentMapPosData.Id + this.MapjsonData.mapX - 1 })
|
|
|
- bronMap.push({ x: MyIndex.x, y: MyIndex.y + 1, Id: this.CurrentMapPosData.Id + this.MapjsonData.mapX })
|
|
|
- bronMap.push({ x: MyIndex.x + 1, y: MyIndex.y + 1, Id: this.CurrentMapPosData.Id + this.MapjsonData.mapX + 1 })
|
|
|
+ // bronMap.push({ x: MyIndex.x - 1, y: MyIndex.y + 1, Id: this.CurrentMapPosData.Id + this.MapjsonData.mapX - 1 })
|
|
|
+ // bronMap.push({ x: MyIndex.x, y: MyIndex.y + 1, Id: this.CurrentMapPosData.Id + this.MapjsonData.mapX })
|
|
|
+ // bronMap.push({ x: MyIndex.x + 1, y: MyIndex.y + 1, Id: this.CurrentMapPosData.Id + this.MapjsonData.mapX + 1 })
|
|
|
+
|
|
|
+ // bronMap.push({ x: MyIndex.x - 1, y: MyIndex.y, Id: this.CurrentMapPosData.Id - 1 })
|
|
|
+ // bronMap.push({ x: MyIndex.x, y: MyIndex.y, Id: this.CurrentMapPosData.Id })
|
|
|
+ // bronMap.push({ x: MyIndex.x + 1, y: MyIndex.y, Id: this.CurrentMapPosData.Id + 1 })
|
|
|
+
|
|
|
+ // bronMap.push({ x: MyIndex.x - 1, y: MyIndex.y - 1, Id: this.CurrentMapPosData.Id - this.MapjsonData.mapX - 1 })
|
|
|
+ // bronMap.push({ x: MyIndex.x, y: MyIndex.y - 1, Id: this.CurrentMapPosData.Id - this.MapjsonData.mapX })
|
|
|
+ // bronMap.push({ x: MyIndex.x + 1, y: MyIndex.y - 1, Id: this.CurrentMapPosData.Id - this.MapjsonData.mapX + 1 })
|
|
|
|
|
|
|
|
|
- bronMap.push({ x: MyIndex.x - 1, y: MyIndex.y, Id: this.CurrentMapPosData.Id - 1 })
|
|
|
bronMap.push({ x: MyIndex.x, y: MyIndex.y, Id: this.CurrentMapPosData.Id })
|
|
|
+ bronMap.push({ x: MyIndex.x, y: MyIndex.y + 1, Id: this.CurrentMapPosData.Id + this.MapjsonData.mapX })
|
|
|
+ bronMap.push({ x: MyIndex.x, y: MyIndex.y - 1, Id: this.CurrentMapPosData.Id - this.MapjsonData.mapX })
|
|
|
+ bronMap.push({ x: MyIndex.x - 1, y: MyIndex.y, Id: this.CurrentMapPosData.Id - 1 })
|
|
|
bronMap.push({ x: MyIndex.x + 1, y: MyIndex.y, Id: this.CurrentMapPosData.Id + 1 })
|
|
|
|
|
|
+
|
|
|
+ bronMap.push({ x: MyIndex.x - 1, y: MyIndex.y + 1, Id: this.CurrentMapPosData.Id + this.MapjsonData.mapX - 1 })
|
|
|
+ bronMap.push({ x: MyIndex.x + 1, y: MyIndex.y + 1, Id: this.CurrentMapPosData.Id + this.MapjsonData.mapX + 1 })
|
|
|
bronMap.push({ x: MyIndex.x - 1, y: MyIndex.y - 1, Id: this.CurrentMapPosData.Id - this.MapjsonData.mapX - 1 })
|
|
|
- bronMap.push({ x: MyIndex.x, y: MyIndex.y - 1, Id: this.CurrentMapPosData.Id - this.MapjsonData.mapX })
|
|
|
bronMap.push({ x: MyIndex.x + 1, y: MyIndex.y - 1, Id: this.CurrentMapPosData.Id - this.MapjsonData.mapX + 1 })
|
|
|
|
|
|
|
|
|
+
|
|
|
for (let index = 0; index < bronMap.length; index++) {
|
|
|
|
|
|
+ console.log(bronMap[index].Id);
|
|
|
+
|
|
|
+
|
|
|
+ if (bronMap[index].x < 0 || bronMap[index].x > (this.MapjsonData.mapX - 1)) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if (bronMap[index].y < 0 || bronMap[index].y > (this.MapjsonData.mapY - 1)) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
const SubMap = this.getSubMapDataByID(bronMap[index].Id)
|
|
|
|
|
|
if (SubMap) {
|
|
|
if (this.总共生成的地图数组.includes(SubMap.Id)) {
|
|
|
|
|
|
} else {
|
|
|
- console.log('生成一次' + SubMap.Id);
|
|
|
this.BronSubMap(SubMap)
|
|
|
this.总共生成的地图数组.push(SubMap.Id)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- console.error('this.总共生成的地图数组');
|
|
|
- console.error(this.总共生成的地图数组);
|
|
|
+
|
|
|
+
|
|
|
+ // const array1 = [1, 2, 3, 4];
|
|
|
+ // const array2 = [3, 4, 5, 6];
|
|
|
+
|
|
|
+ // const differentElements = array1.filter(item => !array2.includes(item)).concat(
|
|
|
+ // array2.filter(item => !array1.includes(item))
|
|
|
+ // );
|
|
|
+
|
|
|
+ // console.log(differentElements);
|
|
|
+
|
|
|
|
|
|
|
|
|
for (let index = 0; index < this.总共生成的地图数组.length; index++) {
|
|
|
const MapId = this.总共生成的地图数组[index];
|
|
|
-
|
|
|
const SubMap = this.getSubMapDataByID(MapId)
|
|
|
-
|
|
|
if (SubMap) {
|
|
|
for (let j = 0; j < bronMap.length; j++) {
|
|
|
const element = bronMap[j];
|
|
|
if (element.Id == MapId) {
|
|
|
break
|
|
|
}
|
|
|
-
|
|
|
if (j == bronMap.length - 1) {
|
|
|
this.DeleteSubMap(SubMap)
|
|
|
+
|
|
|
+
|
|
|
+ const array = this.总共生成的地图数组
|
|
|
+ const elementToRemove = MapId; // 要删除的元素
|
|
|
+
|
|
|
+ this.总共生成的地图数组 = array.filter(item => item !== elementToRemove);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -310,11 +363,7 @@ export default class MyMap extends cc.Component {
|
|
|
|
|
|
|
|
|
DeleteSubMap(SubMap: MapPosData) {
|
|
|
-
|
|
|
-
|
|
|
- this.总共生成的地图数组 = this.总共生成的地图数组.filter(item => item !== SubMap.Id);
|
|
|
-
|
|
|
-
|
|
|
+ this.总共生成的地图数组 = this.总共生成的地图数组.filter(item => item !== SubMap.Id);
|
|
|
|
|
|
this.node.getChildByName('bg' + SubMap.Id).getComponent(cc.Sprite).spriteFrame = null
|
|
|
|