85 lines
2.2 KiB
TypeScript
85 lines
2.2 KiB
TypeScript
import GameUtil from "../core/GameUtil";
|
|
import BangMgr from "../bang/BangMgr";
|
|
import PaiHangMgr from "../core/PaiHangMgr";
|
|
import DWorldStarMgr from "./DWorldStarMgr";
|
|
import DWorldMonsterMgr from "./DWorldMonsterMgr";
|
|
// 天元盛典
|
|
export default class DWorld {
|
|
private static _shared:DWorld;
|
|
starMgr:DWorldStarMgr;
|
|
worldMonsterMgr:DWorldMonsterMgr;
|
|
nTimeCnt:number;
|
|
logTime:any;
|
|
m_timer:NodeJS.Timeout;
|
|
|
|
static get shared():DWorld{
|
|
if(!this._shared){
|
|
this._shared=new DWorld();
|
|
}
|
|
return this._shared;
|
|
}
|
|
|
|
constructor() {
|
|
this.starMgr = new DWorldStarMgr();
|
|
this.worldMonsterMgr = new DWorldMonsterMgr();
|
|
this.ResetTimer(1000);
|
|
this.nTimeCnt = -1;
|
|
this.logTime = null;
|
|
}
|
|
|
|
init() {
|
|
let nCurTime = GameUtil.getTime();
|
|
let nDay = Math.floor(nCurTime / 86400);
|
|
let nHour = Math.floor(nCurTime / 3600);
|
|
this.logTime = {
|
|
nCurDay: nDay,
|
|
nCurHour: nHour,
|
|
}
|
|
}
|
|
|
|
OnKillNpc(nAccountID:any, nNpcOnlyID:any) {
|
|
// this.starMgr.playerAddStar(nAccountID);
|
|
this.starMgr.CheckWorldStarDead(nNpcOnlyID);
|
|
this.worldMonsterMgr.CheckWorldMonsterDead(nNpcOnlyID);
|
|
}
|
|
|
|
ResetTimer(nValue:any) {
|
|
let pSelf = this;
|
|
clearInterval(this.m_timer);
|
|
this.m_timer = setInterval(function () {
|
|
pSelf.OnTimer();
|
|
}, nValue);
|
|
}
|
|
|
|
OnTimer() { //每秒一次
|
|
this.nTimeCnt += 1;
|
|
if (this.nTimeCnt % 60 == 0) {
|
|
this.CheckTimeChange();
|
|
}
|
|
|
|
// this.starMgr.OnUpdate(this.nTimeCnt);
|
|
}
|
|
|
|
CheckTimeChange() {
|
|
let nCurTime = GameUtil.getTime();
|
|
let nDay = Math.floor(nCurTime / 86400);
|
|
// let nHour = Math.floor(nCurTime / 3600);
|
|
if (this.logTime.nCurDay != nDay) {
|
|
this.OnNewDay();
|
|
this.logTime.nCurDay = nDay;
|
|
}
|
|
// if (this.logTime.nCurHour != nHour) {
|
|
// this.OnNewHour();
|
|
// this.logTime.nCurHour = nHour;
|
|
// }
|
|
}
|
|
|
|
OnNewDay() {
|
|
PaiHangMgr.shared.onNewDay();
|
|
BangMgr.shared.onNewDay();
|
|
}
|
|
|
|
// OnNewHour() {
|
|
// PlayerMgr.shared.OnNewHour();
|
|
// }
|
|
} |