103 lines
2.9 KiB
TypeScript
103 lines
2.9 KiB
TypeScript
import WorldStarMgr from "./WorldStarMgr";
|
|
import WorldMonsterMgr from "./WorldMonsterMgr";
|
|
import GameUtil from "../core/GameUtil";
|
|
import PlayerMgr from "./PlayerMgr";
|
|
import BangMgr from "../bang/BangMgr";
|
|
import PaiHangMgr from "../core/PaiHangMgr";
|
|
import MagicWorldMgr from "./MagicWorldMgr";
|
|
import * as schedule from "node-schedule";
|
|
import PirateMgr from "./PirateMgr";
|
|
import TianTi from "../activity/TianTi";
|
|
|
|
|
|
export default class World {
|
|
private static _shared:World;
|
|
starMgr:WorldStarMgr;
|
|
worldMonsterMgr:WorldMonsterMgr;
|
|
magicWorldMgr:MagicWorldMgr;
|
|
pirateMgr: PirateMgr;
|
|
nTimeCnt:number;
|
|
logTime:any;
|
|
// m_timer:NodeJS.Timeout;
|
|
|
|
static get shared():World{
|
|
if(!this._shared){
|
|
this._shared=new World();
|
|
}
|
|
return this._shared;
|
|
}
|
|
|
|
constructor() {
|
|
this.starMgr = new WorldStarMgr();
|
|
this.worldMonsterMgr = new WorldMonsterMgr();
|
|
this.magicWorldMgr = new MagicWorldMgr();
|
|
this.pirateMgr = new PirateMgr();
|
|
// this.ResetTimer(1000);
|
|
this.nTimeCnt = -1;
|
|
this.logTime = null;
|
|
}
|
|
|
|
launch() {
|
|
let nCurTime = GameUtil.getTime();
|
|
let nDay = Math.floor(nCurTime / 86400);
|
|
let nHour = Math.floor(nCurTime / 3600);
|
|
this.logTime = {
|
|
nCurDay: nDay,
|
|
nCurHour: nHour,
|
|
}
|
|
|
|
schedule.scheduleJob("0 0 5 * * *", () => {
|
|
this.OnNewDay();
|
|
PlayerMgr.shared.clearAllDayCount();
|
|
})
|
|
}
|
|
|
|
OnKillNpc(nAccountID:any, nNpcOnlyID:any, battle: any = null) {
|
|
this.starMgr.CheckWorldStarDead(nNpcOnlyID,battle);
|
|
this.worldMonsterMgr.CheckWorldMonsterDead(nNpcOnlyID,battle);
|
|
this.magicWorldMgr.CheckWorldMagicDead(nNpcOnlyID,battle);
|
|
this.pirateMgr.CheckPirateDead(nNpcOnlyID,battle);
|
|
}
|
|
//
|
|
// 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() {
|
|
PlayerMgr.shared.OnNewDay();
|
|
PaiHangMgr.shared.onNewDay();
|
|
BangMgr.shared.onNewDay();
|
|
TianTi.shared.OnNewDay()
|
|
}
|
|
//
|
|
// OnNewHour() {
|
|
// PlayerMgr.shared.OnNewHour();
|
|
// }
|
|
} |