Exemple #1
0
    void OnEndBattleHandler(C2G.EndBattle packet, C2G.EndBattleAck ack)
    {
        MapStageDifficulty stage_info = Network.BattleStageInfo;

        _battle_end_param          = new EventParamBattleEnd();
        _battle_end_param.end_type = packet.end_type;
        _battle_end_param.is_boss  = stage_info.MapInfo.MapType == "boss";
        _battle_end_param.maxlevel_reward_mail_idxs = ack.maxlevel_reward_mail_idx;
        if (packet.end_type != pe_EndBattle.Exit)
        {
            Network.PlayerInfo.UseEnergy(stage_info.Energy);

            _battle_end_param.player_levelup = Network.PlayerInfo.UpdateExp(ack.player_exp_add_info);
            _battle_end_param.creatures      = new List <BattleEndCreature>();

            m_TeamData.Creatures.ForEach(c => _battle_end_param.creatures.Add(c.creature.UpdateExp(ack.creature_exp_add_infos.Find(i => i.creature_idx == c.creature.Idx))));
            _battle_end_param.add_goods  = ack.add_goods;
            _battle_end_param.loot_items = ack.loot_items;
            _battle_end_param.loot_runes = ack.loot_runes;

            _battle_end_param.loot_creatures = ack.loot_creatures.Select(c => c.creature_idx).ToList();

            ack.loot_items.ForEach(i => ItemManager.Instance.Add(i));
            ack.loot_runes.ForEach(i => RuneManager.Instance.Add(i));
            ack.add_goods.ForEach(g => Network.PlayerInfo.AddGoods(g));
            Network.Instance.LootCreatures(ack.loot_creatures, ack.loot_creatures_equip);

            //int dead_count = dead_characters.Count;
            _battle_end_param.clear_rate = 3;

            MapClearDataManager.Instance.SetClearRate(stage_info, _battle_end_param.clear_rate);
        }
        GameMain.SetBattleMode(eBattleMode.None);
    }
Exemple #2
0
    void OnEndBattleHandler(C2G.EndBattle packet, C2G.EndBattleAck ack)
    {
        MapStageDifficulty stage_info = Network.BattleStageInfo;

        _battle_end_param          = new EventParamBattleEnd();
        _battle_end_param.end_type = packet.end_type;
        _battle_end_param.is_boss  = stage_info.MapInfo.MapType == "boss";
        if (packet.end_type == pe_EndBattle.Win)
        {
            _battle_end_param.player_levelup = Network.PlayerInfo.UpdateExp(ack.player_exp_add_info);
            _battle_end_param.creatures      = new List <BattleEndCreature>();

            m_TeamData.Creatures.ForEach(c => _battle_end_param.creatures.Add(c.creature.UpdateExp(ack.creature_exp_add_infos.Find(i => i.creature_idx == c.creature.Idx))));
            _battle_end_param.add_goods  = ack.add_goods;
            _battle_end_param.loot_items = ack.loot_items;
            _battle_end_param.loot_runes = ack.loot_runes;

            _battle_end_param.loot_creatures = ack.loot_creatures.Select(c => c.creature_idx).ToList();

            ack.loot_items.ForEach(i => ItemManager.Instance.Add(i));
            ack.loot_runes.ForEach(i => RuneManager.Instance.Add(i));
            ack.add_goods.ForEach(g => Network.PlayerInfo.AddGoods(g));
            Network.Instance.LootCreatures(ack.loot_creatures, ack.loot_creatures_equip);

            int dead_count = dead_characters.Count;
            _battle_end_param.clear_rate = battleEndType == pe_EndBattle.Win ? (short)Math.Max(1, 3 - dead_count) : (short)0;

            if (MapClearDataManager.Instance.SetClearRate(stage_info, _battle_end_param.clear_rate) == true && stage_info.MapInfo.MapType == "main")
            {
                Network.LastOpenContentsStageInfo = stage_info;
                Tutorial.Instance.first_clear     = true;
            }
            else
            {
                Tutorial.Instance.first_clear = false;
            }

            Network.NewStageInfo = null;

            if (ack.set_new_map == true)
            {
                var next_stage_info = MapInfoManager.Instance.GetNextStageInfo(stage_info);
                if (next_stage_info != null)
                {
                    MapClearDataManager.Instance.SetNew(next_stage_info);
                    if (next_stage_info.MapInfo.MapType != "main" || next_stage_info.MapInfo.IDN <= GameConfig.Get <int>("contents_open_main_map"))
                    {
                        Network.NewStageInfo = next_stage_info;
                    }
                }
            }
        }
        else
        {
            _battle_end_param.player_levelup = Network.PlayerInfo.UpdateExp(null);

            short energy       = stage_info.Energy;
            var   energy_event = EventHottimeManager.Instance.GetInfoByID("dungeon_energy_zero");
            if (energy_event != null)
            {
                energy = (short)(energy * energy_event.Percent);
            }
            Network.PlayerInfo.AddEnergy(energy);
        }

        _battle_end_param.maxlevel_reward_mail_idxs = ack.maxlevel_reward_mail_idx;

        m_Hottime.Clear();

        if (packet.end_type == pe_EndBattle.Exit)
        {
            GameMain.SetBattleMode(eBattleMode.None);
        }
    }