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 source diff could not be displayed because it is too large. You can view the blob instead.
import { delayCall } from "../../../form/src/app/play/Unit";
import LoadingLayer from "../script/BoardGame_yyh_LoadingLayer";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import { NetworkHelper } from "../script/NetworkHelper";
......@@ -17,6 +18,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
@property(cc.Node)
cat = null
@property(cc.Node)
clockNode = null
@property(cc.Node)
cover = null
@property(cc.Node)
recordCat = null
......@@ -25,7 +28,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private _isRolling: any;
_randomList = ["1", "2", "3", "4", "5", "6"]
_randomList = [];
excellent: any;
_nowData: any;
private _myData: any;
......@@ -33,9 +36,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
private _playingAudio: boolean;
private _canClick: any;
private _recordBefore: boolean = false;
private _coinNode: cc.Node;
private _springNode: cc.Node;
private _leftTime: number;
private _redLb: cc.Label;
private _blueLb: cc.Label;
private _redDot: cc.Node;
private _blueDot: cc.Node;
private _lastIndex: any;
addPreloadImage() {
......@@ -65,13 +73,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
_status = {
state: -1,// -1:未开始 0 准备阶段 1 roll 2 判定
Red: -1,
Blue: -1,
state: 0,// -1:未开始 0 准备阶段 1 roll 2 判定
Red: 0,
Blue: 0,
RedTime: 0,
BlueTime: 0,
step: 0,
current: "Red",
jump: null,
back: null,
time: 0
};
playerId;
isRoomOwner;
......@@ -96,10 +105,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.log("房主");
this.isRoomOwner = true;
this.server = new GameServer(2, this.networkHelper);
this.server.jumpList = this.getJumpList();
this.server.randomList = this._randomList;
this.server.TotalStep = this._cardList.length;
this.server.forceWrongIndexList = this.getForceWrongList();
await this.networkHelper.startFrameSync();
this.server.addPlayer({
uuid: this.playerId,
......@@ -140,76 +148,76 @@ export default class SceneComponent extends MyCocosSceneComponent {
let cardDatas = [
{
id: 0, rJumpId: null, wJumpId: null, word: "cage", url: "",
id: 1, rJumpId: null, wJumpId: null, word: "cage", url: "",
},
{
id: 1, rJumpId: null, wJumpId: null, word: "cellphone", url: "",
id: 2, rJumpId: null, wJumpId: null, word: "cellphone", url: "",
},
{
id: 2, rJumpId: null, wJumpId: null, word: "cheese", url: "",
id: 3, rJumpId: null, wJumpId: null, word: "cheese", url: "",
},
{
id: 3, rJumpId: null, wJumpId: null, word: "city", url: "",
id: 4, rJumpId: null, wJumpId: null, word: "city", url: "",
},
{
id: 4, rJumpId: null, wJumpId: null, word: "desk", url: "",
id: 5, rJumpId: null, wJumpId: null, word: "desk", url: "",
},
{
id: 5, rJumpId: null, wJumpId: null, word: "giant", url: "",
id: 6, rJumpId: null, wJumpId: null, word: "giant", url: "",
},
{
id: 6, rJumpId: null, wJumpId: null, word: "giraffe", url: "",
id: 7, rJumpId: null, wJumpId: null, word: "giraffe", url: "",
},
{
id: 7, rJumpId: null, wJumpId: null, word: "icecream", url: "",
id: 8, rJumpId: null, wJumpId: null, word: "icecream", url: "",
},
{
id: 8, rJumpId: null, wJumpId: null, word: "jeans", url: "",
id: 9, rJumpId: null, wJumpId: null, word: "jeans", url: "",
},
{
id: 9, rJumpId: null, wJumpId: null, word: "legs", url: "",
id: 10, rJumpId: null, wJumpId: null, word: "legs", url: "",
},
{
id: 10, rJumpId: null, wJumpId: null, word: "orange", url: "",
id: 11, rJumpId: null, wJumpId: null, word: "orange", url: "",
},
{
id: 11, rJumpId: null, wJumpId: null, word: "rice", url: "",
id: 12, rJumpId: null, wJumpId: null, word: "rice", url: "",
},
{
id: 12, rJumpId: null, wJumpId: null, word: "rose", url: "",
id: 13, rJumpId: null, wJumpId: null, word: "rose", url: "",
},
{
id: 13, rJumpId: null, wJumpId: null, word: "scale", url: "",
id: 14, rJumpId: null, wJumpId: null, word: "scale", url: "",
},
{
id: 14, rJumpId: null, wJumpId: null, word: "school", url: "",
id: 15, rJumpId: null, wJumpId: null, word: "school", url: "",
},
{
id: 15, rJumpId: null, wJumpId: null, word: "skunk", url: "",
id: 16, rJumpId: null, wJumpId: null, word: "skunk", url: "",
},
{
id: 16, rJumpId: null, wJumpId: null, word: "splash", url: "",
id: 17, rJumpId: null, wJumpId: null, word: "splash", url: "",
},
{
id: 17, rJumpId: null, wJumpId: null, word: "splint", url: "",
id: 18, rJumpId: null, wJumpId: null, word: "splint", url: "",
},
{
id: 18, rJumpId: null, wJumpId: null, word: "spray", url: "",
id: 19, rJumpId: null, wJumpId: null, word: "spray", url: "",
},
{
id: 19, rJumpId: null, wJumpId: null, word: "spring", url: "",
id: 20, rJumpId: null, wJumpId: null, word: "spring", url: "",
},
{
id: 20, rJumpId: null, wJumpId: null, word: "square", url: "",
id: 21, rJumpId: null, wJumpId: null, word: "square", url: "",
},
{
id: 21, rJumpId: null, wJumpId: null, word: "squid", url: "",
id: 22, rJumpId: null, wJumpId: null, word: "squid", url: "",
},
{
id: 22, rJumpId: null, wJumpId: null, word: "string", url: "",
id: 23, rJumpId: null, wJumpId: null, word: "string", url: "",
},
{
id: 23, rJumpId: null, wJumpId: null, word: "strong", url: "",
id: 24, rJumpId: null, wJumpId: null, word: "strong", url: "",
},
]
this._cardList = cc.find("Canvas/road/root/wordCards").children;
......@@ -218,6 +226,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
let data = list[i];
let com = this._cardList[i].addComponent(BoardCardItem);
com.cardData = data;
this._randomList.push(i);
}
}
......@@ -266,9 +275,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
const endRoot = cc.find("Canvas/endRoot")
endRoot.scale = this._mapScaleMax;
// const bg1 = cc.find("Canvas/bg1")
// bg1.width = cc.winSize.width;
// bg1.height = cc.winSize.height;
this._redDot = cc.find("Canvas/redDot");
this._redDot.active = false;
this._blueDot = cc.find("Canvas/blueDot");
this._blueDot.active = false;
this._coinNode = cc.find("Canvas/road/board/coinRoot");
this._coinNode.getChildByName("coinA").active = true;
this._coinNode.getChildByName("coinB").active = false;
const blueHead = cc.find("Canvas/road/blueHead");
const redHead = cc.find("Canvas/road/redHead");
this._redLb = redHead.getChildByName("lb").getComponent(cc.Label)
this._blueLb = blueHead.getChildByName("lb").getComponent(cc.Label)
this._springNode = cc.find("Canvas/road/board/btn");
this.cat.getComponent(dragonBones.ArmatureDisplay).addEventListener(dragonBones.EventObject.COMPLETE, () => {
......@@ -325,8 +348,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
switch (state) {
case -1:
break;
case 0:
if (this.isMySide) {
......@@ -342,7 +363,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
}
// this.rollPiece();
this._redLb.string = `${this._status.Red}/10`;
this._blueLb.string = `${this._status.Blue}/10`;
let costTime = this._status.current == "Red" ? this._status.RedTime : this._status.BlueTime;
this._leftTime = 150 - (+costTime)
break;
case 1:
if (this.isMySide) {
......@@ -350,7 +376,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else {
this.greyDice();
}
this.stopRollPiece();
break;
case 2:
if (this.isMySide) {
......@@ -358,6 +384,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else {
this.greyDice();
}
this._leftTime = -1;
break;
}
......@@ -395,29 +422,39 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
blinkTheDice() {
cc.find("Canvas/road/board").children.forEach((node) => {
cc.tween(node)
.set({ scale: 1 })
.to(0.2, { scale: 1.1 })
.to(0.2, { scale: 1.0 })
.union()
.repeatForever()
.start();
});
let finger = cc.find("Canvas/road/board/finger")
finger.zIndex = 10;
finger.active = true;
cc.tween(finger)
.set({ scale: 3 })
.to(0.2, { scale: 3.3 })
.to(0.2, { scale: 3.0 })
.union()
.repeatForever()
.start();
}
normaltheDice() {
cc.find("Canvas/road/board").children.forEach((node) => {
node.stopAllActions();
node.color = cc.color(250, 250, 250);
});
let finger = cc.find("Canvas/road/board/finger")
finger.active = false;
// cc.find("Canvas/road/board").children.forEach((node) => {
// node.stopAllActions();
// node.color = cc.color(250, 250, 250);
// });
}
greyDice() {
cc.find("Canvas/road/board").children.forEach((node) => {
node.color = cc.color(150, 150, 150);
});
let finger = cc.find("Canvas/road/board/finger")
finger.active = false;
// cc.find("Canvas/road/board").children.forEach((node) => {
// node.color = cc.color(150, 150, 150);
// });
}
......@@ -438,37 +475,33 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
stopRollPiece() {
let node = this.getCurrentPiece()
node.stopAllActions();
}
backCoin(right = false) {
rollPiece() {
let node = this.getCurrentPiece()
node.stopAllActions();
cc.tween(node)
.set({ scale: 1, angle: 0 })
.to(0.1, { angle: -10 })
.to(0.2, { angle: 10 })
.to(0.1, { angle: 0 })
.delay(1)
.union()
.repeatForever()
.start();
this.playLocalAudio("grow");
this._cardList.forEach((child: cc.Node, idx, list) => {
cc.tween(child)
.set({ scale: 1 })
.delay(idx * 0.1)
.to(0.1, { scale: 1.1 })
.to(0.1, { scale: 1 })
.delay(list.length * 0.11 - idx * 0.11)
.start();
});
let board = cc.find("Canvas/road/board")
this._coinNode.parent = board;
this._coinNode.position = cc.v3(-67, 139);
this._coinNode.getChildByName("coinA").active = true;
this._coinNode.getChildByName("coinB").active = false;
if (right) {
let point = this._cardList[this._lastIndex].getChildByName("p");
let dot = this._redDot;
if (this._status.current == "Blue") {
dot = this._blueDot;
}
let dotNode = cc.instantiate(dot);
dotNode.active = true;
dotNode.parent = point;
dotNode.position = cc.Vec3.ZERO;
}
}
jumpBlock(idx) {
const targetNode = this._cardList[idx];
......@@ -481,14 +514,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
async peaceJumpAndSpeak() {
let node = cc.find(`Canvas/road/root/piece${this._status.current}`);
let nowIdx = this._status[this._status.current];
let nextIdx = nowIdx + this._status.step;
// let node = cc.find(`Canvas/road/root/piece${this._status.current}`);
// let nowIdx = this._status[this._status.current];
// let nextIdx = nowIdx + this._status.step;
this.playLocalAudio("piece");
let word = await this.pieceMove(node, nowIdx, nextIdx);
let word = await this.pieceMove();
if (this.isMySide) {
let card = this._cardList[nextIdx];
let card = this._cardList[this._status.step];
await asyncDelay(0.5);
this.openCoursView(card, word);
......@@ -501,10 +534,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
let nowIdx = this._status[this._status.current];
let nextIdx = nowIdx + this._status.step;
this.playLocalAudio("piece");
await this.pieceMove(node, nowIdx, nextIdx);
await this.pieceMove();
//todo
this.playLocalAudio("wrong");
await this.pieceGoBack(node, node["nowIndex"], nowIdx);
await this.pieceGoBack();
}
......@@ -551,7 +584,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
probar.getComponent(cc.ProgressBar).unscheduleAllCallbacks();
this._coursewareStoped();
}
}, 0.1, 61, 0.1)
}, 0.1, 31, 0.1)
}
async _startCourseware(word) {
......@@ -708,24 +741,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
async fixStep() {
if (this._status.jump) {
this.log("===fix====jump====");
let node = cc.find(`Canvas/road/root/piece${this._status.current}`);
let nowStep = this._status[this._status.current]
let offset = this._status.current == "Red" ? -25 : 25;
let pos = this._cardList[nowStep].position;
await asyncTweenTo(
node,
0.7,
{ x: pos.x + offset, y: pos.y },
{ easing: "cubicOut" }
);
await asyncDelay(0.2);
node.stopAllActions();
}
}
......@@ -819,7 +835,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else {
this.greyDice();
}
let rollNum = this._status.step - 1 + 6 + (Math.random() > 0.5 ? 0 : 6);
let rollNum = this._status.step
this._lastIndex = rollNum;
await this.rollTheDice(rollNum);
this.log("rollTheDice done");
......@@ -828,30 +846,26 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.log("peaceJumpAndSpeak done");
this.roundEndCheck();
}
else if (item.data.type == "SERVER_playerRight") {
this._leftTime = -1;
!this.isMySide && this.playLocalAudio("right");
this._status = JSON.parse(JSON.stringify(item.data.status));
await this.fixStep();
this.backCoin(true)
await asyncDelay(2);
this.roundEndCheck(true);
} else if (item.data.type == "SERVER_playerWrong") {
this._leftTime = -1;
!this.isMySide && this.playLocalAudio("wrong");
this._status = JSON.parse(JSON.stringify(item.data.status));
if (this._status.jump) {
await this.fixStep();
} else {
let node = cc.find(`Canvas/road/root/piece${this._status.current}`);
let nowIdx = this._status[this._status.current];
await this.pieceGoBack(node, node["nowIndex"], nowIdx);
}
this.backCoin()
await asyncDelay(2);
this.roundEndCheck();
} else if (item.data.type == "SERVER_playerWin") {
this._leftTime = -1;
this._status = JSON.parse(JSON.stringify(item.data.status));
const node = cc.find(
`Canvas/road/root/piece${this._status.current}`
......@@ -870,14 +884,31 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
pieceGoBack(a, v, c) {
update(dt) {
if (this._leftTime > 0) {
this._leftTime -= dt;
this.clockNode.getChildByName("lb").getComponent(cc.Label).string = "" + Math.round(this._leftTime);
this.clockNode.getChildByName("lb").color = this._status.current == "Red" ? cc.Color.RED : cc.Color.BLUE;
}
}
pieceMove(a, b, c) { }
pieceGoBack() {
this.backCoin();
}
pieceMove() { }
async toEnd() {
this._redLb.string = `${this._status.Red}/10`;
this._blueLb.string = `${this._status.Blue}/10`;
let node = cc.find(`Canvas/road/root/piece${this._status.current}`);
// let pos = this._bluePointRoot.getChildByName("19").position;
......@@ -936,29 +967,27 @@ export default class SceneComponent extends MyCocosSceneComponent {
// onHomeworkFinish();
}
rollTheDice(num) {
async rollTheDice(num) {
if (this._isRolling) {
return;
}
const dice = cc.find("Canvas/road/board/runBoard");
return new Promise((resolve, reject) => {
const targetAngle = Math.ceil(dice.angle / 360 + 1) * 360;
const time = (targetAngle - 360 - dice.angle) / 360;
this._isRolling = true;
cc.tween(dice)
.by(1.5, { angle: 360 }, { easing: "cubicIn" })
.to(time / 2, { angle: targetAngle })
.by(0.5, { angle: 360 })
.by(0.5, { angle: 360 })
.by((1 / 12) * num, { angle: 60 * num })
.by(1.5, { angle: 360 }, { easing: "cubicOut" })
.call(() => {
this._isRolling = false;
resolve(null);
})
.start();
});
this._springNode.getComponent(cc.Animation).play();
cc.tween(this._coinNode).by(0.14, { y: -10 }).start();
await asyncDelay(0.14);
this._coinNode.getChildByName("coinA").active = false;
this._coinNode.getChildByName("coinB").active = true;
cc.tween(this._coinNode).by(0.5, { y: 400 }).start();
await asyncDelay(0.5);
this._coinNode.parent = this._cardList[num].parent;
this._coinNode.position = cc.v3(this._cardList[num].x, this._cardList[num].y + 1000, 0)
cc.tween(this._coinNode).by(0.5, { y: -1000 }, { easing: cc.easeBounceIn.name }).start();
await asyncDelay(0.5);
return Promise.resolve();
}
playLocalAudio(audioName) {
......
......@@ -29,14 +29,11 @@ export class GameServer {
"http://staging-teach.cdn.ireadabc.com/f40ce4a8630039c4cf48a63fc1399c52.png",
];
jumpList = [
// { from: 2, rto: 11 ,wto:1},
];
forceWrongIndexList = [];
private _totalStep: any;
randomList = [];
private _useAI: boolean;
private _timer: number;
private _totalTime: number = 150;
constructor(playerMaxNumber, networkHelper) {
this.playerMaxNumber = playerMaxNumber;
......@@ -80,14 +77,20 @@ export class GameServer {
gameStatus = {
state: 0,// -1:未开始 0 准备阶段 1 roll 2 判定
Red: -1,
Blue: -1,
Red: 0,
Blue: 0,
RedTime: 0,
BlueTime: 0,
step: 0,
current: "Red",
jump: false,
back: false,
time: "0"
};
startGame() {
this.openTimerCounter();
console.log("startGame set time ------");
this.networkHelper.sendFrame({
type: "SERVER_updateStatus",
status: this.gameStatus,
......@@ -154,57 +157,46 @@ export class GameServer {
}
if (sender.color == this.gameStatus.current) {
let nowStep = this.gameStatus[this.gameStatus.current];
let index = Math.floor(Math.random() * this.randomList.length)
let step = this.randomList[index];
// if (nowStep < 5) {
// step = 3;
// } else {
// step = 1;
// }
// step = 3
step = Math.min(step, this._totalStep - 1 - nowStep);
console.log("random step ===" + step);
this.gameStatus.step = step;
let i = Math.floor(Math.random() * this.randomList.length)
let index = this.randomList[i];
console.log("random index ===" + index);
this.gameStatus.step = index;
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 {
console.warn("data uuid not match");
}
}
else if (data.type == "right") {
let nowStep: number = this.gameStatus[this.gameStatus.current];
console.log("nowStep === " + nowStep);
const jump = this.jumpList.find(jump => parseInt(jump.from) == nowStep + this.gameStatus.step);
this.gameStatus[this.gameStatus.current] = jump?.rto ? parseInt(jump.rto) : nowStep + this.gameStatus.step;
if (jump) {
console.log("jump=============");
console.log(jump);
let posIndex = this.gameStatus.step
this.gameStatus[this.gameStatus.current]++;
let lastTime = +this.gameStatus.time;
console.log("lasttime = " + lastTime);
let costTime = (Math.floor(Date.now() / 1000) - lastTime).toFixed(1)
console.log("=right===cost time = " + costTime);
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.state = 2;
this.gameStatus.jump = !!jump?.rto;
this.networkHelper.sendFrame({
type: "SERVER_playerRight",
status: this.gameStatus,
......@@ -213,7 +205,6 @@ export class GameServer {
} else {
this.gameStatus.state = 2;
this.gameStatus.step = null;
this.gameStatus.jump = !!jump;
this.networkHelper.sendFrame({
type: "SERVER_playerWin",
status: this.gameStatus,
......@@ -222,15 +213,19 @@ export class GameServer {
}
} else if (data.type == "wrong") {
console.log("data = " + JSON.stringify(data));
let nowStep: number = this.gameStatus[this.gameStatus.current];
console.log("nowStep === " + nowStep);
const jump = this.jumpList.find(jump => parseInt(jump.from) == nowStep + this.gameStatus.step);
this.gameStatus[this.gameStatus.current] = jump?.wto ? parseInt(jump.wto) : nowStep;
let lastTime = +this.gameStatus.time;
let costTime = (Math.floor(Date.now() / 1000) - lastTime).toFixed(1)
console.log("=wrong and ===cost time = " + costTime);
if (this.gameStatus.current == "Red") {
this.gameStatus.RedTime += +costTime
} else {
this.gameStatus.BlueTime += +costTime
}
this.gameStatus.step = null;
this.gameStatus.state = 2;
this.gameStatus.jump = !!jump?.wto;
this.networkHelper.sendFrame({
type: "SERVER_playerWrong",
status: this.gameStatus,
......@@ -241,15 +236,19 @@ export class GameServer {
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;
}
if (this.gameStatus.state == 0) {
this.openTimerCounter();
}
this.networkHelper.sendFrame({
type: "SERVER_updateStatus",
status: this.gameStatus,
});
this.gameStatus.jump = null;
this.gameStatus.back = null;
}
}
......@@ -264,6 +263,50 @@ export class GameServer {
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() {
......
{
"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