Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BoardGame3
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
BoardGame3
Commits
225a9738
Commit
225a9738
authored
Mar 18, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 语法报错
parent
1a2aa3d6
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
37 deletions
+35
-37
BoardGame3.ts
assets/BoardGame3/scene/BoardGame3.ts
+27
-27
LoadingLayer.ts
assets/BoardGame3/script/LoadingLayer.ts
+1
-1
MyCocosSceneComponent.ts
assets/BoardGame3/script/MyCocosSceneComponent.ts
+1
-1
NetworkHelper.ts
assets/BoardGame3/script/NetworkHelper.ts
+2
-4
Server.ts
assets/BoardGame3/script/Server.ts
+3
-3
util.ts
assets/BoardGame3/script/util.ts
+1
-1
No files found.
assets/BoardGame3/scene/BoardGame3.ts
View file @
225a9738
...
...
@@ -30,7 +30,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
_audioResList
.
push
({
url
:
this
.
data
.
waitingTurn
});
}
addPreloadAnima
()
{}
addPreloadAnima
()
{
}
onLoadEnd
()
{
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
...
...
@@ -141,8 +141,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
start
();
});
const
dice
=
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg/dice
"
);
dice
[
"
canClick
"
]
=
true
;
const
dice
2
=
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg/dice
"
);
dice
2
[
"
canClick
"
]
=
true
;
}
stopBlinkTheDice
()
{
...
...
@@ -153,8 +153,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
node
.
scale
=
1
;
node
.
opacity
=
255
;
});
const
dice
=
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg/dice
"
);
dice
[
"
canClick
"
]
=
false
;
const
dice
2
=
cc
.
find
(
"
Canvas/bg/chessBoard/diceBg/dice
"
);
dice
2
[
"
canClick
"
]
=
false
;
}
greyDice
()
{
...
...
@@ -173,8 +173,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
offsetX
=
{
Red
:
-
45
,
Blue
:
45
};
const
offsetY
=
{
Red
:
-
90
,
Blue
:
-
90
};
const
board
=
{
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
}
const
pieceNodeRed
=
cc
.
find
(
`Canvas/bg/chessBoard/pieceRed`
);
...
...
@@ -357,7 +357,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
start
();
}
rollPiece
(
node
:
cc
.
Node
,
color
:
string
)
{
rollPiece
(
node
:
cc
.
Node
,
color
:
string
)
{
node
.
stopAllActions
();
cc
.
tween
(
node
)
.
set
({
scale
:
1
,
angle
:
0
})
...
...
@@ -370,8 +370,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
start
();
const
board
=
{
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
}
board
[
color
].
children
.
forEach
((
child
:
cc
.
Node
,
idx
,
list
)
=>
{
...
...
@@ -401,8 +401,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
getRightBlock
()
{
const
board
=
{
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
}
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
console
.
log
(
"
startIdx =
"
+
JSON
.
stringify
(
startIdx
));
...
...
@@ -418,8 +418,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
getNextRightIdx
()
{
const
board
=
{
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
}
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
for
(
let
i
=
startIdx
+
1
;
i
<
board
[
this
.
_status
.
current
].
children
.
length
;
i
++
)
{
...
...
@@ -434,8 +434,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
checkNodeInRightBlock
(
node
,
color
)
{
const
board
=
{
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
}
const
startIdx
=
this
.
_status
[
color
];
...
...
@@ -484,8 +484,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
async
pieceFindRightBlock
(
rightBlock
,
idx
)
{
const
board
=
{
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
}
const
color
=
this
.
_status
.
current
;
const
piece
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
color
}
`
);
...
...
@@ -566,7 +566,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
else
{
this
.
stopBlinkTheDice
();
this
.
rollPiece
(
this
.
getCurrentPiece
(),
playerMe
.
color
);
this
.
rollPiece
(
this
.
getCurrentPiece
(),
playerMe
.
color
);
}
}
else
{
this
.
greyDice
();
...
...
@@ -622,7 +622,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
delay
(
0.5
)
.
to
(
0.5
,
{
opacity
:
0
})
.
call
(()
=>
{
resolve
();
resolve
(
null
);
})
.
start
();
});
...
...
@@ -660,7 +660,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
networkHelper
.
leaveRoom
();
this
.
log
(
"
playerOffLine
"
+
JSON
.
stringify
(
event
));
});
this
.
networkHelper
.
on
(
"
gameStart
"
,
(
event
)
=>
{});
this
.
networkHelper
.
on
(
"
gameStart
"
,
(
event
)
=>
{
});
this
.
networkHelper
.
on
(
"
frameEvent
"
,
(
event
)
=>
{
event
.
data
.
frame
.
items
.
forEach
(
async
(
item
)
=>
{
if
(
this
.
server
)
{
...
...
@@ -773,8 +773,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
);
const
board
=
{
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
}
const
idx
=
board
[
this
.
_status
.
current
].
children
.
length
;
const
rightBlock
=
board
[
this
.
_status
.
current
].
children
[
idx
-
1
];
...
...
@@ -826,8 +826,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
offsetY
=
{
Red
:
-
90
,
Blue
:
-
90
};
const
pieceNode
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
color
}
`
);
const
board
=
{
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
"
Blue
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsL
"
),
"
Red
"
:
cc
.
find
(
"
Canvas/bg/chessBoard/boardItemsR
"
),
}
const
startIdx
=
this
.
_status
[
color
];
...
...
assets/BoardGame3/script/LoadingLayer.ts
View file @
225a9738
...
...
@@ -224,7 +224,7 @@ export default class SceneComponent extends cc.Component {
return
;
}
this
.
stopCurrentPlayedAudio
();
cc
.
assetManager
.
loadRemote
(
audio_url
.
toLowerCase
(),
(
err
,
audioClip
)
=>
{
cc
.
assetManager
.
loadRemote
(
audio_url
.
toLowerCase
(),
(
err
,
audioClip
:
cc
.
AudioClip
)
=>
{
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
this
.
currentPlayedAudioId
=
audioId
;
if
(
cb
)
{
...
...
assets/BoardGame3/script/MyCocosSceneComponent.ts
View file @
225a9738
...
...
@@ -182,7 +182,7 @@ export class MyCocosSceneComponent extends cc.Component {
playAudioByUrl
(
audio_url
,
cb
=
null
)
{
if
(
audio_url
)
{
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
)
=>
{
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
:
cc
.
AudioClip
)
=>
{
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
if
(
cb
)
{
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
()
=>
{
...
...
assets/BoardGame3/script/NetworkHelper.ts
View file @
225a9738
import
{
Base64
}
from
"
js-base64
"
;
export
class
NetworkHelper
{
_eventListeners
:
any
=
{};
ctor
()
{}
...
...
@@ -127,7 +125,7 @@ export class NetworkHelper {
console
.
log
(
"
this.room =
"
+
JSON
.
stringify
(
this
.
room
.
roomInfo
));
}
player
:
MGOBE
.
Player
;
player
:
any
;
joinRoom
(
roomType
:
string
,
maxPlayers
:
number
,
customData
:
string
=
""
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
playerName
=
"
Tom
"
+
Math
.
random
();
...
...
@@ -366,7 +364,7 @@ export function asyncDelay(time) {
cc
.
tween
(
cc
.
find
(
"
Canvas
"
))
.
delay
(
time
)
.
call
(()
=>
{
resolve
();
resolve
(
null
);
})
.
start
();
});
...
...
assets/BoardGame3/script/Server.ts
View file @
225a9738
...
...
@@ -107,7 +107,7 @@ export class GameServer {
}
async
onFrameEvent
(
data
)
{
if
(
this
.
gameStatus
.
gameOver
)
{
if
(
this
.
gameStatus
[
'
gameOver
'
]
)
{
return
;
}
if
(
data
.
type
==
"
roll
"
)
{
...
...
@@ -128,7 +128,7 @@ export class GameServer {
type
:
"
SERVER_playerWin
"
,
color
:
this
.
gameStatus
.
current
,
});
this
.
gameStatus
.
gameOver
=
true
;
this
.
gameStatus
[
'
gameOver
'
]
=
true
;
}
}
else
if
(
data
.
type
==
"
right
"
)
{
if
(
this
.
gameStatus
.
letter
!=
""
)
{
...
...
@@ -149,7 +149,7 @@ export class GameServer {
type
:
"
SERVER_playerWin
"
,
color
:
this
.
gameStatus
.
current
,
});
this
.
gameStatus
.
gameOver
=
true
;
this
.
gameStatus
[
'
gameOver
'
]
=
true
;
}
}
else
{
console
.
log
(
'
汪汪汪
'
);
...
...
assets/BoardGame3/script/util.ts
View file @
225a9738
...
...
@@ -102,7 +102,7 @@ export function getDistance(start, end) {
export
function
playAudioByUrl
(
audio_url
,
cb
=
null
)
{
if
(
audio_url
)
{
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
)
=>
{
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
:
cc
.
AudioClip
)
=>
{
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
if
(
cb
)
{
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
()
=>
{
...
...
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