Пример #1
0
//请求奖励条件检查
func (this *AchievementStruct) GetConditionCheck(ach *AchievementInfo, player *Player) (int32, []*protocol.RwardProp) {
	//0:ok 1:该任务未完成 2:已经领取 3:未查询到该任务id
	var props []*protocol.RwardProp

	if !ach.Is_complete {
		return 1, props
	}

	if ach.Is_reward {
		return 2, props
	}

	for _, v := range Csv.achievement[ach.Id].Reward {
		var prop Prop
		prop.Prop_id = v.Data_reward.Id
		prop.Count = v.Data_reward.Num
		prop.Prop_uid = GetUid()
		player.Bag_Prop.AddAndNotice(prop, player.conn)

		proto_prop := new(protocol.RwardProp)
		proto_prop.PropUid = &prop.Prop_uid
		proto_prop.Num = &prop.Count

		props = append(props, proto_prop)
	}

	ach.Is_reward = true
	return 0, props
}
Пример #2
0
//挑战boss发放奖励
func (this *GuajiMapStage) C2SChallengeResult(state int32, stage_id int32, player *Player) {
	this.props = nil
	this.equips = nil
	item0 := Json_config.guaji_reward[this.Now_Guaji_id].Item0

	//产生道具跟装备
	for _, v := range item0 {
		var prop Prop
		if v.ItemType == global.Type_prop {
			prop.Prop_id = v.ItemID
			prop.Prop_uid = GetUid()
			prop.Count = v.Num
			this.props = append(this.props, prop)
		}

		var object_equip Equip
		if v.ItemType == global.Type_equip {
			equip := object_equip.Create(v.ItemID, Json_config.guaji_reward[this.Now_Guaji_id].Quality, player)
			this.equips = append(this.equips, *equip)
		}
	}

	//添加到背包
	player.Bag_Equip.Adds(this.equips, player.conn)
	player.Bag_Prop.Adds(this.props, player.conn)

	//过关
	this.Guaji_Map_stage_pass[stage_id] = state
	next_stage_id_int32 := Csv.map_guaji[stage_id].Id_102
	this.Notice2CheckPoint(2, 0, next_stage_id_int32, player.conn)
	this.Guaji_Map_stage_pass[next_stage_id_int32] = 0
	this.ChangeStage(next_stage_id_int32, player.PlayerId)

	//发送消息
	var equips_list []int32
	for _, v := range this.equips {
		equips_list = append(equips_list, v.Equip_uid)
	}

	var props_list []*protocol.RwardProp
	for _, v := range this.props {
		var props_ protocol.RwardProp
		props_.PropUid = &v.Prop_uid
		props_.Num = &v.Count
		props_list = append(props_list, &props_)
	}

	result4C := &protocol.StageBase_C2SChallengeResult{
		PropUids:  props_list,
		EquipUids: equips_list,
	}

	encObj, _ := proto.Marshal(result4C)
	SendPackage(*player.conn, 1107, encObj)
}
Пример #3
0
//在线挂机收益
func (this *GuajiMapStage) OnNotice2CGuaji(player *Player) {

	buff_Player_exp := this.Player_exp
	buff_Player_gold := this.Player_gold
	this.props = nil
	this.equips = nil

	//在线挂机
	var npc_id int32 = 0

	//遍历循环产生对事件
	event := Json_config.guaji_event[this.Now_Guaji_id].Item0
	var percent_list_ []int32
	var percent_list_value []int32
	for _, k := range event {
		percent_list_ = append(percent_list_, k.Per)
		percent_list_value = append(percent_list_value, k.Event_type)
	}
	index := GetRandomIndex(percent_list_)

	switch percent_list_value[index] {
	case 1: //(1 怪物事件 2开宝箱事件 3装备事件)
		item0 := Json_config.guaji_event_monster[this.Now_Guaji_id].Item0
		var percent_list_item0 []int32
		var percent_list_value_item0 []int32
		for _, k := range item0 {
			percent_list_item0 = append(percent_list_item0, k.Percent)
			percent_list_value_item0 = append(percent_list_value_item0, k.MonModelID)
		}
		index := GetRandomIndex(percent_list_item0)
		npc_id = percent_list_value_item0[index]

		buff_exp := RandNum(Json_config.guaji_event_monster[this.Now_Guaji_id].Exp_Min, Json_config.guaji_event_monster[this.Now_Guaji_id].Exp_Max)
		this.Player_exp += buff_exp

	case 2:
		gold, buff_props := this.DealOnlineGoods(this.Now_Guaji_id)
		this.Player_gold += gold
		this.props = append(this.props, buff_props...)
	case 3:
		this.equips = append(this.equips, this.OnlineEquips(this.Now_Guaji_id))

	}

	Log.Info("Player_gold = %d buff_Player_gold = %d this.Player_exp = %d buff_Player_exp = %d npc_id =%d %d", this.Player_gold, buff_Player_gold, this.Player_exp, buff_Player_exp, npc_id, int32(index))

	can_add_gold := this.Player_gold - buff_Player_gold
	can_add_exp := this.Player_exp - buff_Player_exp

	player.AddRoleExp(can_add_gold)
	player.ModifyGold(can_add_gold)

	player.Bag_Equip.Adds(this.equips, player.conn)
	player.Bag_Prop.Adds(this.props, player.conn)

	//发送在线挂机
	var Equip_Uids []int32
	for _, v := range this.equips {
		Equip_Uids = append(Equip_Uids, v.Equip_uid)
	}

	var Prop_Uids []*protocol.RwardProp
	for _, v := range this.props {
		prop_uid := new(protocol.RwardProp)
		prop_uid.PropUid = &v.Prop_uid
		prop_uid.Num = &v.Count
		Prop_Uids = append(Prop_Uids, prop_uid)
	}

	result4C := &protocol.StageBase_OnNotice2CGuaji{
		GuajiType: &index,
		NpcId:     &npc_id,
		Gold:      &can_add_gold,
		Exp:       &can_add_exp,
		EquipUids: Equip_Uids,
		PropUids:  Prop_Uids,
	}

	encObj, _ := proto.Marshal(result4C)
	SendPackage(*player.conn, 1104, encObj)
}