Пример #1
0
func NewServer(app Apper, id int32) *Server {
	s := &Server{}
	core = s
	s.AppId = id
	s.WaitGroup = &util.WaitGroupWrapper{}
	s.exitChannel = make(chan struct{})
	s.shutdown = make(chan struct{})
	s.Eventer = NewEvent()
	s.clientList = NewClientList()
	s.apper = app
	s.Emitter = event.NewEventList()
	s.ObjectFactory = NewFactory()
	s.Kernel = NewKernel(s.ObjectFactory)
	s.channel = make(map[string]*Channel, 32)

	s.s2chelper = NewS2CHelper()
	s.c2shelper = &C2SHelper{}
	s.teleport = &TeleportHelper{}
	s.globalHelper = NewGlobalDataHelper()
	RegisterRemote("S2CHelper", s.s2chelper)
	RegisterRemote("Teleport", s.teleport)
	RegisterRemote("GlobalHelper", s.globalHelper)
	RegisterHandler("C2SHelper", s.c2shelper)
	return s
}
Пример #2
0
func NewTowerAOI(w float32, h float32, tw float32, th float32, limit int) *TowerAOI {
	aoi := &TowerAOI{}
	aoi.width = w
	aoi.height = h
	aoi.towerWidth = tw
	aoi.towerHeight = th
	aoi.rangeLimit = limit
	aoi.Emitter = event.NewEventList()
	aoi.Init()
	return aoi
}