73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
package entertainment
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
func NewModule() core.IModule {
|
|
m := new(Entertainment)
|
|
return m
|
|
}
|
|
|
|
type Entertainment struct {
|
|
modules.ModuleBase
|
|
service core.IService
|
|
api *apiComp
|
|
configure *configureComp
|
|
model *modelComp
|
|
gameMgr *gameMgrComp
|
|
//room *Room
|
|
}
|
|
|
|
// 模块名
|
|
func (this *Entertainment) GetType() core.M_Modules {
|
|
return comm.ModuleEntertainment
|
|
}
|
|
|
|
// 模块初始化接口 注册用户创建角色事件
|
|
func (this *Entertainment) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
if err = this.ModuleBase.Init(service, module, options); err != nil {
|
|
return
|
|
}
|
|
this.service = service
|
|
return
|
|
}
|
|
|
|
// 装备组件
|
|
func (this *Entertainment) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.model = this.RegisterComp(new(modelComp)).(*modelComp)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
this.gameMgr = this.RegisterComp(new(gameMgrComp)).(*gameMgrComp)
|
|
//this.room = this.RegisterComp(new(Room)).(*Room)
|
|
}
|
|
|
|
func (this *Entertainment) Start() (err error) {
|
|
if err = this.ModuleBase.Start(); err != nil {
|
|
return
|
|
}
|
|
// var s1 comm.IUserSession
|
|
// var s2 comm.IUserSession
|
|
// this.gameMgr.CreateRoom(s1, s2)
|
|
// this.xxl = new(MapData)
|
|
// this.xxl.InitMap()
|
|
// this.xxl.SwapGirde(1, 0)
|
|
// this.xxl.CheckMap()
|
|
// this.xxl.DropGirde()
|
|
return
|
|
}
|
|
|
|
func (this *Entertainment) BroadcastRoomMsg(uids ...string) {
|
|
this.SendMsgToUsers(string(this.GetType()), "message", &pb.EntertainStartGamePush{
|
|
User1: &pb.PlayerData{},
|
|
User2: &pb.PlayerData{},
|
|
Mpadata: &pb.MapData{},
|
|
Power: "",
|
|
Round: 0,
|
|
}, uids...)
|
|
}
|