Commit eab321e5 authored by spc's avatar spc

modified: project/src/canvas/game/src/xiaoxiaole/XxlScene.ts

parent 8cb21f11
...@@ -19,9 +19,17 @@ declare interface point { ...@@ -19,9 +19,17 @@ declare interface point {
y: number; y: number;
} }
/**
* 男左女右
*/
class noder { class noder {
mother: noder = null mother: noder = null
father: noder = null father: noder = null
bother: noder = null
sister: noder = null
son: noder = null
daughter: noder = null
index: number index: number
item: CircleItem = null item: CircleItem = null
p: point = null p: point = null
...@@ -460,60 +468,139 @@ export class XxlScene extends Scene { ...@@ -460,60 +468,139 @@ export class XxlScene extends Scene {
const nowrightindex = this.hexIndices[i][t1 + offset] const nowrightindex = this.hexIndices[i][t1 + offset]
const rightbotherindex = this.hexIndices[i][t1 + offset - 1]
const rightsisterindex = this.hexIndices[i][t1 + offset + 1]
let fatherright = this.ItemMap.get(fatherrightindex) let fatherright = this.ItemMap.get(fatherrightindex)
let motherright = this.ItemMap.get(motherrightindex) let motherright = this.ItemMap.get(motherrightindex)
let nowright = this.ItemMap.get(nowrightindex) let nowright = this.ItemMap.get(nowrightindex)
let rightbother = this.ItemMap.get(rightbotherindex)
let rightsister = this.ItemMap.get(rightsisterindex)
nowright.bother = rightbother
nowright.sister = rightsister
nowright.father = fatherright nowright.father = fatherright
if (fatherright) {
fatherright.daughter = nowright
}
nowright.mother = motherright nowright.mother = motherright
if (motherright) {
motherright.son = nowright
}
//左移 //左移
let fatherleftindex = this.hexIndices[i - 1][t2 - 1 - offset] const fatherleftindex = this.hexIndices[i - 1][t2 - 1 - offset]
let motherleftindex = this.hexIndices[i - 1][t2 - offset] const motherleftindex = this.hexIndices[i - 1][t2 - offset]
let nowleftindex = this.hexIndices[i][t1 - offset] const nowleftindex = this.hexIndices[i][t1 - offset]
const leftbotherindex = this.hexIndices[i][t1 - offset - 1]
const leftsisterindex = this.hexIndices[i][t1 - offset + 1]
let nowleft = this.ItemMap.get(nowleftindex) let nowleft = this.ItemMap.get(nowleftindex)
let fatherleft = this.ItemMap.get(fatherleftindex) let fatherleft = this.ItemMap.get(fatherleftindex)
let motherleft = this.ItemMap.get(motherleftindex) let motherleft = this.ItemMap.get(motherleftindex)
let leftbother = this.ItemMap.get(leftbotherindex)
let leftsister = this.ItemMap.get(leftsisterindex)
nowleft.bother = leftbother
nowleft.sister = leftsister
nowleft.father = fatherleft nowleft.father = fatherleft
if (fatherleft) {
fatherleft.daughter = nowleft
}
nowleft.mother = motherleft nowleft.mother = motherleft
if (motherleft) {
motherleft.son = nowleft
}
} else { } else {
//中间项 //中间项
let fatherindex = this.hexIndices[i - 1][t2 - 1] const fatherindex = this.hexIndices[i - 1][t2 - 1]
let motherindex = this.hexIndices[i - 1][t2] const motherindex = this.hexIndices[i - 1][t2]
let nowindex = this.hexIndices[i][t1] const nowindex = this.hexIndices[i][t1]
const botherindex = this.hexIndices[i][t1 - 1]
const sisterindex = this.hexIndices[i][t1 + 1]
let now = this.ItemMap.get(nowindex) let now = this.ItemMap.get(nowindex)
now.father = this.ItemMap.get(fatherindex) let father = this.ItemMap.get(fatherindex)
now.mother = this.ItemMap.get(motherindex) let mother = this.ItemMap.get(motherindex)
let bother = this.ItemMap.get(botherindex)
let sister = this.ItemMap.get(sisterindex)
now.bother = bother
now.sister = sister
now.father = father
if (father) {
father.daughter = now
}
now.mother = mother
if (mother) {
mother.son = now
}
} }
} }
} else { } else {
for (let offset = 0; offset < t1; offset++) { for (let offset = 0; offset < t1; offset++) {
//右移 //右移
let fatherrightindex = this.hexIndices[i - 1][t2 + offset] const fatherrightindex = this.hexIndices[i - 1][t2 + offset]
let motherrightindex = this.hexIndices[i - 1][t2 + 1 + offset] const motherrightindex = this.hexIndices[i - 1][t2 + 1 + offset]
let nowrightindex = this.hexIndices[i][t1 + offset] const nowrightindex = this.hexIndices[i][t1 + offset]
const rightbotherindex = this.hexIndices[i][t1 + offset - 1]
const rightsisterindex = this.hexIndices[i][t1 + offset + 1]
let nowright = this.ItemMap.get(nowrightindex) let nowright = this.ItemMap.get(nowrightindex)
nowright.father = this.ItemMap.get(fatherrightindex) let rightfather = this.ItemMap.get(fatherrightindex)
nowright.mother = this.ItemMap.get(motherrightindex) let rightmother = this.ItemMap.get(motherrightindex)
let rightbother = this.ItemMap.get(rightbotherindex)
let rightsister = this.ItemMap.get(rightsisterindex)
nowright.bother = rightbother
nowright.sister = rightsister
nowright.father = rightfather
if (rightfather) {
rightfather.daughter = nowright
}
nowright.mother = rightmother
if (rightmother) {
rightmother.son = nowright
}
//左移 //左移
let fatherleftindex = this.hexIndices[i - 1][t2 - 1 - offset] const fatherleftindex = this.hexIndices[i - 1][t2 - 1 - offset]
let motherleftindex = this.hexIndices[i - 1][t2 - offset] const motherleftindex = this.hexIndices[i - 1][t2 - offset]
let nowleftindex = this.hexIndices[i][t1 - offset - 1] const nowleftindex = this.hexIndices[i][t1 - offset - 1]
const leftbotherindex = this.hexIndices[i][t1 - offset - 2]
const leftsisterindex = this.hexIndices[i][t1 - offset]
let nowleft = this.ItemMap.get(nowleftindex) let nowleft = this.ItemMap.get(nowleftindex)
nowleft.father = this.ItemMap.get(fatherleftindex) let leftfather = this.ItemMap.get(fatherleftindex)
nowleft.mother = this.ItemMap.get(motherleftindex) let leftmother = this.ItemMap.get(motherleftindex)
let leftbother = this.ItemMap.get(leftbotherindex)
let leftsister = this.ItemMap.get(leftsisterindex)
nowleft.bother = leftbother
nowleft.sister = leftsister
nowleft.father = leftfather
if (leftfather) {
leftfather.daughter = nowleft
}
nowleft.mother = leftmother
if (leftmother) {
leftmother.son = nowleft
}
} }
} }
} }
} }
// console.log(this.ItemMap) console.log(this.ItemMap)
this.isImpasse()
if (this.userInfo.isNewUser) { if (this.userInfo.isNewUser) {
let i = 0 let i = 0
...@@ -870,7 +957,32 @@ export class XxlScene extends Scene { ...@@ -870,7 +957,32 @@ export class XxlScene extends Scene {
} }
//是否是僵局
isImpasse(): boolean {
let isImpasse = true
for (let i in this.ItemMap) {
let noder = this.ItemMap[i]
if (noder.father && noder.item.type == noder.father.item.type) {
isImpasse = false
}
if (noder.mother && noder.item.type == noder.mother.item.type) {
isImpasse = true
}
if (noder.bother && noder.item.type == noder.bother.item.type) {
isImpasse = true
}
if (noder.sister && noder.item.type == noder.sister.item.type) {
isImpasse = true
}
if (noder.son && noder.item.type == noder.son.item.type) {
isImpasse = true
}
if (noder.daughter && noder.item.type == noder.daughter.item.type) {
isImpasse = true
}
}
return isImpasse
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment