Commit 145fbcf9 authored by 杨一航's avatar 杨一航

v1.0

parent 174d6104
{"frameRate":24,"name":"coin_overturn","version":"5.5","compatibleVersion":"5.5","armature":[{"type":"Armature","frameRate":24,"name":"Armature","aabb":{"x":-119,"y":-85.5,"width":233,"height":178},"bone":[{"name":"root"},{"length":43,"name":"1","parent":"root","transform":{"x":-1.25,"y":-4.45,"skX":-86.688,"skY":-86.688}}],"slot":[{"name":"1","parent":"1"}],"skin":[{"slot":[{"name":"1","display":[{"name":"coin_overturn/1","transform":{"x":-8.01,"y":-0.79,"skX":86.69,"skY":86.69}},{"name":"coin_overturn/2","transform":{"x":-8.01,"y":-0.79,"skX":86.69,"skY":86.69}},{"name":"coin_overturn/3","transform":{"x":-5.4,"y":1.06,"skX":86.69,"skY":86.69}},{"name":"coin_overturn/4","transform":{"x":-4.96,"y":0.04,"skX":86.69,"skY":86.69}},{"name":"coin_overturn/5","transform":{"x":-6.01,"y":-0.9,"skX":86.69,"skY":86.69}},{"name":"coin_overturn/6","transform":{"x":-8.01,"y":-0.79,"skX":86.69,"skY":86.69}},{"name":"coin_overturn/7","transform":{"x":-5.01,"y":-0.96,"skX":86.69,"skY":86.69}}]}]}],"animation":[{"duration":14,"playTimes":0,"name":"normal","slot":[{"name":"1","displayFrame":[{},{"value":1},{"value":2},{"value":3},{"value":4},{"value":5},{"value":6},{},{"value":1},{"value":2},{"value":3},{"value":4},{"value":5},{"value":6},{"duration":0}]}]}],"defaultActions":[{"gotoAndPlay":"normal"}]}]}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "2b6b7708-44d5-4679-9880-777f48407ec1",
"subMetas": {}
}
\ No newline at end of file
{"width":512,"SubTexture":[{"width":233,"y":1,"height":178,"name":"coin_overturn/7","x":1},{"width":253,"y":181,"height":98,"name":"coin_overturn/2","x":1},{"width":257,"y":365,"height":59,"name":"coin_overturn/3","x":1},{"width":253,"y":181,"height":98,"name":"coin_overturn/6","x":256},{"width":253,"y":281,"height":82,"name":"coin_overturn/5","x":1},{"width":233,"y":1,"height":178,"name":"coin_overturn/1","x":236},{"width":255,"y":281,"height":58,"name":"coin_overturn/4","x":256}],"height":512,"name":"coin_overturn","imagePath":"coin_overturn_tex.png"}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "d2e64191-0d23-44ba-bd59-24a0b80c6525",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "f48beade-3501-49c9-87c5-0657f20ff2f4",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 512,
"height": 512,
"platformSettings": {},
"subMetas": {
"coin_overturn_tex": {
"ver": "1.0.4",
"uuid": "907db0c0-a56c-4168-aa9f-6c5630628187",
"rawTextureUuid": "f48beade-3501-49c9-87c5-0657f20ff2f4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 43.5,
"trimX": 1,
"trimY": 1,
"width": 510,
"height": 423,
"rawWidth": 512,
"rawHeight": 512,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
...@@ -29,14 +29,11 @@ export class GameServer { ...@@ -29,14 +29,11 @@ export class GameServer {
"http://staging-teach.cdn.ireadabc.com/f40ce4a8630039c4cf48a63fc1399c52.png", "http://staging-teach.cdn.ireadabc.com/f40ce4a8630039c4cf48a63fc1399c52.png",
]; ];
jumpList = [
// { from: 2, rto: 11 ,wto:1},
];
forceWrongIndexList = [];
private _totalStep: any; private _totalStep: any;
randomList = []; randomList = [];
private _useAI: boolean; private _useAI: boolean;
private _timer: number;
private _totalTime: number = 150;
constructor(playerMaxNumber, networkHelper) { constructor(playerMaxNumber, networkHelper) {
this.playerMaxNumber = playerMaxNumber; this.playerMaxNumber = playerMaxNumber;
...@@ -80,14 +77,20 @@ export class GameServer { ...@@ -80,14 +77,20 @@ export class GameServer {
gameStatus = { gameStatus = {
state: 0,// -1:未开始 0 准备阶段 1 roll 2 判定 state: 0,// -1:未开始 0 准备阶段 1 roll 2 判定
Red: -1, Red: 0,
Blue: -1, Blue: 0,
RedTime: 0,
BlueTime: 0,
step: 0, step: 0,
current: "Red", current: "Red",
jump: false, time: "0"
back: false,
}; };
startGame() { startGame() {
this.openTimerCounter();
console.log("startGame set time ------");
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: "SERVER_updateStatus", type: "SERVER_updateStatus",
status: this.gameStatus, status: this.gameStatus,
...@@ -154,57 +157,46 @@ export class GameServer { ...@@ -154,57 +157,46 @@ export class GameServer {
} }
if (sender.color == this.gameStatus.current) { if (sender.color == this.gameStatus.current) {
let nowStep = this.gameStatus[this.gameStatus.current];
let index = Math.floor(Math.random() * this.randomList.length) let i = Math.floor(Math.random() * this.randomList.length)
let step = this.randomList[index]; let index = this.randomList[i];
// if (nowStep < 5) {
// step = 3; console.log("random index ===" + index);
// } else { this.gameStatus.step = index;
// step = 1;
// }
// step = 3
step = Math.min(step, this._totalStep - 1 - nowStep);
console.log("random step ===" + step);
this.gameStatus.step = step;
this.gameStatus.state = 1; this.gameStatus.state = 1;
let endStep = nowStep + step;
this.gameStatus.back = false;
if (this.forceWrongIndexList.indexOf(endStep) > -1) {
this.gameStatus.back = true;
this.networkHelper.sendFrame({
type: "SERVER_playerRoll",
status: this.gameStatus,
});
this.gameStatus.state = 2;
this.gameStatus.step = null;
this.changeSide();
} else {
this.networkHelper.sendFrame({
type: "SERVER_playerRoll",
status: this.gameStatus,
});
} this.networkHelper.sendFrame({
type: "SERVER_playerRoll",
status: this.gameStatus,
});
} else { } else {
console.warn("data uuid not match"); console.warn("data uuid not match");
} }
} }
else if (data.type == "right") { else if (data.type == "right") {
let nowStep: number = this.gameStatus[this.gameStatus.current];
console.log("nowStep === " + nowStep); let posIndex = this.gameStatus.step
const jump = this.jumpList.find(jump => parseInt(jump.from) == nowStep + this.gameStatus.step); this.gameStatus[this.gameStatus.current]++;
this.gameStatus[this.gameStatus.current] = jump?.rto ? parseInt(jump.rto) : nowStep + this.gameStatus.step; let lastTime = +this.gameStatus.time;
console.log("lasttime = " + lastTime);
if (jump) { let costTime = (Math.floor(Date.now() / 1000) - lastTime).toFixed(1)
console.log("jump============="); console.log("=right===cost time = " + costTime);
console.log(jump); if (this.gameStatus.current == "Red") {
this.gameStatus.RedTime += +costTime
} else {
this.gameStatus.BlueTime += +costTime
} }
if (this.gameStatus[this.gameStatus.current] < this._totalStep - 1) {
let i = this.randomList.indexOf(posIndex);
this.randomList[i] = this.randomList[this.randomList.length - 1];
this.randomList.length--;
if (this.gameStatus[this.gameStatus.current] < 10) {
this.gameStatus.step = null; this.gameStatus.step = null;
this.gameStatus.state = 2; this.gameStatus.state = 2;
this.gameStatus.jump = !!jump?.rto;
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: "SERVER_playerRight", type: "SERVER_playerRight",
status: this.gameStatus, status: this.gameStatus,
...@@ -213,7 +205,6 @@ export class GameServer { ...@@ -213,7 +205,6 @@ export class GameServer {
} else { } else {
this.gameStatus.state = 2; this.gameStatus.state = 2;
this.gameStatus.step = null; this.gameStatus.step = null;
this.gameStatus.jump = !!jump;
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: "SERVER_playerWin", type: "SERVER_playerWin",
status: this.gameStatus, status: this.gameStatus,
...@@ -222,15 +213,19 @@ export class GameServer { ...@@ -222,15 +213,19 @@ export class GameServer {
} }
} else if (data.type == "wrong") { } else if (data.type == "wrong") {
console.log("data = " + JSON.stringify(data));
let nowStep: number = this.gameStatus[this.gameStatus.current]; let lastTime = +this.gameStatus.time;
console.log("nowStep === " + nowStep); let costTime = (Math.floor(Date.now() / 1000) - lastTime).toFixed(1)
const jump = this.jumpList.find(jump => parseInt(jump.from) == nowStep + this.gameStatus.step); console.log("=wrong and ===cost time = " + costTime);
this.gameStatus[this.gameStatus.current] = jump?.wto ? parseInt(jump.wto) : nowStep; if (this.gameStatus.current == "Red") {
this.gameStatus.RedTime += +costTime
} else {
this.gameStatus.BlueTime += +costTime
}
this.gameStatus.step = null; this.gameStatus.step = null;
this.gameStatus.state = 2; this.gameStatus.state = 2;
this.gameStatus.jump = !!jump?.wto;
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: "SERVER_playerWrong", type: "SERVER_playerWrong",
status: this.gameStatus, status: this.gameStatus,
...@@ -241,15 +236,19 @@ export class GameServer { ...@@ -241,15 +236,19 @@ export class GameServer {
if (this._useAI || sender.color == this.gameStatus.current) { if (this._useAI || sender.color == this.gameStatus.current) {
if (this.gameStatus.state == 2 || this.gameStatus.back) { if (this.gameStatus.state == 2) {
this.gameStatus.state = 0; this.gameStatus.state = 0;
} }
if (this.gameStatus.state == 0) {
this.openTimerCounter();
}
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: "SERVER_updateStatus", type: "SERVER_updateStatus",
status: this.gameStatus, status: this.gameStatus,
}); });
this.gameStatus.jump = null;
this.gameStatus.back = null;
} }
} }
...@@ -264,6 +263,50 @@ export class GameServer { ...@@ -264,6 +263,50 @@ export class GameServer {
this._totalStep = step; this._totalStep = step;
} }
openTimerCounter() {
let prepareTime = 4;
// AI 无准备时间
if (this._useAI && this.gameStatus.current == "Blue") {
prepareTime = 0
}
this.gameStatus.time = "" + (Math.floor(Date.now() / 1000) + prepareTime);
console.log(" openTimerCounter set time ------");
clearTimeout(this._timer)
let leftTime = this.gameStatus.BlueTime
if (this.gameStatus.current == "Red") {
leftTime = this.gameStatus.RedTime;
}
leftTime = this._totalTime - leftTime + prepareTime;
console.log(`${this.gameStatus.current} left time ${leftTime}, now time ${Date.now() / 1000}`)
this._timer = setTimeout(this.timeOver.bind(this), leftTime * 1000);
}
timeOver() {
let lastTime = +this.gameStatus.time;
let costTime = (Math.floor(Date.now() / 1000) - lastTime).toFixed(1)
console.log(`time over and time now ${Date.now() / 1000}`);
console.log("=wrong and ===cost time = " + costTime);
if (this.gameStatus.current == "Red") {
this.gameStatus.RedTime += +costTime
} else {
this.gameStatus.BlueTime += +costTime
}
if (this.gameStatus.current == "Red") {
this.gameStatus.current = "Blue"
}
this.gameStatus.state = 2;
this.gameStatus.step = null;
this.networkHelper.sendFrame({
type: "SERVER_playerWin",
status: this.gameStatus,
});
this.gameStatus['gameOver'] = true;
}
changeSide() { changeSide() {
......
{
"ver": "2.3.5",
"uuid": "a2aaf5ad-5e41-4c6b-8e88-20d13def81e2",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 65,
"height": 65,
"platformSettings": {},
"subMetas": {
"红色方标记": {
"ver": "1.0.4",
"uuid": "0d662d0a-e52c-465c-b2e3-3ded3c5c5cf3",
"rawTextureUuid": "a2aaf5ad-5e41-4c6b-8e88-20d13def81e2",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 1,
"trimX": 2,
"trimY": 0,
"width": 61,
"height": 63,
"rawWidth": 65,
"rawHeight": 65,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "4a17542f-6342-48aa-ac6a-6c41cca3c59a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 65,
"height": 65,
"platformSettings": {},
"subMetas": {
"蓝色方标记": {
"ver": "1.0.4",
"uuid": "5ccb965e-4c30-4b3a-914c-20367db3d00f",
"rawTextureUuid": "4a17542f-6342-48aa-ac6a-6c41cca3c59a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 1,
"trimX": 2,
"trimY": 0,
"width": 61,
"height": 63,
"rawWidth": 65,
"rawHeight": 65,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment