示例#1
0
 public static short GetDailyClearCount(this pd_MapClearData data)
 {
     if (data.daily_index != Network.DailyIndex)
     {
         return(0);
     }
     return(data.daily_clear_count);
 }
示例#2
0
    void Init()
    {
        if (GameMain.Instance != null)
        {
            GameMain.Instance.InitTopFrame();
        }

        m_ToggleNormal.value = false;
        if (m_StageInfo != null)
        {
//             if (m_StageInfo.MapInfo.MapType == "main")
//                 m_DungeonInfo.text = Localization.Format("DungeonInfoDesc", Mathf.CeilToInt(m_StageInfo.Power * 0.7f));
//             else
            m_DungeonInfo.text = Localization.Get("DungeonInfo");

            if (m_StageInfo.MapInfo.MapType == "weekly")
            {
                m_DungeonDesc.text  = m_StageInfo.MapInfo.Description + "\n";
                m_DungeonDesc.text += Localization.Get("WeeklyAvailable");
                foreach (var tag in m_StageInfo.MapInfo.AvailableTags)
                {
                    m_DungeonDesc.text += string.Format("[url={0}]{1}[/url] ", "Tag_" + tag, Localization.Get("Tag_" + tag));
                }
            }
            else
            {
                m_DungeonDesc.text = m_StageInfo.Description;
            }

            m_map_clear_data = MapClearDataManager.Instance.GetData(m_StageInfo);
            int rate = m_map_clear_data != null ? m_map_clear_data.clear_rate : (short)0;
            for (int i = 0; i < 3; ++i)
            {
                m_ClearRating[i].SetSpriteActive(i < rate);
            }

            if (MapInfo.MapType == "boss")
            {
                m_StageRecommend.SetActive(true);
                m_StageMonster.SetActive(false);

                var boss_info = m_StageInfo.Waves[0].Creatures.Find(e => e.CreatureType == eMapCreatureType.Boss);
                m_DungeonName.text = Localization.Format("HeroName", "Lv." + Boss.CalculateLevel(boss_info.Level, m_StageInfo), boss_info.CreatureInfo.Name);

                //set recommend
                //List<MapCreatureInfo> show_recommends = new List<MapCreatureInfo>();

                Array.ForEach(m_RecommendGrid.GetComponentsInChildren(typeof(DungeonHeroRecommend), true), i => DestroyImmediate(i.gameObject));
                foreach (var recommend in m_StageInfo.Recommends)
                {
                    GameObject obj = NGUITools.AddChild(m_RecommendGrid.gameObject, DungeonHeroRecommendPrefab);
                    obj.GetComponent <DungeonHeroRecommend>().Init(recommend);
                }

                m_RecommendGrid.Reposition();
            }
            else
            {
                m_StageRecommend.SetActive(false);
                m_StageMonster.SetActive(true);

                m_DungeonName.text = m_StageInfo.ShowName;

                //set monster
                List <MapCreatureInfo> show_monsters = new List <MapCreatureInfo>();

                for (int i = 0; i < m_StageInfo.Waves.Count; ++i)
                {
                    MapWaveInfo wave = m_StageInfo.Waves[i];
                    //Debug.LogFormat("wave.Creatures.Count : {0}", wave.Creatures.Count);
                    for (int j = 0; j < wave.Creatures.Count; ++j)
                    {
                        var map_creature = wave.Creatures[j];
                        if (map_creature.IsShow == true && show_monsters.Exists(m => m.CreatureType == map_creature.CreatureType && m.Grade == map_creature.Grade && m.Level == map_creature.Level && m.CreatureInfo.ID == map_creature.CreatureInfo.ID) == false)
                        {
                            show_monsters.Add(map_creature);
                        }
                    }
                }

                Array.ForEach(m_MonsterGrid.GetComponentsInChildren(typeof(DungeonMonster), true), i => DestroyImmediate(i.gameObject));
                foreach (var map_creature in show_monsters)
                {
                    GameObject obj = NGUITools.AddChild(m_MonsterGrid.gameObject, DungeonMonsterPrefab);
                    obj.GetComponent <DungeonMonster>().Init(m_StageInfo, map_creature);
                }

                m_MonsterGrid.Reposition();
            }

            if (MapInfo.MapType == "main")
            {
                m_ToggleStage.value = true;
            }
            else
            {
                m_ToggleStage.value = false;

                int try_count = 0;
                if (MapInfo.MapType == "weekly")
                {
                    try_count = MapClearDataManager.Instance.GetMapDailyClearCount(m_StageInfo.MapInfo.IDN);
                }
                else
                {
                    try_count = MapClearDataManager.Instance.GetMapDailyClearCount(m_StageInfo.MapInfo.IDN, PacketEnums.pe_Difficulty.Normal);
                }
                m_LabelStartTraining.text = Localization.Format("LeftTryCount", m_StageInfo.MapInfo.TryLimit - try_count, m_StageInfo.MapInfo.TryLimit);
            }
            m_BattleAvailableCount = CalculateBattleAvailableCount(m_StageInfo);

            var energy_event = EventHottimeManager.Instance.GetInfoByID("dungeon_energy_zero");
            if (energy_event != null)
            {
                m_Energy.text = ((short)(m_StageInfo.Energy * energy_event.Percent)).ToString();
            }
            else
            {
                m_Energy.text = m_StageInfo.Energy.ToString();
            }

            m_EventEnergyZero.SetActive(energy_event != null);
        }

        InitCharacter();

        if (BattleContinue.Instance.CheckFinish() == false)
        {
            if (BattleContinue.Instance.IsRetry == true)
            {
                BattleContinue.Instance.Clear();
                OnStart();
            }
            else if (BattleContinue.Instance.IsPlaying)
            {
                if (CheckConditionBattleStart() == false)
                {
                    return;
                }

                BattleContinue.Instance.IncreaseBattle();
                if (BattleContinue.Instance.IsPlaying == false)
                {
                    BattleContinue.Instance.Finish(eBattleContinueFinish.Count);
                    return;
                }
                else
                {
                    EnterBattle();
                }
            }
        }
        //m_HeroActive.gameObject.SetActive(false);
    }
