package combat import ( "go_dreamfactory/comm" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/event" "go_dreamfactory/modules" "go_dreamfactory/pb" ) /* 模块名:关卡编辑器 描述:新手训练营 开发:李伟 */ func NewModule() core.IModule { m := new(Combat) return m } type Combat struct { modules.ModuleBase service base.IRPCXService battle comm.IBattle api_comp *apiComp configure *configureComp modelCombat *modelCombatComp } // 模块名 func (this *Combat) GetType() core.M_Modules { return comm.ModuleCombat } // 模块初始化接口 注册用户创建角色事件 func (this *Combat) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) this.service = service.(base.IRPCXService) return } func (this *Combat) Start() (err error) { err = this.ModuleBase.Start() var module core.IModule if module, err = this.service.GetModule(comm.ModuleBattle); err != nil { return } this.battle = module.(comm.IBattle) event.RegisterGO(comm.EventUserOffline, this.EventUserOffline) return } // 装备组件 func (this *Combat) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp) this.modelCombat = this.RegisterComp(new(modelCombatComp)).(*modelCombatComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } // Event------------------------------------------------------------------------------------------------------------ func (this *Combat) EventUserOffline(uid, sessionid string) { this.modelCombat.delInfo(uid) } func (this *Combat) GetLevelStatus(uid string) (levels map[int32]*pb.DBCombatLevel) { combat := &pb.DBCombatUser{} levels = make(map[int32]*pb.DBCombatLevel) if err := this.modelCombat.Get(uid, combat); err != nil { return } levels = combat.Level return } func (this *Combat) GetLevels(uid string) (levels map[int32]*pb.DBCombatLevel) { return }