Exemplo n.º 1
0
    private void SetVisibleTimeControlObject()
    {
        if (transform.name != "TimeControlDropdown")
        {
            return;
        }

        if (currentlyActiveTimeControlObject)
        {
            currentlyActiveTimeControlObject.SetActive(false);
        }

        switch (transform.GetComponent <Dropdown>().value)
        {
        case 0:
            bulletObject.SetActive(true);
            currentlyActiveTimeControlObject = bulletObject;
            break;

        case 1:
            blitzObject.SetActive(true);
            currentlyActiveTimeControlObject = blitzObject;
            break;

        case 2:
            rapidObject.SetActive(true);
            currentlyActiveTimeControlObject = rapidObject;
            break;

        case 3:
            customObject.SetActive(true);
            currentlyActiveTimeControlObject = customObject;
            SetTimeControlData("Custom", 15, 0, true, isDecimal: true, isMinuteSlider: true, sliderString: "1/4");
            ChessMenuManager chessMenu = FindObjectOfType <ChessMenuManager>();
            chessMenu.SetMyGameData(typeOfGame: gameType, gameTime: timeControlInSeconds, increment: timeIncrement, partOfDataToSetOrUpdate: "TimeControl");
            break;
        }
    }
Exemplo n.º 2
0
    public void HandleSliderData(Slider slider)
    {
        Transform sliderParent  = slider.transform.parent;
        int       siblingIndex  = (sliderParent.name == "MinuteSlider") ? sliderParent.GetSiblingIndex() + 1 : sliderParent.GetSiblingIndex() - 1;
        Slider    siblingSlider = sliderParent.parent.GetChild(siblingIndex).GetChild(2).GetComponent <Slider>();

        bool isDecimal = false;

        float  sliderValue              = slider.value;
        string sliderValueString        = sliderValue.ToString();
        float  siblingSliderValue       = siblingSlider.value;
        string siblingSliderValueString = siblingSliderValue.ToString();

        if (sliderParent.name == "MinuteSlider")
        {
            if (sliderValue >= 4 && sliderValue < 16)
            {
                if (sliderValue % 4 != 0)
                {
                    sliderValue = 4 * ((int)sliderValue / 4);
                }

                sliderValueString = (sliderValue / 4 == 2) ? $"{sliderValue / 8}/2" : $"{sliderValue / 4}/4";
                sliderValue       = (sliderValue / 4) * 15.0f;
                isDecimal         = true;
            }
            else if (sliderValue >= 16)
            {
                sliderValue      -= 15;
                sliderValueString = $"{sliderValue}";
            }
        }
        else if (sliderParent.name == "IncrementSlider")
        {
            if (siblingSliderValue >= 4 && siblingSliderValue < 16)
            {
                if (siblingSliderValue % 4 != 0)
                {
                    siblingSliderValue = 4 * ((int)siblingSliderValue / 4);
                }

                siblingSliderValueString = (siblingSliderValue / 4 == 2) ? $"{siblingSliderValue / 8}/2" : $"{siblingSliderValue / 4}/4";
                siblingSliderValue       = (siblingSliderValue / 4) * 15.0f;
                isDecimal = true;
            }
            else if (siblingSliderValue >= 16)
            {
                siblingSliderValue      -= 15;
                siblingSliderValueString = $"{siblingSliderValue}";
            }
        }

        sliderParent.GetChild(1).GetComponent <Text>().text  = sliderValueString;
        sliderParent.GetChild(1).GetComponent <Text>().color = HexToColor32((sliderValue != 0) ? selectedTimeColor : noSelectedTimeColor);

        bool isTimeSelected = (sliderValue == 0 && siblingSliderValue == 0) ? false : true;

        if (sliderParent.name == "MinuteSlider")
        {
            SetTimeControlData("Custom", sliderValue, siblingSliderValue, isTimeSelected, isDecimal, isMinuteSlider: true, sliderString: sliderValueString);
        }
        else if (sliderParent.name == "IncrementSlider")
        {
            SetTimeControlData("Custom", sliderValue, siblingSliderValue, isTimeSelected, isDecimal, isIncrementSlider: true, siblingSliderString: siblingSliderValueString);
        }

        ChessMenuManager chessMenu = FindObjectOfType <ChessMenuManager>();

        chessMenu.SetMyGameData(typeOfGame: gameType, gameTime: timeControlInSeconds, increment: timeIncrement, partOfDataToSetOrUpdate: "TimeControl");
    }
Exemplo n.º 3
0
    public void OnTimeControlButtonClick(Button button)
    {
        string buttonValue = button.transform.GetChild(0).GetComponent <Text>().text;

        switch (buttonValue)
        {
        case "Unlimited time":
            SetTimeControlData("Unlimited", 0, 0);
            break;

        case "30 s":
            SetTimeControlData("Bullet", 30.0f, 0, sliderString: "1/2", isDecimal: true);
            break;

        case "1 min":
            SetTimeControlData("Bullet", 60.0f, 0);
            break;

        case "1 | 1":
            SetTimeControlData("Bullet", 60.0f, 1.0f);
            break;

        case "2 | 1":
            SetTimeControlData("Bullet", 2 * 60.0f, 1.0f);
            break;

        case "3 min":
            SetTimeControlData("Blitz", 3 * 60.0f, 0);
            break;

        case "3 | 2":
            SetTimeControlData("Blitz", 3 * 60.0f, 2.0f);
            break;

        case "5 min":
            SetTimeControlData("Blitz", 5 * 60.0f, 0);
            break;

        case "5 | 5":
            SetTimeControlData("Blitz", 5 * 60.0f, 5.0f);
            break;

        case "10 min":
            SetTimeControlData("Blitz", 10 * 60.0f, 0);
            break;

        case "15 | 10":
            SetTimeControlData("Rapid", 15 * 60.0f, 10.0f);
            break;

        case "20 min":
            SetTimeControlData("Rapid", 20 * 60.0f, 0);
            break;

        case "30 min":
            SetTimeControlData("Rapid", 30 * 60.0f, 0);
            break;

        case "45 | 45":
            SetTimeControlData("Rapid", 45 * 60.0f, 45.0f);
            break;

        case "60 min":
            SetTimeControlData("Rapid", 60 * 60.0f, 0);
            break;
        }

        ChessMenuManager chessMenu = FindObjectOfType <ChessMenuManager>();

        chessMenu.SetMyGameData(typeOfGame: gameType, gameTime: timeControlInSeconds, increment: timeIncrement, partOfDataToSetOrUpdate: "TimeControl");
    }