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
912c2a58
Commit
912c2a58
authored
Feb 17, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: bugs
parent
3acf5050
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1982 additions
and
982 deletions
+1982
-982
.DS_Store
.DS_Store
+0
-0
match.mp3
assets/op_16/audios/match.mp3
+0
-0
match.mp3.meta
assets/op_16/audios/match.mp3.meta
+7
-0
LoadingLayer.prefab
assets/op_16/prefab/LoadingLayer/LoadingLayer.prefab
+175
-3
op_16.fire
assets/op_16/scene/op_16.fire
+631
-172
op_16.ts
assets/op_16/scene/op_16.ts
+854
-654
AI.ts
assets/op_16/script/AI.ts
+28
-25
LoadingLayer.ts
assets/op_16/script/LoadingLayer.ts
+20
-0
NetworkHelper.ts
assets/op_16/script/NetworkHelper.ts
+151
-69
Server.ts
assets/op_16/script/Server.ts
+74
-59
yourturn.png
assets/op_16/textures/yourturn.png
+0
-0
yourturn.png.meta
assets/op_16/textures/yourturn.png.meta
+36
-0
package-lock.json
package-lock.json
+5
-0
package.json
package.json
+1
-0
No files found.
.DS_Store
View file @
912c2a58
No preview for this file type
assets/op_16/audios/match.mp3
0 → 100644
View file @
912c2a58
File added
assets/op_16/audios/match.mp3.meta
0 → 100644
View file @
912c2a58
{
"ver": "2.0.1",
"uuid": "64769aad-08a2-4b33-8fbb-6a6ba01f53f2",
"downloadMode": 0,
"duration": 3.474286,
"subMetas": {}
}
\ No newline at end of file
assets/op_16/prefab/LoadingLayer/LoadingLayer.prefab
View file @
912c2a58
...
@@ -40,19 +40,22 @@
...
@@ -40,19 +40,22 @@
},
},
{
{
"__id__": 34
"__id__": 34
},
{
"__id__": 54
}
}
],
],
"_active": true,
"_active": true,
"_components": [
"_components": [
{
{
"__id__": 5
4
"__id__": 5
9
},
},
{
{
"__id__":
55
"__id__":
60
}
}
],
],
"_prefab": {
"_prefab": {
"__id__":
56
"__id__":
61
},
},
"_opacity": 255,
"_opacity": 255,
"_color": {
"_color": {
...
@@ -1959,6 +1962,175 @@
...
@@ -1959,6 +1962,175 @@
"fileId": "f9qrJyDh5P1oErn3FfsNL7",
"fileId": "f9qrJyDh5P1oErn3FfsNL7",
"sync": false
"sync": false
},
},
{
"__type__": "cc.Node",
"_name": "res",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 55
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 58
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "match",
"_objFlags": 0,
"_parent": {
"__id__": 54
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 56
}
],
"_prefab": {
"__id__": 57
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 55
},
"_enabled": true,
"_clip": {
"__uuid__": "64769aad-08a2-4b33-8fbb-6a6ba01f53f2"
},
"_volume": 1,
"_mute": false,
"_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false,
"preload": false,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "4839576b-7c74-49ab-aa3e-8eeec631d7c0"
},
"fileId": "24pM39t0xAcpeV3Rbf7iK5",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "4839576b-7c74-49ab-aa3e-8eeec631d7c0"
},
"fileId": "28B+az6rRACpZT/KUohVaz",
"sync": false
},
{
{
"__type__": "cc.Widget",
"__type__": "cc.Widget",
"_name": "",
"_name": "",
...
...
assets/op_16/scene/op_16.fire
View file @
912c2a58
This diff is collapsed.
Click to expand it.
assets/op_16/scene/op_16.ts
View file @
912c2a58
This diff is collapsed.
Click to expand it.
assets/op_16/script/AI.ts
View file @
912c2a58
...
@@ -7,8 +7,8 @@ export class AI {
...
@@ -7,8 +7,8 @@ export class AI {
_status
=
{
_status
=
{
Red
:
0
,
Red
:
0
,
Blue
:
0
,
Blue
:
0
,
letter
:
''
,
letter
:
""
,
current
:
'
Blue
'
current
:
"
Blue
"
,
};
};
constructor
(
networkHelper
:
NetworkHelper
,
playerData
:
any
)
{
constructor
(
networkHelper
:
NetworkHelper
,
playerData
:
any
)
{
...
@@ -17,44 +17,47 @@ export class AI {
...
@@ -17,44 +17,47 @@ export class AI {
}
}
async
onFrameEvent
(
event
)
{
async
onFrameEvent
(
event
)
{
console
.
log
(
'
AI get event:
'
+
JSON
.
stringify
(
event
));
console
.
log
(
"
AI get event:
"
+
JSON
.
stringify
(
event
));
if
(
event
.
type
==
'
SERVER_updateStatus
'
)
{
if
(
event
.
type
==
"
SERVER_updateStatus
"
)
{
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
event
.
status
));
this
.
_status
=
JSON
.
parse
(
JSON
.
stringify
(
event
.
status
));
}
else
if
(
event
.
type
==
'
SERVER_playerRoll
'
)
{
}
else
if
(
event
.
type
==
"
SERVER_playerRoll
"
)
{
console
.
log
(
'
汪汪汪0
'
);
this
.
_status
.
letter
=
event
.
letter
;
this
.
_status
.
letter
=
event
.
letter
;
if
(
this
.
playerData
.
color
==
this
.
_status
.
current
)
{
if
(
this
.
playerData
.
color
==
this
.
_status
.
current
)
{
await
asyncDelay
(
Math
.
random
()
*
3
+
1
1
);
await
asyncDelay
(
Math
.
random
()
*
3
+
1
2
);
}
}
}
else
if
(
event
.
type
==
'
SERVER_playerRight
'
)
{
}
else
if
(
event
.
type
==
"
SERVER_playerRight
"
)
{
this
.
_status
.
letter
=
''
;
console
.
log
(
'
汪汪汪1
'
);
this
.
_status
.
letter
=
""
;
this
.
_status
[
event
.
color
]
=
event
.
idx
;
this
.
_status
[
event
.
color
]
=
event
.
idx
;
this
.
changeSide
();
this
.
changeSide
();
}
else
if
(
event
.
type
==
'
SERVER_playerWrong
'
)
{
}
else
if
(
event
.
type
==
"
SERVER_playerWrong
"
)
{
this
.
_status
.
letter
=
''
;
console
.
log
(
'
汪汪汪2
'
);
this
.
_status
.
letter
=
""
;
this
.
changeSide
();
this
.
changeSide
();
}
}
if
(
this
.
playerData
.
color
==
this
.
_status
.
current
)
{
if
(
this
.
playerData
.
color
==
this
.
_status
.
current
)
{
await
asyncDelay
(
Math
.
random
()
*
3
+
2
);
await
asyncDelay
(
Math
.
random
()
*
3
+
4
);
if
(
this
.
_status
.
letter
==
''
)
{
if
(
this
.
_status
.
letter
==
""
)
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
roll
'
,
type
:
"
roll
"
,
uuid
:
this
.
playerData
.
uuid
uuid
:
this
.
playerData
.
uuid
,
});
});
}
else
{
}
else
{
const
idx
=
this
.
getNextRightIdx
();
const
idx
=
this
.
getNextRightIdx
();
if
(
Math
.
random
()
>
0.5
)
{
if
(
Math
.
random
()
<
0.9
)
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
right
'
,
type
:
"
right
"
,
idx
:
idx
,
idx
:
idx
,
uuid
:
this
.
playerData
.
uuid
,
uuid
:
this
.
playerData
.
uuid
,
color
:
this
.
playerData
.
color
color
:
this
.
playerData
.
color
,
});
});
}
else
{
}
else
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
wrong
'
,
type
:
"
wrong
"
,
uuid
:
this
.
playerData
.
uuid
,
uuid
:
this
.
playerData
.
uuid
,
color
:
this
.
playerData
.
color
color
:
this
.
playerData
.
color
,
});
});
}
}
}
}
...
@@ -62,23 +65,23 @@ export class AI {
...
@@ -62,23 +65,23 @@ export class AI {
}
}
changeSide
()
{
changeSide
()
{
if
(
this
.
_status
.
current
==
'
Red
'
)
{
if
(
this
.
_status
.
current
==
"
Red
"
)
{
this
.
_status
.
current
=
'
Blue
'
;
this
.
_status
.
current
=
"
Blue
"
;
}
else
{
}
else
{
this
.
_status
.
current
=
'
Red
'
;
this
.
_status
.
current
=
"
Red
"
;
}
}
}
}
getNextRightIdx
()
{
getNextRightIdx
()
{
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
const
startIdx
=
this
.
_status
[
this
.
_status
.
current
];
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
const
targetNode
=
board
.
children
[
i
];
const
targetNode
=
board
.
children
[
i
];
const
itemData
=
targetNode
.
getComponent
(
'
ItemData
'
);
const
itemData
=
targetNode
.
getComponent
(
"
ItemData
"
);
if
(
itemData
.
letter
.
toLowerCase
()
==
this
.
_status
.
letter
.
toLowerCase
())
{
if
(
itemData
.
letter
.
toLowerCase
()
==
this
.
_status
.
letter
.
toLowerCase
())
{
return
i
;
return
i
;
}
}
}
}
return
-
1
;
return
-
1
;
}
}
}
}
\ No newline at end of file
assets/op_16/script/LoadingLayer.ts
View file @
912c2a58
...
@@ -97,6 +97,7 @@ export default class SceneComponent extends cc.Component {
...
@@ -97,6 +97,7 @@ export default class SceneComponent extends cc.Component {
cc
.
find
(
'
right
'
,
this
.
node
).
addChild
(
headNode
);
cc
.
find
(
'
right
'
,
this
.
node
).
addChild
(
headNode
);
const
vs
=
cc
.
find
(
'
vs
'
,
this
.
node
);
const
vs
=
cc
.
find
(
'
vs
'
,
this
.
node
);
asyncPlayDragonBoneAnimation
(
vs
,
'
normal
'
,
1
);
asyncPlayDragonBoneAnimation
(
vs
,
'
normal
'
,
1
);
this
.
playLocalAudio
(
'
match
'
);
}
}
const
rate
=
Math
.
min
(
1
,
this
.
_playerList
.
length
/
this
.
_maxPlayerNum
);
const
rate
=
Math
.
min
(
1
,
this
.
_playerList
.
length
/
this
.
_maxPlayerNum
);
...
@@ -231,6 +232,25 @@ export default class SceneComponent extends cc.Component {
...
@@ -231,6 +232,25 @@ export default class SceneComponent extends cc.Component {
}
}
});
});
}
}
playLocalAudio
(
name
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
stopCurrentPlayedAudio
();
const
audioNode
=
cc
.
find
(
`res/
${
name
}
`
,
this
.
node
);
if
(
!
audioNode
)
{
resolve
(
null
);
return
;
}
const
audioClip
=
audioNode
.
getComponent
(
cc
.
AudioSource
).
clip
;
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
this
.
currentPlayedAudioId
=
audioId
;
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
()
=>
{
resolve
(
null
);
});
});
}
_timeoutIds
=
[];
_timeoutIds
=
[];
_intervalIds
=
[];
_intervalIds
=
[];
// 生命周期
// 生命周期
...
...
assets/op_16/script/NetworkHelper.ts
View file @
912c2a58
This diff is collapsed.
Click to expand it.
assets/op_16/script/Server.ts
View file @
912c2a58
...
@@ -7,16 +7,25 @@ export class GameServer {
...
@@ -7,16 +7,25 @@ export class GameServer {
playerMaxNumber
=
0
;
playerMaxNumber
=
0
;
networkHelper
:
NetworkHelper
=
null
;
networkHelper
:
NetworkHelper
=
null
;
nameList
=
[
nameList
=
[
'
Chris
'
,
'
Benny
'
,
'
Leslie
'
,
'
Devin
'
,
'
Sam
'
,
"
Chris
"
,
'
Kerry
'
,
'
Joey
'
,
'
Hailey
'
,
'
Fred
'
,
'
Arrow
'
,
"
Benny
"
,
'
Tony
'
,
'
Michael
'
,
"
Leslie
"
,
"
Devin
"
,
"
Sam
"
,
"
Kerry
"
,
"
Joey
"
,
"
Hailey
"
,
"
Fred
"
,
"
Arrow
"
,
"
Tony
"
,
"
Michael
"
,
];
];
headUrls
=
[
headUrls
=
[
'
http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png
'
,
"
http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png
"
,
'
http://staging-teach.cdn.ireadabc.com/f596e586a31ac2813b1702557941c022.png
'
,
"
http://staging-teach.cdn.ireadabc.com/f596e586a31ac2813b1702557941c022.png
"
,
'
http://staging-teach.cdn.ireadabc.com/f0f396c52c42239913fd94523db979fa.png
'
,
"
http://staging-teach.cdn.ireadabc.com/f0f396c52c42239913fd94523db979fa.png
"
,
'
http://staging-teach.cdn.ireadabc.com/9f2d2ef622fa33d4e2abcbdc4b40ab6a.png
'
,
"
http://staging-teach.cdn.ireadabc.com/9f2d2ef622fa33d4e2abcbdc4b40ab6a.png
"
,
'
http://staging-teach.cdn.ireadabc.com/f40ce4a8630039c4cf48a63fc1399c52.png
'
"
http://staging-teach.cdn.ireadabc.com/f40ce4a8630039c4cf48a63fc1399c52.png
"
,
];
];
constructor
(
playerMaxNumber
,
networkHelper
)
{
constructor
(
playerMaxNumber
,
networkHelper
)
{
...
@@ -33,19 +42,20 @@ export class GameServer {
...
@@ -33,19 +42,20 @@ export class GameServer {
}
}
async
addPlayer
(
player
)
{
async
addPlayer
(
player
)
{
console
.
log
(
'
addPlayer
'
);
console
.
log
(
"
addPlayer
"
);
this
.
playerList
.
push
({
this
.
playerList
.
push
({
name
:
this
.
nameList
.
splice
(
0
,
1
)[
0
],
name
:
this
.
nameList
.
splice
(
0
,
1
)[
0
],
uuid
:
player
.
uuid
,
uuid
:
player
.
uuid
,
color
:
player
.
uuid
==
this
.
networkHelper
.
room
.
roomInfo
.
owner
?
'
Blue
'
:
'
Red
'
,
color
:
player
.
uuid
==
this
.
networkHelper
.
room
.
roomInfo
.
owner
?
"
Blue
"
:
"
Red
"
,
isAI
:
player
.
isAI
,
isAI
:
player
.
isAI
,
headUrl
:
this
.
headUrls
.
splice
(
0
,
1
)[
0
]
headUrl
:
this
.
headUrls
.
splice
(
0
,
1
)[
0
]
,
});
});
await
asyncDelay
(
1
);
await
asyncDelay
(
1
);
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_allPlayerInfo
'
,
type
:
"
SERVER_allPlayerInfo
"
,
playerData
:
this
.
playerList
playerData
:
this
.
playerList
,
});
});
if
(
this
.
playerList
.
length
==
this
.
playerMaxNumber
)
{
if
(
this
.
playerList
.
length
==
this
.
playerMaxNumber
)
{
...
@@ -59,83 +69,90 @@ export class GameServer {
...
@@ -59,83 +69,90 @@ export class GameServer {
gameStatus
=
{
gameStatus
=
{
Red
:
0
,
Red
:
0
,
Blue
:
0
,
Blue
:
0
,
letter
:
''
,
letter
:
""
,
current
:
'
Blue
'
current
:
"
Blue
"
,
};
};
startGame
()
{
startGame
()
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_updateStatus
'
,
type
:
"
SERVER_updateStatus
"
,
status
:
this
.
gameStatus
status
:
this
.
gameStatus
,
});
});
}
}
onPlayerJoin
(
event
)
{
onPlayerJoin
(
event
)
{
this
.
addPlayer
({
this
.
addPlayer
({
uuid
:
event
.
data
.
joinPlayerId
,
uuid
:
event
.
data
.
joinPlayerId
,
isAI
:
false
isAI
:
false
,
});
});
}
}
_aiPlayerList
=
[];
_aiPlayerList
=
[];
startMatch
()
{
startMatch
()
{
for
(
let
i
=
0
;
i
<
this
.
playerMaxNumber
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
playerMaxNumber
;
i
++
)
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
const
count
=
this
.
playerMaxNumber
-
this
.
playerList
.
length
;
setTimeout
(()
=>
{
if
(
count
>
0
)
{
const
count
=
this
.
playerMaxNumber
-
this
.
playerList
.
length
;
const
playerInfo
=
{
if
(
count
>
0
)
{
uuid
:
'
ai_
'
+
i
,
const
playerInfo
=
{
isAI
:
true
,
uuid
:
"
ai_
"
+
i
,
color
:
'
Red
'
isAI
:
true
,
color
:
"
Red
"
,
};
this
.
_aiPlayerList
.
push
(
new
AI
(
this
.
networkHelper
,
playerInfo
));
this
.
addPlayer
(
playerInfo
);
}
}
this
.
_aiPlayerList
.
push
(
new
AI
(
this
.
networkHelper
,
playerInfo
));
},
RandomInt
(
10000
,
15000
))
this
.
addPlayer
(
playerInfo
);
);
}
},
RandomInt
(
10000
,
15000
)));
}
}
}
}
onFrameEvent
(
data
)
{
onFrameEvent
(
data
)
{
if
(
data
.
type
==
'
roll
'
)
{
if
(
this
.
gameStatus
.
gameOver
)
{
return
;
}
if
(
data
.
type
==
"
roll
"
)
{
const
letterList
=
this
.
getLetterList
();
const
letterList
=
this
.
getLetterList
();
if
(
letterList
.
length
>
0
)
{
if
(
letterList
.
length
>
0
)
{
const
letter
=
letterList
[
RandomInt
(
letterList
.
length
)];
const
letter
=
letterList
[
RandomInt
(
letterList
.
length
)];
this
.
gameStatus
.
letter
=
letter
;
this
.
gameStatus
.
letter
=
letter
;
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_playerRoll
'
,
type
:
"
SERVER_playerRoll
"
,
letter
:
letter
letter
:
letter
,
});
});
}
else
{
}
else
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_playerWin
'
,
type
:
"
SERVER_playerWin
"
,
color
:
this
.
gameStatus
.
current
color
:
this
.
gameStatus
.
current
,
});
});
this
.
gameStatus
.
gameOver
=
true
;
}
}
}
else
if
(
data
.
type
==
'
right
'
)
{
}
else
if
(
data
.
type
==
"
right
"
)
{
this
.
gameStatus
[
data
.
color
]
=
data
.
idx
;
this
.
gameStatus
[
data
.
color
]
=
data
.
idx
;
const
letterList
=
this
.
getLetterList
();
const
letterList
=
this
.
getLetterList
();
console
.
log
(
'
letterList =
'
+
JSON
.
stringify
(
letterList
));
console
.
log
(
"
letterList =
"
+
JSON
.
stringify
(
letterList
));
if
(
letterList
.
length
>
0
)
{
if
(
letterList
.
length
>
0
)
{
this
.
changeSide
();
this
.
changeSide
();
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_playerRight
'
,
type
:
"
SERVER_playerRight
"
,
idx
:
data
.
idx
,
idx
:
data
.
idx
,
uuid
:
data
.
uuid
,
uuid
:
data
.
uuid
,
color
:
data
.
color
color
:
data
.
color
,
});
});
}
else
{
}
else
{
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_playerWin
'
,
type
:
"
SERVER_playerWin
"
,
color
:
this
.
gameStatus
.
current
color
:
this
.
gameStatus
.
current
,
});
});
this
.
gameStatus
.
gameOver
=
true
;
}
}
}
else
if
(
data
.
type
==
'
wrong
'
)
{
}
else
if
(
data
.
type
==
"
wrong
"
)
{
console
.
log
(
'
data =
'
+
JSON
.
stringify
(
data
));
console
.
log
(
"
data =
"
+
JSON
.
stringify
(
data
));
// this.gameStatus[data.color] = data.idx;
// this.gameStatus[data.color] = data.idx;
this
.
changeSide
();
this
.
changeSide
();
this
.
networkHelper
.
sendFrame
({
this
.
networkHelper
.
sendFrame
({
type
:
'
SERVER_playerWrong
'
,
type
:
"
SERVER_playerWrong
"
,
uuid
:
data
.
uuid
,
uuid
:
data
.
uuid
,
color
:
data
.
color
color
:
data
.
color
,
});
});
}
else
{
}
else
{
this
.
_aiPlayerList
.
forEach
((
ai
:
AI
)
=>
{
this
.
_aiPlayerList
.
forEach
((
ai
:
AI
)
=>
{
...
@@ -145,19 +162,19 @@ export class GameServer {
...
@@ -145,19 +162,19 @@ export class GameServer {
}
}
getLetterList
()
{
getLetterList
()
{
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
board
=
cc
.
find
(
"
Canvas/bg/chessBoard/boardItems
"
);
const
color
=
this
.
gameStatus
.
current
;
const
color
=
this
.
gameStatus
.
current
;
console
.
log
(
"
color =
"
+
color
);
console
.
log
(
"
color =
"
+
color
);
console
.
log
(
'
this.gameStatus =
'
+
JSON
.
stringify
(
this
.
gameStatus
));
console
.
log
(
"
this.gameStatus =
"
+
JSON
.
stringify
(
this
.
gameStatus
));
const
startIdx
=
this
.
gameStatus
[
color
];
const
startIdx
=
this
.
gameStatus
[
color
];
console
.
log
(
'
startIdx =
'
+
startIdx
);
console
.
log
(
"
startIdx =
"
+
startIdx
);
const
letterList
=
[];
const
letterList
=
[];
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
const
targetNode
=
board
.
children
[
i
];
const
targetNode
=
board
.
children
[
i
];
const
itemData
=
targetNode
.
getComponent
(
'
ItemData
'
);
const
itemData
=
targetNode
.
getComponent
(
"
ItemData
"
);
const
nodeLetter
=
itemData
.
letter
.
toUpperCase
();
const
nodeLetter
=
itemData
.
letter
.
toUpperCase
();
if
(
!
letterList
.
find
(
letter
=>
letter
==
nodeLetter
))
{
if
(
!
letterList
.
find
(
(
letter
)
=>
letter
==
nodeLetter
))
{
letterList
.
push
(
nodeLetter
);
letterList
.
push
(
nodeLetter
);
}
}
}
}
...
@@ -165,30 +182,28 @@ export class GameServer {
...
@@ -165,30 +182,28 @@ export class GameServer {
}
}
changeSide
()
{
changeSide
()
{
if
(
this
.
gameStatus
.
current
==
'
Red
'
)
{
if
(
this
.
gameStatus
.
current
==
"
Red
"
)
{
this
.
gameStatus
.
current
=
'
Blue
'
;
this
.
gameStatus
.
current
=
"
Blue
"
;
}
else
{
}
else
{
this
.
gameStatus
.
current
=
'
Red
'
;
this
.
gameStatus
.
current
=
"
Red
"
;
}
}
}
}
startAI
()
{
startAI
()
{
this
.
playerList
this
.
playerList
.
filter
(
player
=>
player
.
isAI
==
true
)
.
filter
((
player
)
=>
player
.
isAI
==
true
)
.
forEach
(
player
=>
{
.
forEach
((
player
)
=>
{});
});
}
}
_timeoutIds
=
null
;
_timeoutIds
=
null
;
_intervalIds
=
null
;
_intervalIds
=
null
;
// 生命周期
// 生命周期
onDestroy
()
{
onDestroy
()
{
this
.
_timeoutIds
.
forEach
(
id
=>
{
this
.
_timeoutIds
.
forEach
(
(
id
)
=>
{
clearTimeout
(
id
);
clearTimeout
(
id
);
});
});
this
.
_intervalIds
.
forEach
(
id
=>
{
this
.
_intervalIds
.
forEach
(
(
id
)
=>
{
clearInterval
(
id
);
clearInterval
(
id
);
});
});
}
}
}
}
\ No newline at end of file
assets/op_16/textures/yourturn.png
0 → 100644
View file @
912c2a58
30.3 KB
assets/op_16/textures/yourturn.png.meta
0 → 100644
View file @
912c2a58
{
"ver": "2.3.5",
"uuid": "e1c1011c-37ad-47ab-b75c-0528fb58912e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 584,
"height": 235,
"platformSettings": {},
"subMetas": {
"yourturn": {
"ver": "1.0.4",
"uuid": "eeb8a1d1-4858-4241-8733-38b1cff4c7cf",
"rawTextureUuid": "e1c1011c-37ad-47ab-b75c-0528fb58912e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 584,
"height": 235,
"rawWidth": 584,
"rawHeight": 235,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
package-lock.json
View file @
912c2a58
...
@@ -616,6 +616,11 @@
...
@@ -616,6 +616,11 @@
"mime-types"
:
"~2.1.24"
"mime-types"
:
"~2.1.24"
}
}
},
},
"typescript"
:
{
"version"
:
"4.5.5"
,
"resolved"
:
"https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz"
,
"integrity"
:
"sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA=="
},
"unpipe"
:
{
"unpipe"
:
{
"version"
:
"1.0.0"
,
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/unpipe/download/unpipe-1.0.0.tgz"
,
"resolved"
:
"https://registry.npm.taobao.org/unpipe/download/unpipe-1.0.0.tgz"
,
...
...
package.json
View file @
912c2a58
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
"
crypto-js
"
:
"
^4.1.1
"
,
"
crypto-js
"
:
"
^4.1.1
"
,
"
express
"
:
"
^4.17.1
"
,
"
express
"
:
"
^4.17.1
"
,
"
js-base64
"
:
"
^3.7.2
"
,
"
js-base64
"
:
"
^3.7.2
"
,
"
typescript
"
:
"
^4.5.5
"
,
"
uuid
"
:
"
^8.3.2
"
"
uuid
"
:
"
^8.3.2
"
}
}
}
}
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