示例#3
0
    void Init()
    {
        MapInfo map_info = MapInfo;
        List <MapStageDifficulty> stages = map_info.Stages.Select(e => e.Difficulty[(int)CurrentDifficulty]).ToList();

        pd_MapClearData last_stage_info = null;

        if (map_info != m_SelectStageInfo.MapInfo)
        {
            last_stage_info = MapClearDataManager.Instance.GetLastStage(map_info.IDN, CurrentDifficulty);
        }

        bool is_set_character_position = false;

        for (int i = 0; i < stages.Count; ++i)
        {
            MapStageDifficulty stage_info = stages[i];
            DungeonSpot        stage;
            if (m_Spots.Count < i + 1)
            {
                GameObject dungeon = NGUITools.AddChild(DungeonLocation, DungeonSpotPrefab);
                stage = dungeon.GetComponent <DungeonSpot>();
                m_Spots.Add(stage);
            }
            else
            {
                stage = m_Spots[i];
            }

            stage.transform.localPosition = stage_info.MapPos;
            stage.gameObject.name         = stage_info.ID;

            pd_MapClearData clear_data = MapClearDataManager.Instance.GetData(stage_info);
            short           clear_rate = clear_data == null ? (short)0 : clear_data.clear_rate;
            stage.Init(stage_info, clear_rate);

            if (last_stage_info != null && stage_info.StageIndex == last_stage_info.stage_index || stage_info == m_SelectStageInfo || is_set_character_position == false && clear_rate == 0)
            {
                SetCharacterPosition(stage.transform.position);
                is_set_character_position = true;
            }

            stage.OnClickStage = OnClickStage;
        }
        while (m_Spots.Count > stages.Count)
        {
            DungeonSpot spot = m_Spots[m_Spots.Count - 1];
            m_Spots.Remove(spot);
            spot.gameObject.SetActive(false);
            Destroy(spot);
        }
        m_LabelTitle.text = map_info.GetShowName(CurrentDifficulty);
        if (CurrentDifficulty == pe_Difficulty.Hard)
        {
            GameMain.Instance.m_BG.material.SetColor("_GrayColor", GameMain.colorHard);
        }
        else
        {
            GameMain.Instance.m_BG.material.SetColor("_GrayColor", GameMain.colorZero);
        }

        //clear reward
        MapClearRewardInfo reward_info = MapClearRewardInfoManager.Instance.GetInfoByIdn(map_info.IDN);

        if (reward_info.conditions(CurrentDifficulty).Count > 0)
        {
            m_ClearReward.SetActive(true);
            int total_clear = MapClearDataManager.Instance.GetTotalClearRate(map_info.IDN, CurrentDifficulty);
            m_RewardProgress.value = (float)total_clear / reward_info.Total;
            m_LabelClearTotal.text = total_clear.ToString();

            pd_MapClearReward rewarded_info = MapClearRewardManager.Instance.GetRewardedData(m_SelectedMapInfo.IDN, CurrentDifficulty);

            for (int i = 0; i < reward_info.conditions(CurrentDifficulty).Count; ++i)
            {
                m_LabelCondition[i].text = reward_info.conditions(CurrentDifficulty)[i].condition.ToString();

                if (rewarded_info == null || rewarded_info.GetAt(i) == false)
                {
                    m_Boxes[i].GetComponentInChildren <UIToggleSprite>().SetSpriteActive(false);
                    m_Boxes[i].GetComponent <BoxCollider2D>().enabled = true;
                    m_BoxEffects[i].SetActive(GetClearRewardAvailable(i));
                }
                else
                {                //rewarded
                    m_Boxes[i].GetComponentInChildren <UIToggleSprite>().SetSpriteActive(true);
                    m_Boxes[i].GetComponent <BoxCollider2D>().enabled = false;
                    m_BoxEffects[i].SetActive(false);
                }
            }
        }
        else
        {
            m_ClearReward.SetActive(false);
        }


        m_Left.gameObject.SetActive(MapInfo.IDN > 1);
        m_Right.gameObject.SetActive(MapInfoManager.Instance.ContainsIdn(MapInfo.IDN + 1) && MapInfo.IDN + 1 <= GameConfig.Get <int>("contents_open_main_map"));

        m_HardModeLock.SetActive(MapInfo.IDN == 1 && MapInfo.CheckCondition(pe_Difficulty.Hard) != null);
    }