Exemplo n.º 1
0
    public void _Init()
    {
        if (Lock_4 == null)
        {
            Lock_4  = Lock_4_obj.GetComponent <ButtonScale>();
            Lock_8  = Lock_8_obj.GetComponent <ButtonScale>();
            Lock_12 = Lock_12_obj.GetComponent <ButtonScale>();
        }
        LevelViewbs levelView = null;
        GameObject  name      = null;
        string      levelName = "";

        for (int idx = 0; idx < BattleMgr.Instance.Genlevel.Count; idx++)
        {
            if (idx > 0)
            {
                return;
            }
            switch (idx)
            {
            case 0:
                name = commonBack_obj;
                break;

            case 1:
                name = eliteBack_obj;
                break;

            case 2:
                name = epicBack_obj;
                break;
            }
            ChapterDic.Add(new List <GameObject>());
            for (int idx1 = 0; idx1 < BattleMgr.Instance.Genlevel[idx].Count; idx1++)
            {
                string chapter = string.Format("level_{0}", ((idx + 1) * 100 + (idx1 + 1)));
                ChapterDic[idx].Add(name.transform.Find(chapter).gameObject);
                for (int idx2 = 0; idx2 < BattleMgr.Instance.Genlevel[idx][idx1].GenStage.Count; idx2++)
                {
                    levelName = string.Format("stage_{0}", BattleMgr.Instance.Genlevel[idx][idx1].GenStage[idx2].LevelID);
                    string level = String.Concat(name.name, "/", chapter, "/level/", levelName);
                    levelView        = commonBack_obj.transform.parent.transform.Find(level).GetComponent <LevelViewbs>();
                    levelView.isZeki = BattleMgr.Instance.Genlevel[idx][idx1].GenStage[idx2].isZeki;
                    levelView.Init();
                    Genlevel.Add(BattleMgr.Instance.Genlevel[idx][idx1].GenStage[idx2].LevelID, levelView);
                    if (BattleMgr.Instance.Genlevel[idx][idx1].GenStage[idx2].StarCount != 0 || (idx == 0 && idx1 == 0 && idx2 == 0))
                    {
                        Genlevel[BattleMgr.Instance.Genlevel[idx][idx1].GenStage[idx2].LevelID].CloseBtn.enabled = true;
                        if (idx2 + 1 < BattleMgr.Instance.Genlevel[idx][idx1].GenStage.Count)
                        {
                            switch (idx)
                            {
                            case 0:
                                if (BattleMgr.Instance.NowLevelId >= 10301)
                                {
                                    break;
                                }
                                BattleMgr.Instance.NowLevelId = BattleMgr.Instance.Genlevel[idx][idx1].GenStage[idx2 + 1].LevelID;
                                elite_tog.interactable        = true;
                                break;

                            case 1:
                                BattleMgr.Instance.EliteLevelId = BattleMgr.Instance.Genlevel[idx][idx1].GenStage[idx2 + 1].LevelID;
                                epic_tog.interactable           = true;
                                break;

                            case 2:
                                BattleMgr.Instance.EpicLevelId = BattleMgr.Instance.Genlevel[idx][idx1].GenStage[idx2 + 1].LevelID;
                                break;
                            }
                        }
                        else
                        {
                            if (idx1 + 1 >= BattleMgr.Instance.Genlevel[idx].Count)
                            {
                                break;
                            }
                            ;
                            if (BattleMgr.Instance.Genlevel[idx][idx1 + 1].GenStage.Count == 0)
                            {
                                break;
                            }
                            switch (idx)
                            {
                            case 0:
                                for (int i = 0; i < BattleMgr.Instance.Genlevel[idx][idx1 + 1].GenStage.Count; i++)
                                {
                                    BattleMgr.Instance.NowLevelId = BattleMgr.Instance.Genlevel[idx][idx1 + 1].GenStage[0].LevelID;
                                    if (BattleMgr.Instance.Genlevel[idx][idx1 + 1].GenStage[i].StarCount != 0)
                                    {
                                        BattleMgr.Instance.NowLevelId = BattleMgr.Instance.Genlevel[idx][idx1 + 1].GenStage[i].LevelID;
                                    }
                                }
                                break;

                            case 1:
                                BattleMgr.Instance.EliteLevelId = BattleMgr.Instance.Genlevel[idx][idx1 + 1].GenStage[0].LevelID;
                                break;

                            case 2:
                                BattleMgr.Instance.EpicLevelId = BattleMgr.Instance.Genlevel[idx][idx1 + 1].GenStage[0].LevelID;
                                break;
                            }
                        }

                        ChapterDic[idx][idx1].SetActive(true);
                        // battleName = ChapterDic[idx][idx1].transform.Find("battleName").gameObject;
                    }
                    else
                    {
                        Genlevel[BattleMgr.Instance.Genlevel[idx][idx1].GenStage[idx2].LevelID].CloseBtn.enabled = false;
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 更新奖励星条
    /// </summary>
    /// <param name="_type">类型</param>
    /// <param name="_section">章节</param>
    public void InitStar(int _type, int _section)
    {
        if (BattleMgr.Instance.Genlevel[_type][_section].StarCount > 12)
        {
            BattleMgr.Instance.Genlevel[_type][_section].StarCount = 12;
        }

        double sum   = (double)(1.0 / 12);
        double count = BattleMgr.Instance.Genlevel[_type][_section].StarCount * sum;

        if (Slider_slider.value <= 1)
        {
            Slider_slider.value = (float)count;
        }

        if (BattleMgr.Instance.Genlevel[_type][_section].StarCount == 0)
        {
            Slider_slider.value = 0;
            Lock_4_obj.SetActive(true);
            Clear_4_btn.gameObject.SetActive(false);
            Open_4_obj.gameObject.SetActive(false);
            Lock_8_obj.gameObject.SetActive(true);
            Clear_8_btn.gameObject.SetActive(false);
            Open_8_obj.gameObject.SetActive(false);
            Lock_12_obj.gameObject.SetActive(true);
            Clear_12_btn.gameObject.SetActive(false);
            Open_12_obj.gameObject.SetActive(false);
        }
        BattleData data = JsonMgr.GetSingleton().GetChapter((BattleMgr.Instance.SectionKey + 1) * 100 + (BattleMgr.Instance.SectionChapter + 1));

        Vector2Int[] award  = { new Vector2Int(2000, 1000 + _section), new Vector2Int(2001, 10000 + _section) };
        Vector2Int[] award1 = { new Vector2Int(2001, 1000 + _section), new Vector2Int(2002, 10000 + _section) };
        Vector2Int[] award2 = { new Vector2Int(2003, 1000 + _section), new Vector2Int(2004, 10000 + _section) };


        if (Lock_4.rect == null)
        {
            Lock_4.rect  = Lock_4_obj.transform.parent.GetComponent <RectTransform>();
            Lock_8.rect  = Lock_8_obj.transform.parent.GetComponent <RectTransform>();
            Lock_12.rect = Lock_12_obj.transform.parent.GetComponent <RectTransform>();
        }
        Lock_4.ItemData  = award;
        Lock_4.isShow    = true;
        Lock_8.ItemData  = award1;
        Lock_8.isShow    = true;
        Lock_12.ItemData = award2;
        Lock_12.isShow   = true;
        if (BattleMgr.Instance.Genlevel[_type][_section].StarCount >= 4 && BattleMgr.Instance.Genlevel[_type][_section].isGet_4 == false)
        {
            Lock_4_obj.SetActive(false);
            Clear_4_btn.gameObject.SetActive(true);
        }
        else if (BattleMgr.Instance.Genlevel[_type][_section].isGet_4 != false)
        {
            Clear_4_btn.gameObject.SetActive(false);
            Lock_4_obj.SetActive(false);
            Open_4_obj.SetActive(true);
        }
        else if (BattleMgr.Instance.Genlevel[_type][_section].isGet_4 == false)
        {
            Clear_4_btn.gameObject.SetActive(false);
            Lock_4_obj.SetActive(true);
            Open_4_obj.SetActive(false);
        }

        if (BattleMgr.Instance.Genlevel[_type][_section].StarCount >= 8 && BattleMgr.Instance.Genlevel[_type][_section].isGet_8 == false)
        {
            Lock_8_obj.gameObject.SetActive(false);
            Clear_8_btn.gameObject.SetActive(true);
        }
        else if (BattleMgr.Instance.Genlevel[_type][_section].isGet_8 != false)
        {
            Lock_8_obj.gameObject.SetActive(false);
            Clear_8_btn.gameObject.SetActive(false);
            Open_8_obj.SetActive(true);
        }
        else if (BattleMgr.Instance.Genlevel[_type][_section].isGet_8 == false)
        {
            Clear_8_btn.gameObject.SetActive(false);
            Lock_8_obj.SetActive(true);
            Open_8_obj.SetActive(false);
        }

        if (BattleMgr.Instance.Genlevel[_type][_section].StarCount == 12 && BattleMgr.Instance.Genlevel[_type][_section].isGet_12 == false)
        {
            Lock_12_obj.gameObject.SetActive(false);
            Clear_12_btn.gameObject.SetActive(true);
        }
        else if (BattleMgr.Instance.Genlevel[_type][_section].isGet_12 != false)
        {
            Lock_12_obj.gameObject.SetActive(false);
            Clear_12_btn.gameObject.SetActive(false);
            Open_12_obj.SetActive(true);
        }
        else if (BattleMgr.Instance.Genlevel[_type][_section].isGet_12 == false)
        {
            Clear_12_btn.gameObject.SetActive(false);
            Lock_12_obj.SetActive(true);
            Open_12_obj.SetActive(false);
        }

        Existing_txt.text = BattleMgr.Instance.Genlevel[_type][_section].StarCount.ToString();
    }