Beispiel #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);
    }
Beispiel #2
0
    public override void SetBattleEnd()
    {
        base.SetBattleEnd();

        C2G.EndBattle _packet = new C2G.EndBattle();
        _packet.battle_type = pe_Battle.Stage;
        _packet.end_type    = pe_EndBattle.Win;
        _packet.difficulty  = Network.BattleStageInfo.Difficulty;
        _packet.map_id      = Network.BattleStageInfo.MapInfo.ID;
        _packet.stage_id    = Network.BattleStageInfo.ID;

        _packet.creatures = new List <PacketInfo.pd_BattleEndCreatureInfo>();

        //List<int> skill_indice = new List<int>();
        for (int i = 0; i < m_TeamData.Creatures.Count; ++i)
        {
            Creature       creature = m_TeamData.Creatures[i].creature;
            BattleCreature bc       = characters.Find(c => c.Idx == creature.Idx) as BattleCreature;
            if (bc == null)
            {
                bc = dead_characters.Find(c => c.Idx == creature.Idx) as BattleCreature;
            }
            _packet.creatures.Add(new PacketInfo.pd_BattleEndCreatureInfo(bc.Idx, bc.IsDead));
            m_TeamData.Creatures[i].auto_skill_index = bc.AutoSkillIndex;
        }
        _packet.team_data = m_TeamData.CreateSaveData();

        Network.GameServer.JsonAsync <C2G.EndBattle, C2G.EndBattleAck>(_packet, OnEndBattleHandler);
    }
Beispiel #3
0
    void SetBattleEndStage()
    {
        C2G.EndBattle _packet = new C2G.EndBattle();
        _packet.battle_type  = pe_Battle.Stage;
        _packet.end_type     = battleEndType;
        _packet.difficulty   = Network.BattleStageInfo.Difficulty;
        _packet.map_id       = Network.BattleStageInfo.MapInfo.ID;
        _packet.stage_id     = Network.BattleStageInfo.ID;
        _packet.creatures    = new List <PacketInfo.pd_BattleEndCreatureInfo>();
        _packet.is_new_clear = MapClearDataManager.Instance.IsNewClear(Network.BattleStageInfo);

        //List<int> skill_indice = new List<int>();
        for (int i = 0; i < m_TeamData.Creatures.Count; ++i)
        {
            Creature       creature = m_TeamData.Creatures[i].creature;
            BattleCreature bc       = characters.Find(c => c.Idx == creature.Idx) as BattleCreature;
            if (bc == null)
            {
                bc = dead_characters.Find(c => c.Idx == creature.Idx) as BattleCreature;
            }
            _packet.creatures.Add(new PacketInfo.pd_BattleEndCreatureInfo(bc.Idx, bc.IsDead));
            m_TeamData.Creatures[i].auto_skill_index = bc.AutoSkillIndex;
        }
        if (m_TeamData.IsEqual(m_TeamDataBackup) == false || Tutorial.Instance.Completed == false)
        {
            _packet.team_data = m_TeamData.CreateSaveData();
        }

        if (Tutorial.Instance.Completed == false)
        {
            C2G.TutorialState tutorial_packet = new C2G.TutorialState();
            tutorial_packet.tutorial_state      = Network.PlayerInfo.tutorial_state;
            tutorial_packet.next_tutorial_state = (short)Tutorial.Instance.CurrentState;
            tutorial_packet.end_battle          = _packet;

            Network.GameServer.JsonAsync <C2G.TutorialState, C2G.TutorialStateAck>(tutorial_packet, OnTutorialEndBattleHandler);
        }
        else
        {
            Network.GameServer.JsonAsync <C2G.EndBattle, C2G.EndBattleAck>(_packet, OnEndBattleHandler);
        }
    }
Beispiel #4
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);
        }
    }