Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
l2_boardgame2_tree
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
l2_boardgame2_tree
Commits
c67bfeb5
Commit
c67bfeb5
authored
Jul 21, 2022
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成
parent
26b6f182
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
555 additions
and
1026 deletions
+555
-1026
l2_boardgame2.fire
assets/l2_boardgame2/scene/l2_boardgame2.fire
+372
-880
l2_boardgame2.ts
assets/l2_boardgame2/scene/l2_boardgame2.ts
+161
-133
AI.ts
assets/l2_boardgame2/script/AI.ts
+16
-7
Server.ts
assets/l2_boardgame2/script/Server.ts
+6
-6
No files found.
assets/l2_boardgame2/scene/l2_boardgame2.fire
View file @
c67bfeb5
This diff is collapsed.
Click to expand it.
assets/l2_boardgame2/scene/l2_boardgame2.ts
View file @
c67bfeb5
...
...
@@ -47,7 +47,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
Red
:
0
,
Blue
:
0
,
letter
:
""
,
current
:
"
Blue
"
,
current
:
"
Red
"
,
};
playerId
;
isRoomOwner
;
...
...
@@ -57,7 +57,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
networkHelper
=
new
NetworkHelper
();
this
.
initNetworkListener
();
do
{
this
.
playerId
=
await
this
.
networkHelper
.
init
(
"
op_16_2
"
,
2
);
this
.
playerId
=
await
this
.
networkHelper
.
init
(
"
l2_boardgame2_tree
"
,
2
);
if
(
this
.
playerId
===
null
)
{
console
.
log
(
"
onDestroy
"
);
this
.
networkHelper
.
onDestroy
();
...
...
@@ -105,15 +105,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
initView
()
{
this
.
addComponents
();
this
.
hideVoice
();
this
.
initBg
();
this
.
initLoadingLayer
();
this
.
initPiece
();
}
getJumpList
()
{
const
jumpList
=
[];
addComponents
()
{
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
).
children
.
forEach
(
node
=>
{
let
itemData
=
node
.
getComponent
(
"
BoardGame2_ItemData
"
);
if
(
!
itemData
)
{
...
...
@@ -131,14 +129,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
});
// cc.find('Canvas/bg/chessBoard/boardItems').children.forEach(node => {
// const itemData = node.getComponent("BoardGame2_ItemData");
// if (itemData.jump) {
// const from = itemData.idx;
// const to = itemData.jump;
// jumpList.push({ from, to });
// }
// });
}
getJumpList
()
{
const
jumpList
=
[];
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
).
children
.
forEach
(
node
=>
{
const
itemData
=
node
.
getComponent
(
"
BoardGame2_ItemData
"
);
if
(
itemData
.
jump
)
{
const
from
=
itemData
.
idx
;
const
to
=
itemData
.
jump
;
jumpList
.
push
({
from
,
to
});
}
});
return
jumpList
;
}
...
...
@@ -492,6 +494,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
start
();
}
getCurrentBlock
()
{
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
return
board
.
children
[
startIdx
]
}
getRightBlock
()
{
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
...
...
@@ -872,11 +879,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
idx
=
this
.
getNextRightIdx
();
const
pieceRed
=
cc
.
find
(
"
Canvas/bg/chessBoard/pieceRed
"
);
const
pieceBlue
=
cc
.
find
(
"
Canvas/bg/chessBoard/pieceBlue
"
);
const
node
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
this
.
_status
.
current
}
`
);
node
[
"
touchStartPos
"
]
=
{
nodeX
:
node
.
x
,
nodeY
:
node
.
y
,
touchX
:
node
.
x
,
touchY
:
node
.
y
,
};
let
lastIdx
=
this
.
_status
[
playerMe
.
color
];
pieceRed
[
"
cantMove
"
]
=
false
;
pieceBlue
[
"
cantMove
"
]
=
false
;
await
this
.
pieceFindRightBlock
(
rightBlock
,
idx
);
pieceRed
[
"
cantMove
"
]
=
true
;
pieceBlue
[
"
cantMove
"
]
=
true
;
let
isSuccess
=
await
this
.
showVoice
(
rightBlock
);
this
.
hideVoice
();
if
(
isSuccess
)
{
...
...
@@ -887,6 +902,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
color
:
playerMe
.
color
,
});
}
else
{
this
.
_status
[
playerMe
.
color
]
=
lastIdx
this
.
networkHelper
.
sendFrame
({
type
:
"
wrong
"
,
uuid
:
playerMe
.
uuid
,
...
...
@@ -897,6 +913,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
else
if
(
item
.
data
.
type
==
"
SERVER_playerRight
"
)
{
const
playerMe
=
this
.
allPlayerList
.
find
((
player
)
=>
player
.
uuid
==
this
.
playerId
);
if
(
this
.
_status
.
current
==
playerMe
.
color
)
{
// let rightBlock = this.getRightBlock();
let
rightBlock
=
this
.
getCurrentBlock
();
const
pieceRed
=
cc
.
find
(
"
Canvas/bg/chessBoard/pieceRed
"
);
const
pieceBlue
=
cc
.
find
(
"
Canvas/bg/chessBoard/pieceBlue
"
);
const
riData
=
rightBlock
.
getComponent
(
"
BoardGame2_ItemData
"
);
if
(
riData
.
jump
!=
""
)
{
rightBlock
=
this
.
jumpBlock
(
parseInt
(
riData
.
jump
));
let
idx
=
parseInt
(
riData
.
jump
);
//this.getNextRightIdx();
await
this
.
pieceFindRightBlock
(
rightBlock
,
idx
);
}
pieceRed
[
"
cantMove
"
]
=
true
;
pieceBlue
[
"
cantMove
"
]
=
true
;
this
.
_status
.
letter
=
""
;
this
.
changeSide
();
this
.
updateStatus
();
...
...
@@ -1005,6 +1034,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
console
.
log
(
'
startTest->
'
+
this
.
_status
.
letter
);
courseware
&&
courseware
.
startTest
(
this
.
_status
.
letter
);
//开始录音
setTimeout
(
async
()
=>
{
if
(
!
courseware
)
{
let
testData
=
{
"
dtLastResponse
"
:
"
2021-09-17 13:36:26:109
"
,
"
refText
"
:
"
I haven't found anything out about him yet.
"
,
...
...
@@ -1016,7 +1046,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
"
fluency
"
:
60
,
"
rhythm
"
:
90
,
"
kernel_version
"
:
"
5.2.4
"
,
"
overall
"
:
25
,
//7
5
"
overall
"
:
80
,
//2
5
"
integrity
"
:
100
,
"
duration
"
:
"
6.779
"
,
"
rear_tone
"
:
"
fall
"
,
...
...
@@ -1122,7 +1152,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
"
tokenId
"
:
"
6144295408558b08dd000001
"
,
"
applicationId
"
:
"
154838659000009e
"
}
if
(
!
courseware
)
{
if
(
this
.
recrodEnd
(
testData
))
{
await
this
.
showVoiceGood
();
return
resolve
(
true
)
...
...
@@ -1186,12 +1215,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
async
recrodEnd
(
data
)
{
recrodEnd
(
data
)
{
// return true;
let
score
=
data
.
result
.
overall
;
let
isSuccess
=
this
.
checkWords
(
data
);
this
.
log
(
"
score->
"
+
score
);
this
.
log
(
"
isSuccess->
"
+
isSuccess
);
if
(
score
>=
70
&&
isSuccess
)
{
//提示成功
return
true
;
}
else
{
return
false
;
...
...
@@ -1200,13 +1230,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
checkWords
(
data
)
{
const
sentences
=
data
.
result
.
sentences
;
if
(
!
sentences
)
return
true
;
for
(
let
i
=
0
;
i
<
sentences
.
length
;
i
++
)
{
const
details
=
sentences
[
i
].
details
;
const
isSuccess
=
details
.
some
(
item
=>
item
.
overall
<=
40
);
if
(
isSuccess
)
{
return
false
;
}
if
(
isSuccess
)
return
false
;
}
return
true
;
}
...
...
assets/l2_boardgame2/script/AI.ts
View file @
c67bfeb5
...
...
@@ -8,7 +8,7 @@ export class AI {
Red
:
0
,
Blue
:
0
,
letter
:
""
,
current
:
"
Blue
"
,
current
:
"
Red
"
,
};
constructor
(
networkHelper
:
NetworkHelper
,
playerData
:
any
)
{
...
...
@@ -49,12 +49,21 @@ export class AI {
//调试加速 2 Math.random() * 3 + 4
await
asyncDelay
(
Math
.
random
()
*
3
+
4
);
const
idx
=
this
.
getNextRightIdx
();
if
(
Math
.
random
()
<
0.8
)
{
this
.
networkHelper
.
sendFrame
({
type
:
"
right
"
,
idx
:
idx
,
uuid
:
this
.
playerData
.
uuid
,
color
:
this
.
playerData
.
color
,
});
}
else
{
this
.
networkHelper
.
sendFrame
({
type
:
"
wrong
"
,
uuid
:
this
.
playerData
.
uuid
,
color
:
this
.
playerData
.
color
,
});
}
}
}
}
...
...
assets/l2_boardgame2/script/Server.ts
View file @
c67bfeb5
...
...
@@ -58,7 +58,7 @@ export class GameServer {
name
:
this
.
nameList
.
splice
(
0
,
1
)[
0
],
uuid
:
player
.
uuid
,
color
:
player
.
uuid
==
this
.
networkHelper
.
room
.
roomInfo
.
owner
?
"
Blue
"
:
"
Red
"
,
player
.
uuid
==
this
.
networkHelper
.
room
.
roomInfo
.
owner
?
"
Red
"
:
"
Blue
"
,
isAI
:
player
.
isAI
,
headUrl
:
this
.
headUrls
.
splice
(
0
,
1
)[
0
],
});
...
...
@@ -82,7 +82,7 @@ export class GameServer {
Red
:
0
,
Blue
:
0
,
letter
:
""
,
current
:
"
Blue
"
,
current
:
"
Red
"
,
};
startGame
()
{
this
.
networkHelper
.
sendFrame
({
...
...
@@ -108,13 +108,13 @@ export class GameServer {
const
playerInfo
=
{
uuid
:
"
ai_
"
+
i
,
isAI
:
true
,
color
:
"
Red
"
,
color
:
"
Blue
"
,
};
this
.
_aiPlayerList
.
push
(
new
AI
(
this
.
networkHelper
,
playerInfo
));
this
.
addPlayer
(
playerInfo
);
}
//TODO:调试加速
},
1000
)
//RandomInt(10000, 15000)
},
1000
0
)
//RandomInt(10000, 15000)
);
}
}
...
...
@@ -128,9 +128,9 @@ export class GameServer {
console
.
log
(
'
letterList:
'
,
letterList
);
if
(
letterList
.
length
>
0
)
{
if
(
this
.
gameStatus
.
letter
==
""
)
{
// let max = Math.max(
letterList.length - 2
, 0);
// let max = Math.max(
9
, 0);
// let letter = letterList[max];//[RandomInt(letterList.length) % 3];//转盘只有1-3
// if (this.gameStatus.current
!
= 'Blue') {
// if (this.gameStatus.current
=
= 'Blue') {
// letter = letterList[0]
// }
let
letter
=
letterList
[
RandomInt
(
letterList
.
length
)
%
3
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment