接口相关
This commit is contained in:
parent
2fa4600ad1
commit
1f47bcf51d
@ -38,6 +38,7 @@ const (
|
||||
SM_FriendModule core.M_Modules = "friend" //好友模块
|
||||
SM_LogModelModule core.M_Modules = "model" //日志模块
|
||||
SM_EquipmentModule core.M_Modules = "equipment" //装备模块
|
||||
SM_HeroModule core.M_Modules = "hero" //英雄模块
|
||||
)
|
||||
|
||||
//RPC服务接口定义处
|
||||
|
25
modules/hero/api.go
Normal file
25
modules/hero/api.go
Normal file
@ -0,0 +1,25 @@
|
||||
package hero
|
||||
|
||||
import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
)
|
||||
|
||||
type Api_Comp struct {
|
||||
modules.MComp_GateComp
|
||||
service core.IService
|
||||
module *Hero
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.MComp_GateComp.Init(service, module, comp, options)
|
||||
this.module = module.(*Hero)
|
||||
this.service = service
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Api_Comp) Start() (err error) {
|
||||
err = this.MComp_GateComp.Start()
|
||||
return
|
||||
}
|
42
modules/hero/configure_comp.go
Normal file
42
modules/hero/configure_comp.go
Normal file
@ -0,0 +1,42 @@
|
||||
package hero
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/modules"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
)
|
||||
|
||||
const (
|
||||
game_hero = "game_hero.json"
|
||||
)
|
||||
|
||||
///配置管理组件
|
||||
type Configure_Comp struct {
|
||||
modules.MComp_Configure
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *Configure_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.ModuleCompBase.Init(service, module, comp, options)
|
||||
this.LoadConfigure(game_hero, cfg.NewGame_hero)
|
||||
return
|
||||
}
|
||||
|
||||
//获取英雄配置数据
|
||||
func (this *Configure_Comp) GetHeroConfigure() (configure *cfg.Game_hero, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_hero); err != nil {
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.Game_hero); !ok {
|
||||
err = fmt.Errorf("%T no is *cfg.Game_hero", v)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
20
modules/hero/hero_comp.go
Normal file
20
modules/hero/hero_comp.go
Normal file
@ -0,0 +1,20 @@
|
||||
package hero
|
||||
|
||||
import (
|
||||
"go_dreamfactory/modules"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
)
|
||||
|
||||
///英雄配置管理组件
|
||||
type Model_Hero_Comp struct {
|
||||
modules.Model_Comp
|
||||
module *Hero
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *Model_Hero_Comp) 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.(*Hero)
|
||||
return
|
||||
}
|
43
modules/hero/module.go
Normal file
43
modules/hero/module.go
Normal file
@ -0,0 +1,43 @@
|
||||
package hero
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
)
|
||||
|
||||
/*
|
||||
模块名:英雄
|
||||
描述:
|
||||
开发:
|
||||
*/
|
||||
func NewModule() core.IModule {
|
||||
m := new(Hero)
|
||||
return m
|
||||
}
|
||||
|
||||
type Hero struct {
|
||||
modules.ModuleBase
|
||||
api_comp *Api_Comp
|
||||
configure_comp *Configure_Comp
|
||||
model_hero_comp *Model_Hero_Comp
|
||||
}
|
||||
|
||||
//模块名
|
||||
func (this *Hero) GetType() core.M_Modules {
|
||||
return comm.SM_HeroModule
|
||||
}
|
||||
|
||||
//模块初始化接口 注册用户创建角色事件
|
||||
func (this *Hero) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleBase.Init(service, module, options)
|
||||
return
|
||||
}
|
||||
|
||||
//装备组件
|
||||
func (this *Hero) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
||||
this.model_hero_comp = this.RegisterComp(new(Model_Hero_Comp)).(*Model_Hero_Comp)
|
||||
this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
|
||||
}
|
@ -20,61 +20,6 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type PropertyType int32
|
||||
|
||||
const (
|
||||
PropertyType_Hp PropertyType = 0 //血量
|
||||
PropertyType_Atk PropertyType = 1 //攻击
|
||||
PropertyType_Def PropertyType = 2 //防御
|
||||
PropertyType_Speed PropertyType = 3 //速度
|
||||
PropertyType_Crit PropertyType = 4 //暴击
|
||||
)
|
||||
|
||||
// Enum value maps for PropertyType.
|
||||
var (
|
||||
PropertyType_name = map[int32]string{
|
||||
0: "Hp",
|
||||
1: "Atk",
|
||||
2: "Def",
|
||||
3: "Speed",
|
||||
4: "Crit",
|
||||
}
|
||||
PropertyType_value = map[string]int32{
|
||||
"Hp": 0,
|
||||
"Atk": 1,
|
||||
"Def": 2,
|
||||
"Speed": 3,
|
||||
"Crit": 4,
|
||||
}
|
||||
)
|
||||
|
||||
func (x PropertyType) Enum() *PropertyType {
|
||||
p := new(PropertyType)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x PropertyType) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (PropertyType) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_hero_hero_db_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (PropertyType) Type() protoreflect.EnumType {
|
||||
return &file_hero_hero_db_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x PropertyType) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use PropertyType.Descriptor instead.
|
||||
func (PropertyType) EnumDescriptor() ([]byte, []int) {
|
||||
return file_hero_hero_db_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type SkillData struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -398,12 +343,8 @@ var file_hero_hero_db_proto_rawDesc = []byte{
|
||||
0x02, 0x38, 0x01, 0x1a, 0x39, 0x0a, 0x0b, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x45, 0x6e, 0x74,
|
||||
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x3d,
|
||||
0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06,
|
||||
0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12,
|
||||
0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65,
|
||||
0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a,
|
||||
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06,
|
||||
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -418,21 +359,19 @@ func file_hero_hero_db_proto_rawDescGZIP() []byte {
|
||||
return file_hero_hero_db_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_hero_hero_db_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_hero_hero_db_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_hero_hero_db_proto_goTypes = []interface{}{
|
||||
(PropertyType)(0), // 0: PropertyType
|
||||
(*SkillData)(nil), // 1: SkillData
|
||||
(*DB_HeroData)(nil), // 2: DB_HeroData
|
||||
nil, // 3: DB_HeroData.PropertyEntry
|
||||
nil, // 4: DB_HeroData.AddPropertyEntry
|
||||
nil, // 5: DB_HeroData.EnergyEntry
|
||||
(*SkillData)(nil), // 0: SkillData
|
||||
(*DB_HeroData)(nil), // 1: DB_HeroData
|
||||
nil, // 2: DB_HeroData.PropertyEntry
|
||||
nil, // 3: DB_HeroData.AddPropertyEntry
|
||||
nil, // 4: DB_HeroData.EnergyEntry
|
||||
}
|
||||
var file_hero_hero_db_proto_depIdxs = []int32{
|
||||
1, // 0: DB_HeroData.normalSkill:type_name -> SkillData
|
||||
3, // 1: DB_HeroData.property:type_name -> DB_HeroData.PropertyEntry
|
||||
4, // 2: DB_HeroData.addProperty:type_name -> DB_HeroData.AddPropertyEntry
|
||||
5, // 3: DB_HeroData.energy:type_name -> DB_HeroData.EnergyEntry
|
||||
0, // 0: DB_HeroData.normalSkill:type_name -> SkillData
|
||||
2, // 1: DB_HeroData.property:type_name -> DB_HeroData.PropertyEntry
|
||||
3, // 2: DB_HeroData.addProperty:type_name -> DB_HeroData.AddPropertyEntry
|
||||
4, // 3: DB_HeroData.energy:type_name -> DB_HeroData.EnergyEntry
|
||||
4, // [4:4] is the sub-list for method output_type
|
||||
4, // [4:4] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
@ -476,14 +415,13 @@ func file_hero_hero_db_proto_init() {
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_hero_hero_db_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumEnums: 0,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_hero_hero_db_proto_goTypes,
|
||||
DependencyIndexes: file_hero_hero_db_proto_depIdxs,
|
||||
EnumInfos: file_hero_hero_db_proto_enumTypes,
|
||||
MessageInfos: file_hero_hero_db_proto_msgTypes,
|
||||
}.Build()
|
||||
File_hero_hero_db_proto = out.File
|
||||
|
@ -1,13 +1,13 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
|
||||
enum PropertyType{
|
||||
Hp = 0; //血量
|
||||
Atk = 1; //攻击
|
||||
Def = 2; //防御
|
||||
Speed = 3; //速度
|
||||
Crit = 4; //暴击
|
||||
}
|
||||
// enum PropertyType{
|
||||
// Hp = 0; //血量
|
||||
// Atk = 1; //攻击
|
||||
// Def = 2; //防御
|
||||
// Speed = 3; //速度
|
||||
// Crit = 4; //暴击
|
||||
// }
|
||||
|
||||
message SkillData{
|
||||
int32 skillID = 1;
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
@ -24,7 +23,7 @@ func NewGame_hero(_buf []map[string]interface{}) (*Game_hero, error) {
|
||||
dataMap[_v.Id] = _v
|
||||
}
|
||||
}
|
||||
return &Game_hero{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||
return &Game_hero{_dataList: _dataList, _dataMap: dataMap}, nil
|
||||
}
|
||||
|
||||
func (table *Game_hero) GetDataMap() map[string]*Game_heroData {
|
||||
@ -38,5 +37,3 @@ func (table *Game_hero) GetDataList() []*Game_heroData {
|
||||
func (table *Game_hero) Get(key string) *Game_heroData {
|
||||
return table._dataMap[key]
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user