Example #1
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();
    }