51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package moonfantasy
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/modules"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
|
|
"go_dreamfactory/lego/core"
|
|
)
|
|
|
|
const (
|
|
game_dreamlandboos = "game_dreamlandboos.json"
|
|
)
|
|
|
|
///背包配置管理组件
|
|
type configureComp struct {
|
|
modules.MCompConfigure
|
|
module *Moonfantasy
|
|
}
|
|
|
|
//组件初始化接口
|
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.ModuleCompBase.Init(service, module, comp, options)
|
|
this.module = module.(*Moonfantasy)
|
|
err = this.LoadConfigure(game_dreamlandboos, cfg.NewGameDreamlandBoos)
|
|
return
|
|
}
|
|
|
|
//获取随机monster
|
|
func (this *configureComp) GetMonster() (result *cfg.GameDreamlandBoosData, err error) {
|
|
var (
|
|
v interface{}
|
|
configure *cfg.GameDreamlandBoos
|
|
waget []int32
|
|
index int32
|
|
)
|
|
if v, err = this.GetConfigure(game_dreamlandboos); err != nil {
|
|
this.module.Errorf("err:%v", err)
|
|
return
|
|
} else {
|
|
configure = v.(*cfg.GameDreamlandBoos)
|
|
waget = make([]int32, len(configure.GetDataList()))
|
|
for i, m := range configure.GetDataList() {
|
|
waget[i] = m.Pro
|
|
}
|
|
index = comm.GetRandW(waget)
|
|
result = configure.GetDataList()[index]
|
|
return
|
|
}
|
|
}
|