From d3fc1d40e9a7b4566242f3af8624a1c6bbcd8119 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Mon, 4 Jul 2022 11:43:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E8=8B=B1=E9=9B=84=E6=8A=80?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/configure_comp.go | 4 ++-- modules/hero/model_hero.go | 33 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index e5f8a2310..686e45aad 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -198,12 +198,12 @@ func (this *configureComp) GetHeroStargrow() (configure *cfg.Game_heroStargrow, } //获取英雄配置 -func (this *configureComp) GetHero(heroId int32) *cfg.Game_newHeroData { +func (this *configureComp) GetHero(heroCfgId int32) *cfg.Game_newHeroData { cfg, err := this.getHeroConfigure() if err != nil { return nil } - if v, ok := cfg.GetDataMap()[heroId]; ok { + if v, ok := cfg.GetDataMap()[heroCfgId]; ok { return v } return nil diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 9a80d1680..400b72482 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -37,12 +37,11 @@ func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DBHero { Id: objId, Uid: uid, HeroID: heroCfg.Hid, - Star: heroCfg.Star, //初始星级 - Lv: 1, //初始等级 - NormalSkill: []*pb.SkillData{}, //初始技能 - IsOverlying: true, //是否允许叠加, - Block: false, //未锁定 - CardType: heroCfg.Type, //卡片类型 + Star: heroCfg.Star, //初始星级 + Lv: 1, //初始等级 + IsOverlying: true, //是否允许叠加, + Block: false, //未锁定 + CardType: heroCfg.Type, //卡片类型 Skins: []int32{}, EquipID: make([]string, 6), //初始装备 SameCount: 1, //默认叠加数量 @@ -50,9 +49,31 @@ func (this *ModelHero) initHero(uid string, heroCfgId int32) *pb.DBHero { Energy: make(map[int32]int32), Property: make(map[string]int32), } + this.initHeroSkill(newHero) return newHero } +//初始化英雄技能 +func (this *ModelHero) initHeroSkill(hero *pb.DBHero) []*pb.SkillData { + heroCfg := this.moduleHero.configure.GetHero(hero.HeroID) + if heroCfg != nil { + skills := []*pb.SkillData{{ + SkillID: heroCfg.Skill1, + SkillLv: 1, + }, { + SkillID: heroCfg.Skill2, + SkillLv: 1, + }, { + SkillID: heroCfg.Skill3, + SkillLv: 1, + }} + hero.NormalSkill = skills + hero.CaptainSkill = heroCfg.Skill + } + + return nil +} + //创建一个指定的英雄 func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (err error) { hero := this.initHero(uid, heroCfgId)