Commit 6d988c90 authored by 杨一航's avatar 杨一航

fix

parent 2b543834
{
"ver": "1.1.2",
"uuid": "6bfb05ca-1a0f-4641-a854-718f949fdf19",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
// 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 EndView extends cc.Component {
@property(cc.Node)
winRoot: cc.Node = null;
@property(cc.Node)
loseRoot: cc.Node = null;
@property(cc.Node)
redIcon: cc.Node = null;
@property(cc.Node)
blueIcon: cc.Node = null;
@property(cc.Label)
lb_red: cc.Label = null;
@property(cc.Label)
lb_blue: cc.Label = null;
@property(cc.Node)
replayNode: cc.Node = null;
onLoad() {
this.replayNode.on("click", this.replay, this)
}
showView(win: boolean, redScore, blueScore, redUrl, blueUrl) {
this.winRoot.active = win;
this.loseRoot.active = !win;
this.lb_blue.string = blueScore;
this.lb_red.string = redScore;
cc.loader.load({ url: redUrl }, (err, img) => {
this.redIcon.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(img)
})
cc.loader.load({ url: blueUrl }, (err, img) => {
this.blueIcon.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(img)
})
}
replay() {
cc.game.restart();
}
}
{
"ver": "1.0.8",
"uuid": "b7a11c07-c2ff-4470-a00b-6654f03aedb4",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "84b72720-2013-4f2b-b787-52900432f34f",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -25,6 +25,7 @@ export default class Keyboard extends cc.Component {
_wordList = [];
private _normaly: number;
private _moving: boolean;
private _endCall: any;
onLoad() {
......@@ -61,8 +62,11 @@ export default class Keyboard extends cc.Component {
sendWords() {
console.log(this._wordList.join(""));
this._endCall && this._endCall(this._wordList.join(""));
this.showOut();
}
set InputEndCall(endCall: Function) {
this._endCall = endCall;
}
showIn() {
......
This diff is collapsed.
This diff is collapsed.
import BoardCardItem from "../scene/boardCardItem";
import MsgData from "./msgDate";
import { MsgType } from "./msgType";
import { NetworkHelper } from "./NetworkHelper";
import { asyncDelay } from "./util";
const countDelay = 4; // 距离上次答对 间隔4s 开始答题下一题
export class AI {
networkHelper: NetworkHelper;
playerData: any;
_status = {
state: -1,// -1:未开始 0 准备阶段 1 roll 2 判定
Red: -1,
Blue: 0,
step: 0,
current: "Blue",
jump: null,
};
_startAi: boolean = false;
_answerpro = 0;
private _gameData: MsgData;
private _countDelay: number;
private _stepIndex: any;
constructor(networkHelper: NetworkHelper, playerData: any) {
this.networkHelper = networkHelper;
this.playerData = playerData;
}
async onFrameEvent(data) {
console.log("AI get event: " + JSON.stringify(data));
// console.log("AI get event: " + data);
if (data.type == "SERVER_updateStatus") {
let type: MsgType = data.type;
let msgData = data.data;
this._status = JSON.parse(JSON.stringify(data.status));
if (type == MsgType.ROOM_ST) {
if (this.playerData.color != this._status.current) return
this._gameData = new MsgData(JSON.parse(msgData));
if (!this._status.step) {
await asyncDelay(Math.random() * 3 + 2);
if (!this._startAi) return;
console.log("AI rolling");
this.networkHelper.sendFrame({
type: "roll",
uuid: this.playerData.uuid,
});
} else {
await asyncDelay(Math.random() * 3 + 2);
if (Math.random() < 0.7) {
this.networkHelper.sendFrame({
type: "right",
uuid: this.playerData.uuid,
});
} else {
this.networkHelper.sendFrame({
type: "wrong",
uuid: this.playerData.uuid,
});
if (this._gameData.Round == 1 && this._gameData.BuleSocre < 14) {
cc.log("ai check")
this._countDelay--;
if (this._countDelay <= 0) {
let wordList = this._gameData.LeftList;
let word = wordList[Math.floor(Math.random() * wordList.length * 0.99)]
cc.log("ai answer word" + word)
this._sendMsg({ type: MsgType.USER_REQ_ERQ, data: { word: word, uuid: this.playerData.uuid } })
this._countDelay = Math.floor(10 + Math.random() * 10);;
}
} else if (this._gameData.Round == 2) {
this._countDelay--;
if (this._countDelay <= 0) {
this._sendMsg({ type: MsgType.USER_REQ_ERQ, data: { index: this._stepIndex, uuid: this.playerData.uuid } })
this._countDelay = 10000
}
}
}
else if (type == MsgType.ROUND_START_EV) {
let data = msgData;
if (data.round == 1) {
this._startAi = true;
this._countDelay = Math.floor(10 + Math.random() * 10);
} else {
this._startAi = true;
this._stepIndex = data.index;
this._countDelay = Math.floor(7 + Math.random() * 5);
}
} else if (type == MsgType.ROUND_END_EV) {
let data = msgData;
if (data.round == 1) {
} else {
}
}
}
_sendMsg(data: { type: MsgType, data: any }) {
this.networkHelper.sendFrame({
type: data.type,
data: data.data
});
}
}
This diff is collapsed.
import { MsgType, PlayerData } from "./msgType";
export default class MsgData {
_playerList: Array<PlayerData>;
_redScore: number = 0;
_buleSocre: number = 0;
_time: number = 0;
_round: number = 0;
_answerList: Array<any> = [];
_leftList: Array<any> = [];
constructor(data?: {
playerList,
redScore,
buleSocre,
time,
round,
answerList,
leftList,
}) {
this._playerList = data?.playerList || [];
this._redScore = data?.redScore || 0;
this._buleSocre = data?.buleSocre || 0;
this._time = data?.time || 0;
this._round = data?.round || 0;
this._answerList = data?.answerList || [];
this._leftList = data?.leftList || [];
}
get PlayerList() {
return this._playerList;
}
addPlayer(val: PlayerData) {
this._playerList.push(val);
}
get Time() {
return this._time;
}
set Time(val: number) {
this._time = val;
}
get Round() {
return this._round;
}
set Round(val: number) {
this._round = val;
}
get RedScore() {
return this._redScore;
}
set RedScore(val: number) {
this._redScore = val;
}
get BuleSocre() {
return this._buleSocre;
}
set BuleSocre(val: number) {
this._buleSocre = val;
}
get LeftList() {
return this._leftList;
}
set LeftList(val) {
this._leftList = val;
}
getAnswerList() {
return this._answerList;
}
addAnswerList(val: { word?: string, uuid: string, index?: number }) {
this._answerList.push(val);
}
clearAnswerList() {
this._answerList = [];
}
get Msg() {
let data =
{
playerList: this._playerList,
redScore: this._redScore,
buleSocre: this._buleSocre,
time: this._time,
round: this._round,
answerList: this._answerList,
leftList: this._leftList
}
return JSON.stringify(data);
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "29f56073-02a9-44f4-9a64-6bc431ec4dd9",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "3237dea0-16c8-4b66-b7a1-ae0e9a782ed2",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -11,7 +11,7 @@
"height": 44,
"platformSettings": {},
"subMetas": {
"surse": {
"urse": {
"ver": "1.0.4",
"uuid": "993da591-bc95-464c-9561-4b837ed41c79",
"rawTextureUuid": "9e028138-b982-4688-8918-9613409d5868",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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