12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import { gameMethod } from "../../common/gameMethod";
- import { UserAdok, UserAdokPram } from "../../common/Xyc";
- import { SevBack } from "../../common/Xys";
- import Config from "../../Config";
- import EventMng from "../../manager/EventMng";
- import { TimeEvent, UserEvent } from "../const/EventConst";
- import { InGame } from "../const/TypeConst";
- import GameDataCenter from "../GameDataCenter";
- import IDataModel from "../../frameWork/model/IDataModel";
- export default class TimeModel extends IDataModel {
- is_open_music: boolean = false;
- is_open_sound: boolean = false;
- defaultHeart: number = 15//心跳包时间,方便修改心跳发送时间
- sevTime: number = 0
- onlineTime: number = 0 // 上线时间
- guideRuoTime: number = 0 // 弱引导时间
- constructor() {
- super('time');
- this.sevTime = 0
- if (Config.upid != null) {
- clearInterval(Config.upid)
- }
- if (Config.upFrame != null) {
- clearInterval(Config.upFrame)
- }
- if (Config.upZhenWen != null) {
- clearInterval(Config.upZhenWen)
- }
- Config.upid = setInterval(() => {
- if (gameMethod.isEmpty(GameDataCenter.sevBack)) return;
- this.sevTime++
- EventMng.emit(TimeEvent.TIME_CD, this.sevTime)
- }, 1000)
- Config.upFrame = setInterval(() => {
- EventMng.emit(TimeEvent.TIME_FRAME_CD, this.sevTime)
- }, 1000 / Config.GAME_FRAME)
- }
- doSevback(result: SevBack): void {
- if (result.time) {
- this.sevTime = result.time
- if (this.onlineTime == 0) {
- this.onlineTime = result.time
- }
- }
- }
- }
|