接口相关
This commit is contained in:
parent
2fa4600ad1
commit
1f47bcf51d
@ -38,6 +38,7 @@ const (
|
|||||||
SM_FriendModule core.M_Modules = "friend" //好友模块
|
SM_FriendModule core.M_Modules = "friend" //好友模块
|
||||||
SM_LogModelModule core.M_Modules = "model" //日志模块
|
SM_LogModelModule core.M_Modules = "model" //日志模块
|
||||||
SM_EquipmentModule core.M_Modules = "equipment" //装备模块
|
SM_EquipmentModule core.M_Modules = "equipment" //装备模块
|
||||||
|
SM_HeroModule core.M_Modules = "hero" //英雄模块
|
||||||
)
|
)
|
||||||
|
|
||||||
//RPC服务接口定义处
|
//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)
|
_ = 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 {
|
type SkillData struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
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,
|
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,
|
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,
|
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,
|
0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06,
|
||||||
0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06,
|
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -418,21 +359,19 @@ func file_hero_hero_db_proto_rawDescGZIP() []byte {
|
|||||||
return file_hero_hero_db_proto_rawDescData
|
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_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||||
var file_hero_hero_db_proto_goTypes = []interface{}{
|
var file_hero_hero_db_proto_goTypes = []interface{}{
|
||||||
(PropertyType)(0), // 0: PropertyType
|
(*SkillData)(nil), // 0: SkillData
|
||||||
(*SkillData)(nil), // 1: SkillData
|
(*DB_HeroData)(nil), // 1: DB_HeroData
|
||||||
(*DB_HeroData)(nil), // 2: DB_HeroData
|
nil, // 2: DB_HeroData.PropertyEntry
|
||||||
nil, // 3: DB_HeroData.PropertyEntry
|
nil, // 3: DB_HeroData.AddPropertyEntry
|
||||||
nil, // 4: DB_HeroData.AddPropertyEntry
|
nil, // 4: DB_HeroData.EnergyEntry
|
||||||
nil, // 5: DB_HeroData.EnergyEntry
|
|
||||||
}
|
}
|
||||||
var file_hero_hero_db_proto_depIdxs = []int32{
|
var file_hero_hero_db_proto_depIdxs = []int32{
|
||||||
1, // 0: DB_HeroData.normalSkill:type_name -> SkillData
|
0, // 0: DB_HeroData.normalSkill:type_name -> SkillData
|
||||||
3, // 1: DB_HeroData.property:type_name -> DB_HeroData.PropertyEntry
|
2, // 1: DB_HeroData.property:type_name -> DB_HeroData.PropertyEntry
|
||||||
4, // 2: DB_HeroData.addProperty:type_name -> DB_HeroData.AddPropertyEntry
|
3, // 2: DB_HeroData.addProperty:type_name -> DB_HeroData.AddPropertyEntry
|
||||||
5, // 3: DB_HeroData.energy:type_name -> DB_HeroData.EnergyEntry
|
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 output_type
|
||||||
4, // [4:4] is the sub-list for method input_type
|
4, // [4:4] is the sub-list for method input_type
|
||||||
4, // [4:4] is the sub-list for extension type_name
|
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{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_hero_hero_db_proto_rawDesc,
|
RawDescriptor: file_hero_hero_db_proto_rawDesc,
|
||||||
NumEnums: 1,
|
NumEnums: 0,
|
||||||
NumMessages: 5,
|
NumMessages: 5,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
GoTypes: file_hero_hero_db_proto_goTypes,
|
GoTypes: file_hero_hero_db_proto_goTypes,
|
||||||
DependencyIndexes: file_hero_hero_db_proto_depIdxs,
|
DependencyIndexes: file_hero_hero_db_proto_depIdxs,
|
||||||
EnumInfos: file_hero_hero_db_proto_enumTypes,
|
|
||||||
MessageInfos: file_hero_hero_db_proto_msgTypes,
|
MessageInfos: file_hero_hero_db_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_hero_hero_db_proto = out.File
|
File_hero_hero_db_proto = out.File
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
option go_package = ".;pb";
|
option go_package = ".;pb";
|
||||||
|
|
||||||
enum PropertyType{
|
// enum PropertyType{
|
||||||
Hp = 0; //血量
|
// Hp = 0; //血量
|
||||||
Atk = 1; //攻击
|
// Atk = 1; //攻击
|
||||||
Def = 2; //防御
|
// Def = 2; //防御
|
||||||
Speed = 3; //速度
|
// Speed = 3; //速度
|
||||||
Crit = 4; //暴击
|
// Crit = 4; //暴击
|
||||||
}
|
// }
|
||||||
|
|
||||||
message SkillData{
|
message SkillData{
|
||||||
int32 skillID = 1;
|
int32 skillID = 1;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
@ -9,8 +8,8 @@
|
|||||||
package cfg
|
package cfg
|
||||||
|
|
||||||
type Game_hero struct {
|
type Game_hero struct {
|
||||||
_dataMap map[string]*Game_heroData
|
_dataMap map[string]*Game_heroData
|
||||||
_dataList []*Game_heroData
|
_dataList []*Game_heroData
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGame_hero(_buf []map[string]interface{}) (*Game_hero, error) {
|
func NewGame_hero(_buf []map[string]interface{}) (*Game_hero, error) {
|
||||||
@ -24,19 +23,17 @@ func NewGame_hero(_buf []map[string]interface{}) (*Game_hero, error) {
|
|||||||
dataMap[_v.Id] = _v
|
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 {
|
func (table *Game_hero) GetDataMap() map[string]*Game_heroData {
|
||||||
return table._dataMap
|
return table._dataMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (table *Game_hero) GetDataList() []*Game_heroData {
|
func (table *Game_hero) GetDataList() []*Game_heroData {
|
||||||
return table._dataList
|
return table._dataList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (table *Game_hero) Get(key string) *Game_heroData {
|
func (table *Game_hero) Get(key string) *Game_heroData {
|
||||||
return table._dataMap[key]
|
return table._dataMap[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user