Esempio n. 1
0
//获取英雄通信相关
func (this *Player) GetHeroStruct(Heros map[int32]*HeroStruct) []*protocol.FightingAttr {
	var Game_HeroStruct []*protocol.FightingAttr
	for _, v_buff := range Heros { //遍历对应玩家的所有英雄列表
		v := v_buff
		HeroInfo := new(protocol.FightingAttr)
		HeroInfo.Id = &v.Hero_Info.Hero_id
		HeroInfo.Uid = &v.Hero_Info.Hero_uid
		HeroInfo.Pos = &v.Hero_Info.Pos_stage
		HeroInfo.Level = &v.Hero_Info.Level
		HeroInfo.Exp = &v.Hero_Info.Exp
		HeroInfo.StarLevel = &v.Hero_Info.Star_level
		HeroInfo.StepLevel = &v.Hero_Info.Step_level
		HeroInfo.Skill = v.Hero_Info.Skill

		//额外属性
		var attributes []*protocol.Attribute
		for _, v1 := range v.Hero_Info.Attr {
			for _, v2_buff := range v1 {
				v2 := v2_buff
				attribute := new(protocol.Attribute)
				attribute.Group = &v2.Group
				attribute.Key = &v2.Key
				attribute.Value = &v2.Value
				attributes = append(attributes, attribute)
			}
		}
		HeroInfo.Attribute = attributes

		Game_HeroStruct = append(Game_HeroStruct, HeroInfo)
	}
	return Game_HeroStruct
}
Esempio n. 2
0
//英雄对应属性推送
func (this *HeroStruct) Note2CHeroChange(conn *net.Conn) {
	result4C := new(protocol.NoticeMsg_Notice2CHero)
	result4C.HeroUid = &this.Hero_Info.Hero_uid
	result4C.StepLevel = &this.Hero_Info.Step_level
	result4C.StarLevel = &this.Hero_Info.Star_level
	result4C.Level = &this.Hero_Info.Level
	result4C.Exp = &this.Hero_Info.Exp

	var HeroAttrs []*protocol.Attribute
	for _, v1 := range this.Hero_Info.Attr {
		for _, v2_buff := range v1 {
			v2 := v2_buff
			HeroAttr := new(protocol.Attribute)
			HeroAttr.Group = &v2.Group
			HeroAttr.Key = &v2.Key
			HeroAttr.Value = &v2.Value
			HeroAttrs = append(HeroAttrs, HeroAttr)

			fmt.Println("attr:", v2.Group)
			fmt.Println("attr:", v2.Key)
			fmt.Println("attr:", v2.Value)

		}
	}

	result4C.HeroAttr = HeroAttrs
	encObj, _ := proto.Marshal(result4C)
	SendPackage(*conn, 1209, encObj)
}
Esempio n. 3
0
//装备变化
func (this *BagEquip) DealEquipStructOne(equip Equip) *protocol.EquipStruct {
	equip_info := new(protocol.EquipInfo)
	var Attributes []*protocol.Attribute
	equip_info.Id = &equip.Equip_id
	equip_info.Uid = &equip.Equip_uid
	equip_info.StrengthenCount = &equip.Strengthen_level
	equip_info.Pos = &equip.Pos
	equip_info.Quality = &equip.Quality
	equip_info.RefineCount = &equip.Refine_count
	equip_info.RefineLevel = &equip.Refine_Level
	for _, v1 := range equip.Attrs {
		for _, v2_buff := range v1 {
			v2 := v2_buff
			Attribute := new(protocol.Attribute)
			Attribute.Group = &v2.Group
			Attribute.Key = &v2.Key
			Attribute.Value = &v2.Value
			Attributes = append(Attributes, Attribute)
		}
	}

	equips_struct := new(protocol.EquipStruct)
	equips_struct.Attribute = Attributes
	equips_struct.EquipInfo = equip_info
	return equips_struct
}