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
0073dffd
Commit
0073dffd
authored
Dec 13, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
parent
857b0688
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1738 additions
and
494 deletions
+1738
-494
ItemData.ts
assets/op_16/scene/ItemData.ts
+18
-0
ItemData.ts.meta
assets/op_16/scene/ItemData.ts.meta
+9
-0
NetworkHelper.ts
assets/op_16/scene/NetworkHelper.ts
+8
-11
op_16.fire
assets/op_16/scene/op_16.fire
+1550
-471
op_16.ts
assets/op_16/scene/op_16.ts
+83
-6
house.png
assets/op_16/textures/boardImgs/house.png
+0
-0
house.png.meta
assets/op_16/textures/boardImgs/house.png.meta
+36
-0
chessBoard.png
assets/op_16/textures/chessBoard.png
+0
-0
chessBoard.png.meta
assets/op_16/textures/chessBoard.png.meta
+6
-6
app.js
bin/app.js
+28
-0
No files found.
assets/op_16/scene/ItemData.ts
0 → 100644
View file @
0073dffd
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
export
default
class
NewClass
extends
cc
.
Component
{
@
property
letter
:
string
=
''
;
@
property
idx
:
string
=
''
;
@
property
word
:
string
=
''
;
}
assets/op_16/scene/ItemData.ts.meta
0 → 100644
View file @
0073dffd
{
"ver": "1.0.8",
"uuid": "95f09492-075f-4331-ae66-6c5934703419",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/op_16/scene/NetworkHelper.ts
View file @
0073dffd
...
...
@@ -43,17 +43,14 @@ export class NetworkHelper {
const
gameInfo
:
MGOBE
.
types
.
GameInfoPara
=
{
gameId
:
gameId
,
openId
:
openId
,
secretKey
:
"
060d81c7abaf24c8ce2afc5a725c152062676d35
"
,
// createSignature: (callback) => {
// this.callNetworkApiGet('http://192.168.3.142:8081', '/getSign', {
// gameId: gameId,
// openId: openId,
// }, (data) => {
// const signature = JSON.parse(data);
// console.log(JSON.stringify(signature));
// callback(signature);
// });
// }
createSignature
:
(
callback
)
=>
{
this
.
callNetworkApiGet
(
'
http://staging-teach.ireadabc.com
'
,
'
/api/oxford/game/v1/config
'
,
{
gameid
:
gameId
,
openid
:
openId
,
},
(
data
)
=>
{
callback
(
JSON
.
parse
(
data
));
});
}
};
const
serverUrl
=
"
i4ql53h1.wxlagame.com
"
;
//替换为控制台上的 域名
...
...
assets/op_16/scene/op_16.fire
View file @
0073dffd
This diff is collapsed.
Click to expand it.
assets/op_16/scene/op_16.ts
View file @
0073dffd
import
{
asyncDelay
,
onHomeworkFinish
,
RandomInt
}
from
"
../script/util
"
;
import
{
asyncDelay
,
asyncTweenTo
,
onHomeworkFinish
,
RandomInt
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
{
NetworkHelper
}
from
"
./NetworkHelper
"
;
...
...
@@ -28,14 +28,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
initListener
();
}
gameData
;
playerId
;
networkHelper
:
NetworkHelper
;
async
initData
()
{
this
.
networkHelper
=
new
NetworkHelper
();
// this.networkHelper.initListener();
await
this
.
networkHelper
.
initRoom
();
this
.
playerId
=
await
this
.
networkHelper
.
joinRoom
(
'
op_16
'
,
2
);
this
.
gameData
=
{
Red
:
0
,
Blue
:
0
,
current
:
'
Blue
'
};
this
.
playerId
=
await
this
.
networkHelper
.
init
(
'
op_16
'
,
2
);
const
roomInfo
=
this
.
networkHelper
.
getRoomInfo
();
if
(
roomInfo
.
playerList
.
length
==
roomInfo
.
maxPlayers
)
{
...
...
@@ -89,6 +88,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
initView
()
{
this
.
initBg
();
this
.
initPiece
();
}
initBg
()
{
...
...
@@ -100,11 +100,88 @@ export default class SceneComponent extends MyCocosSceneComponent {
bg
.
scale
=
Math
.
min
(
canvas
.
width
/
bg
.
width
,
canvas
.
height
/
bg
.
height
);
}
// update (dt) {},
initPiece
()
{
const
offsetX
=
{
Red
:
-
45
,
Blue
:
45
};
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
pieceNodeRed
=
cc
.
find
(
`Canvas/bg/chessBoard/pieceRed`
)
const
startIdxRed
=
this
.
gameData
[
'
Red
'
];
const
boardNodeRed
=
board
.
children
[
startIdxRed
];
pieceNodeRed
.
x
=
boardNodeRed
.
x
+
offsetX
.
Red
;
pieceNodeRed
.
y
=
boardNodeRed
.
y
;
const
pieceNodeBlue
=
cc
.
find
(
`Canvas/bg/chessBoard/pieceBlue`
)
const
startIdxBlue
=
this
.
gameData
[
'
Blue
'
];
const
boardNodeBlue
=
board
.
children
[
startIdxBlue
];
pieceNodeBlue
.
x
=
boardNodeBlue
.
x
+
offsetX
.
Blue
;
pieceNodeBlue
.
y
=
boardNodeBlue
.
y
;
}
// update (dt) {},
initListener
()
{
const
btn
=
cc
.
find
(
'
Canvas/bg/New Button
'
);
btn
.
on
(
'
click
'
,
async
()
=>
{
const
idx
=
RandomInt
(
6
);
await
this
.
rollTheDice
(
idx
);
this
.
movePiece
(
[
'
A
'
,
'
B
'
,
'
C
'
,
'
D
'
,
'
E
'
,
'
F
'
][
idx
],
this
.
gameData
.
current
);
});
}
async
movePiece
(
letter
,
color
)
{
const
offsetX
=
{
Red
:
-
45
,
Blue
:
45
};
const
pieceNode
=
cc
.
find
(
`Canvas/bg/chessBoard/piece
${
color
}
`
)
const
board
=
cc
.
find
(
'
Canvas/bg/chessBoard/boardItems
'
);
const
startIdx
=
this
.
gameData
[
color
];
for
(
let
i
=
startIdx
+
1
;
i
<
board
.
children
.
length
;
i
++
)
{
const
targetNode
=
board
.
children
[
i
];
const
itemData
=
targetNode
.
getComponent
(
'
ItemData
'
);
const
prograssbar
=
cc
.
find
(
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/life_
${
color
.
toLowerCase
()}
/mask/prograssbar`
);
const
mask
=
cc
.
find
(
`Canvas/bg/Life
${
color
.
toLowerCase
()}
/life_
${
color
.
toLowerCase
()}
/mask`
);
const
targetHeight
=
(
i
/
board
.
children
.
length
)
*
prograssbar
.
height
;
cc
.
tween
(
mask
)
.
to
(
1
,
{
height
:
targetHeight
},
{
easing
:
'
cubicInOut
'
})
.
start
();
await
asyncTweenTo
(
pieceNode
,
1
,
{
x
:
targetNode
.
x
+
offsetX
[
color
],
y
:
targetNode
.
y
},
{
easing
:
'
cubicInOut
'
});
if
(
itemData
.
letter
.
toLowerCase
()
==
letter
.
toLowerCase
())
{
this
.
gameData
[
color
]
=
i
;
return
;
}
}
this
.
finish
();
}
finish
()
{
onHomeworkFinish
();
}
rollTheDice
(
num
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
dice
=
cc
.
find
(
'
Canvas/bg/chessBoard/diceBg/dice
'
);
const
targetAngle
=
Math
.
ceil
(
dice
.
angle
/
360
+
1
)
*
360
;
const
time
=
(
targetAngle
-
360
-
dice
.
angle
)
/
360
;
cc
.
tween
(
dice
)
.
by
(
3
,
{
angle
:
360
},
{
easing
:
"
cubicIn
"
})
.
to
(
time
,
{
angle
:
targetAngle
})
.
by
(
1
,
{
angle
:
360
})
.
by
(
1
,
{
angle
:
360
})
.
by
(
1
,
{
angle
:
360
})
.
by
(
1
,
{
angle
:
360
})
.
by
(
1
/
6
*
num
,
{
angle
:
60
*
num
})
.
by
(
3
,
{
angle
:
360
},
{
easing
:
"
cubicOut
"
})
.
call
(()
=>
{
resolve
(
null
);
})
.
start
();
});
}
playLocalAudio
(
audioName
)
{
...
...
assets/op_16/textures/boardImgs/house.png
0 → 100644
View file @
0073dffd
31.9 KB
assets/op_16/textures/boardImgs/house.png.meta
0 → 100644
View file @
0073dffd
{
"ver": "2.3.5",
"uuid": "b5d3e426-80a2-4f05-ab2d-c152235d3300",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 165,
"height": 141,
"platformSettings": {},
"subMetas": {
"house": {
"ver": "1.0.4",
"uuid": "dca8ea51-178a-4b32-a3d9-db19abe537ce",
"rawTextureUuid": "b5d3e426-80a2-4f05-ab2d-c152235d3300",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 0,
"trimY": 1,
"width": 165,
"height": 140,
"rawWidth": 165,
"rawHeight": 141,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
assets/op_16/textures/chessBoard.png
View replaced file @
857b0688
View file @
0073dffd
This diff is collapsed.
Click to expand it.
assets/op_16/textures/chessBoard.png.meta
View file @
0073dffd
...
...
@@ -7,8 +7,8 @@
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width":
1432
,
"height": 1
698
,
"width":
864
,
"height": 1
024
,
"platformSettings": {},
"subMetas": {
"chessBoard": {
...
...
@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width":
1432
,
"height": 1
698
,
"rawWidth":
1432
,
"rawHeight": 1
698
,
"width":
864
,
"height": 1
024
,
"rawWidth":
864
,
"rawHeight": 1
024
,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
...
...
bin/app.js
View file @
0073dffd
...
...
@@ -3,6 +3,7 @@ const os = require('os');
const
readline
=
require
(
'
readline
'
);
const
Base64
=
require
(
'
js-base64
'
);
const
CryptoJS
=
require
(
"
crypto-js
"
);
const
http
=
require
(
"
http
"
);
const
{
build
,
buildAndroid
,
buildIos
}
=
require
(
'
./buildCocos
'
);
const
networkInfo
=
os
.
networkInterfaces
();
...
...
@@ -46,6 +47,33 @@ app.get('/getSign', function (req, res) {
res
.
send
(
JSON
.
stringify
({
nonce
,
timestamp
,
sign
}));
});
// app.get('/jump', function (req, res) {
// res.header("Access-Control-Allow-Origin", "*");
// const gameId = req.query.gameId;
// const openId = req.query.openId;
// http.get({
// hostname: 'staging-teach.ireadabc.com',
// port: 80,
// path: `/api/oxford/game/v1/config?gameid=${gameId}&openid=${openId}`,
// agent: false // 仅为这个请求创建新代理
// }, (getres) => {
// getres.setEncoding('utf8');
// let rawData = '';
// getres.on('data', (chunk) => { rawData += chunk; });
// getres.on('end', () => {
// const secretKey = "060d81c7abaf24c8ce2afc5a725c152062676d35"; //替换为控制台上的 游戏 Key
// const data = JSON.parse(rawData);
// const str = `game_id=${gameId}&nonce=${data.nonce}&open_id=${openId}×tamp=${data.timestamp}`;
// const sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA1(str, secretKey));
// console.log('sign = ' + sign);
// res.send(rawData)
// });
// });
// });
let
port
=
''
;
var
server
=
app
.
listen
(
8081
,
function
()
{
...
...
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