Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
op_16
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
op_16
Commits
ec203d1c
Commit
ec203d1c
authored
Nov 30, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 开始游戏的判断逻辑
parent
409da6cc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
op_16.ts
assets/op_16/scene/op_16.ts
+11
-13
No files found.
assets/op_16/scene/op_16.ts
View file @
ec203d1c
...
@@ -36,24 +36,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -36,24 +36,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
await
this
.
networkHelper
.
initRoom
();
await
this
.
networkHelper
.
initRoom
();
this
.
playerId
=
await
this
.
networkHelper
.
joinRoom
(
'
op_16
'
,
2
);
this
.
playerId
=
await
this
.
networkHelper
.
joinRoom
(
'
op_16
'
,
2
);
const
roomInfo
=
this
.
networkHelper
.
getRoomInfo
();
//
const roomInfo = this.networkHelper.getRoomInfo();
if
(
roomInfo
.
playerList
.
length
==
roomInfo
.
maxPlayers
)
{
//
if (roomInfo.playerList.length == roomInfo.maxPlayers) {
if
(
this
.
playerId
==
roomInfo
.
playerList
[
0
].
id
)
{
//
if (this.playerId == roomInfo.playerList[0].id) {
this
.
networkHelper
.
startGame
();
//
this.networkHelper.startGame();
}
//
}
}
//
}
roomInfo
.
playerList
.
forEach
(
player
=>
{
//
roomInfo.playerList.forEach(player => {
// const startPos = JSON.parse(player.customProfile);
//
// const startPos = JSON.parse(player.customProfile);
// this.createTank(player.id, startPos);
//
// this.createTank(player.id, startPos);
});
//
});
this
.
networkHelper
.
on
(
'
playerJoin
'
,
(
event
)
=>
{
this
.
networkHelper
.
on
(
'
playerJoin
'
,
(
event
)
=>
{
const
roomInfo
=
this
.
networkHelper
.
getRoomInfo
();
const
roomInfo
=
this
.
networkHelper
.
getRoomInfo
();
if
(
roomInfo
.
playerList
.
length
==
roomInfo
.
maxPlayers
)
{
if
(
roomInfo
.
playerList
.
length
==
roomInfo
.
maxPlayers
)
{
if
(
this
.
playerId
==
roomInfo
.
playerList
[
0
].
id
)
{
this
.
networkHelper
.
startGame
();
this
.
networkHelper
.
startGame
();
}
}
}
console
.
log
(
"
playerJoin
"
,
event
);
console
.
log
(
"
playerJoin
"
,
event
);
});
});
this
.
networkHelper
.
on
(
'
playerLeave
'
,
(
event
)
=>
{
this
.
networkHelper
.
on
(
'
playerLeave
'
,
(
event
)
=>
{
...
...
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