| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { _decorator, Component, find, Label } from 'cc';
- import { JCMGO } from '../ThirdParty/JCMGO';
- const { ccclass, property } = _decorator;
- @ccclass('GameState')
- export class GameState extends Component {
- /**权威状态 */
- authGameSystemState: GameSystemState;
- /**当前状态 */
- gameSystemState: GameSystemState;
- /**本地存储的模拟服务器帧(用于本地预测) */
- localMoniFrames: JCMGO.Frame[] = [];
- /**上一次上传帧输入到服务器的标志 */
- lastSign: number = 0;
- /**最后一次上传帧输入的时间点 */
- lastUploadTime: number = 0;
- /**我在房间内的索引位置 */
- myPlayerIndex: number = 0;
- /**AI标志数组 */
- aiFlags: boolean[] = [];
- /**房间匹配完成后的玩家信息列表 */
- matchPlayerInfos: MatchPlayerInfo[];
- /**帧同步是否已经开始 */
- isFrameSyncStarted: boolean = false;
- onLoad() {
- let gameSystemState: GameSystemState = {
- time: 0,
- playerStates: [],
- winPlayerIndex: -1,
- readyComplete: false,
- gameOver: false,
- };
- for (let i = 0; i < window.gm.config.maxMembers; i++) {
- let playerState: PlayerState = {
- index: i,
- moveX: 0,
- speedX: 0,
- lastAccTime: 0,
- accCount: 0,
- };
- gameSystemState.playerStates.push(playerState);
- }
- this.authGameSystemState = gameSystemState;
- this.gameSystemState = JCMGO.ObjectUtils.merge({}, this.authGameSystemState) as GameSystemState;
- }
- }
|