import { Logic } from "../../../script/common/base/Logic" ; import { LogicType , LogicEvent , LogicEventData } from "../../../script/common/event/LogicEvent" ; import { ResourceData } from "../../../script/framework/base/Defines" ; import { LobbyService } from "../../../script/common/net/LobbyService" ; import { ResourceLoaderError } from "../../../script/framework/assetManager/ResourceLoader" ; import { Manager } from "../../../script/common/manager/Manager" ; import TankBattleGameView from "./view/TankBattleGameView" ; import { TankBettle } from "./data/TankBattleGameData" ; import TankBattleNetController from "./controller/TankBattleNetController" ; description class TankBattleLogic extends Logic { logicType : LogicType = LogicType . GAME ; onLoad ( ) { super . onLoad ( ) ; } protected bindingEvents ( ) { super . bindingEvents ( ) ; this . registerEvent ( LogicEvent . ENTER_GAME , this . onEnterGame ) ; this . registerEvent ( LogicEvent . ENTER_ROOM_LIST , this . onEnterRoomList ) ; } protected get bundle ( ) { return TankBettle . gameData . bundle ; } public onEnterComplete ( data ) { super . onEnterComplete ( data ) ; if ( data . type == this . logicType ) { } else { this . removeNetComponent ( ) ; this . _loader . unLoadResources ( ) ; } } private onEnterRoomList ( data ) { } protected onLoadResourceComplete ( err ) { if ( err == ResourceLoaderError . LOADING ) { return ; } cc . log ( `${ this . bundle }资源加载完成!!!` ) ; super . onLoadResourceComplete ( err ) ; LobbyService . instance . resumeMessageQueue ( ) ; Manager . uiManager . open ( { type : TankBattleGameView , bundle : this . bundle } ) ; } protected getNetControllerType ( ) { return TankBattleNetController ; } private onEnterGame ( data ) { if ( data == this . bundle ) { Manager . gameData = TankBettle . gameData ; Manager . gameData . clear ( ) ; this . onLanguageChange ( ) ; this . addNetComponent ( ) ; LobbyService . instance . pauseMessageQueue ( ) ; this . _loader . loadResources ( ) ; } else { this . removeNetComponent ( ) ; this . _loader . unLoadResources ( ) ; } } protected getLoadResources ( ) { return [ { preloadView : TankBattleGameView , bundle : this . bundle } ] ; } protected onLanguageChange ( ) { super . onLanguageChange ( ) ; TankBettle . gameData . onLanguageChange ( ) ; } } Manager . logicManager . push ( TankBattleLogic ) ;