Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BoardGame2
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
BoardGame2
Commits
07c58a54
Commit
07c58a54
authored
Jun 29, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: bugs
parent
2551facb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
11 deletions
+47
-11
BoardGame2.ts
assets/BoardGame2/scene/BoardGame2.ts
+21
-0
Server.ts
assets/BoardGame2/script/Server.ts
+26
-11
No files found.
assets/BoardGame2/scene/BoardGame2.ts
View file @
07c58a54
...
...
@@ -76,6 +76,27 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
this
.
server
.
startMatch
();
}
await
this
.
initHeadImgAndName
();
}
async
initHeadImgAndName
()
{
const
playerInfo
:
any
=
{
playerHeadUrl
:
"
http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png
"
,
playerName
:
"
test
"
,
};
const
middleLayer
=
cc
.
find
(
"
middleLayer
"
);
if
(
middleLayer
)
{
const
kidInfo
=
await
middleLayer
.
getComponent
(
'
middleLayer
'
).
getUserInfo
();
const
playerHeadUrl
=
middleLayer
.
getComponent
(
'
middleLayer
'
).
getHeadUrl
(
kidInfo
.
avatar_url
||
kidInfo
.
id
);
playerInfo
.
playerHeadUrl
=
playerHeadUrl
;
playerInfo
.
playerName
=
kidInfo
.
nick_name
;
}
this
.
networkHelper
.
sendFrame
({
type
:
"
playerInfo
"
,
playerId
:
this
.
playerId
,
playerName
:
playerInfo
.
playerName
,
playerHeadUrl
:
playerInfo
.
playerHeadUrl
,
});
}
initView
()
{
...
...
assets/BoardGame2/script/Server.ts
View file @
07c58a54
...
...
@@ -63,17 +63,18 @@ export class GameServer {
headUrl
:
this
.
headUrls
.
splice
(
0
,
1
)[
0
],
});
await
asyncDelay
(
1
);
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_allPlayerInfo
"
,
playerData
:
this
.
playerList
,
});
if
(
this
.
playerList
.
length
==
this
.
playerMaxNumber
)
{
this
.
networkHelper
.
closeRoom
();
await
asyncDelay
(
0.5
);
this
.
startGame
();
this
.
startAI
();
if
(
player
.
isAI
)
{
await
asyncDelay
(
1
);
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_allPlayerInfo
"
,
playerData
:
this
.
playerList
,
});
if
(
this
.
playerList
.
length
==
this
.
playerMaxNumber
)
{
this
.
networkHelper
.
closeRoom
();
await
asyncDelay
(
0.5
);
this
.
startGame
();
this
.
startAI
();
}
}
}
...
...
@@ -142,6 +143,20 @@ export class GameServer {
});
this
.
gameStatus
[
'
gameOver
'
]
=
true
;
}
}
else
if
(
data
.
type
==
"
playerInfo
"
)
{
const
player
=
this
.
playerList
.
find
(
p
=>
p
.
uuid
==
data
.
playerId
);
player
.
name
=
data
.
playerName
;
player
.
headUrl
=
data
.
playerHeadUrl
;
this
.
networkHelper
.
sendFrame
({
type
:
"
SERVER_allPlayerInfo
"
,
playerData
:
this
.
playerList
,
});
if
(
this
.
playerList
.
length
==
this
.
playerMaxNumber
)
{
this
.
networkHelper
.
closeRoom
();
await
asyncDelay
(
0.5
);
this
.
startGame
();
this
.
startAI
();
}
}
else
if
(
data
.
type
==
"
right
"
)
{
if
(
this
.
gameStatus
.
letter
!=
""
)
{
this
.
gameStatus
.
letter
=
""
;
...
...
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