Beispiel #1
0
    private void SetToggleState(int day)
    {
        var openDay = _missionModel.GetOpenDay();

        if (openDay >= _togglesTran.childCount)
        {
            openDay = _togglesTran.childCount;
        }

        if (_missionModel.IsPreviewStarActivity())
        {
            for (int i = 0; i < _togglesTran.childCount; i++)
            {
                var toggleTra = _togglesTran.GetChild(i);
                var toggleDay = int.Parse(toggleTra.gameObject.name);
                if (toggleDay <= openDay)                       //开放
                {
                    toggleTra.Find("Mask").gameObject.Hide();
                    if (day == toggleDay)
                    {
                        var isOn = toggleTra.GetChild(0).GetComponent <Toggle>().isOn;
                        if (!isOn)
                        {
                            toggleTra.GetChild(0).GetComponent <Toggle>().isOn = true;
                        }

                        toggleTra.GetChild(0).Find("Star1").gameObject.Show();
                        toggleTra.GetChild(0).Find("Star2").gameObject.Hide();
                        if (day == openDay + 1)
                        {
                            toggleTra.Find("Mask").GetComponent <Empty4Raycast>().enabled = false;
                            toggleTra.Find("Mask").gameObject.Show();
                        }
                    }
                    else
                    {
                        var isOn = toggleTra.GetChild(0).GetComponent <Toggle>().isOn;
                        if (isOn)
                        {
                            toggleTra.GetChild(0).GetComponent <Toggle>().isOn = false;
                        }
                        toggleTra.GetChild(0).Find("Star1").gameObject.Hide();
                        toggleTra.GetChild(0).Find("Star2").gameObject.Show();
                    }
                }
                else if (toggleDay == openDay + 1)                      // 预览
                {
                    toggleTra.Find("Mask").GetComponent <Empty4Raycast>().enabled = false;
                    toggleTra.Find("Mask").gameObject.Show();
                    var isOn = toggleTra.GetChild(0).GetComponent <Toggle>().isOn;
                    if (isOn)
                    {
                        toggleTra.GetChild(0).Find("Star1").gameObject.Show();
                        toggleTra.GetChild(0).Find("Star2").gameObject.Hide();
                    }
                    else
                    {
                        toggleTra.GetChild(0).Find("Star1").gameObject.Hide();
                        toggleTra.GetChild(0).Find("Star2").gameObject.Show();
                    }
                }
                else if (toggleDay > openDay + 1)                   //没开放
                {
                    toggleTra.Find("Mask").gameObject.Show();
                    toggleTra.Find("Red").gameObject.Hide();

                    toggleTra.GetChild(0).GetComponent <Toggle>().interactable = false;
                    toggleTra.GetChild(0).GetComponent <Toggle>().isOn         = false;


                    toggleTra.GetChild(0).Find("Star1").gameObject.Hide();
                    toggleTra.GetChild(0).Find("Star2").gameObject.Show();
                }
            }
        }
        else
        {
            for (int i = 0; i < _togglesTran.childCount; i++)
            {
                var toggleTra = _togglesTran.GetChild(i);
                var toggleDay = int.Parse(toggleTra.gameObject.name);
                if (toggleDay <= openDay)                       //开放
                {
                    toggleTra.Find("Mask").gameObject.Hide();
                    if (day == toggleDay)
                    {
                        var isOn = toggleTra.GetChild(0).GetComponent <Toggle>().isOn;
                        if (!isOn)
                        {
                            toggleTra.GetChild(0).GetComponent <Toggle>().isOn = true;
                        }

                        toggleTra.GetChild(0).Find("Star1").gameObject.Show();
                        toggleTra.GetChild(0).Find("Star2").gameObject.Hide();
                    }
                    else
                    {
                        var isOn = toggleTra.GetChild(0).GetComponent <Toggle>().isOn;
                        if (isOn)
                        {
                            toggleTra.GetChild(0).GetComponent <Toggle>().isOn = false;
                        }
                        toggleTra.GetChild(0).Find("Star1").gameObject.Hide();
                        toggleTra.GetChild(0).Find("Star2").gameObject.Show();
                    }
                }
                else                         //没开放
                {
                    toggleTra.Find("Mask").gameObject.Show();
                    toggleTra.Find("Red").gameObject.Hide();

                    toggleTra.GetChild(0).GetComponent <Toggle>().interactable = false;
                    toggleTra.GetChild(0).GetComponent <Toggle>().isOn         = false;


                    toggleTra.GetChild(0).Find("Star1").gameObject.Hide();
                    toggleTra.GetChild(0).Find("Star2").gameObject.Show();
                }
            }
        }
    }