Beispiel #1
0
    //Chest rarity input callbacks
    public void UpdateTotalRarity()
    {
        //Get all input values
        float commonRarity    = UI_Conversions.UserInputToFloat(commonRarityInput);
        float uncommonRarity  = UI_Conversions.UserInputToFloat(uncommonRarityInput);
        float rareRarity      = UI_Conversions.UserInputToFloat(rareRarityInput);
        float legendaryRarity = UI_Conversions.UserInputToFloat(legendaryRarityInput);

        //Check values
        if (commonRarity == -1.0f ||
            uncommonRarity == -1.0f ||
            rareRarity == -1.0f ||
            legendaryRarity == -1.0f)
        {
            //Disable the GO button
            goButton.interactable = false;
            //Exit early
            return;
        }

        //There are values in all inputs, update the total value
        float totalValue = commonRarity + uncommonRarity + rareRarity + legendaryRarity;

        totalRarityInput.text = totalValue.ToString();

        if (totalValue != 100.0f && totalValue != 1.0f)
        {
            goButton.interactable = false;
        }
        else
        {
            goButton.interactable = true;
            if (totalValue == 100.0f)
            {
                commonRarity    /= 100.0f;
                uncommonRarity  /= 100.0f;
                rareRarity      /= 100.0f;
                legendaryRarity /= 100.0f;
            }

            rarities[0] = commonRarity;
            rarities[1] = uncommonRarity;
            rarities[2] = rareRarity;
            rarities[3] = legendaryRarity;
        }
    }
    public void ChiSquareRandom()
    {
        wg = windowGraph.GetComponent <Window_Graph>();
        if (wg == null)
        {
            Debug.Log("wg is null");
            return;
        }

        Clear(wg);

        int   numToGen = UI_Conversions.UserInputToInt(numberToGenerate);
        float minRange = UI_Conversions.UserInputToFloat(rangeMinimum);
        float maxRange = UI_Conversions.UserInputToFloat(rangeMaximum);

        if (numToGen == -1 || minRange == -1 || maxRange == -1)
        {
            return;
        }

        List <float> chiSquareRandomNumbers = new List <float>();

        Randomness.Instance.UnityRandom(numToGen, 0.0f, 1.0f, ref chiSquareRandomNumbers);

        //Square the values
        for (int i = 0; i < chiSquareRandomNumbers.Count; i++)
        {
            chiSquareRandomNumbers[i] *= chiSquareRandomNumbers[i];
            //Values are still between 0.0f and 1.0f, need to scale them to min and max values
            chiSquareRandomNumbers[i] = minRange + (chiSquareRandomNumbers[i] * ((maxRange - minRange)));
        }

        if (roundingToggle.isOn)
        {
            int decimalPlaceRound = UI_Conversions.UserInputToInt(roundingPlaces.options[roundingPlaces.value].text);
            RoundToDecimalPlaces(ref chiSquareRandomNumbers, decimalPlaceRound);
        }
        chiSquareRandomNumbers.Sort();

        int            minCount = System.Int32.MaxValue;
        int            maxCount = System.Int32.MinValue;
        List <Vector2> counts   = CountOccurences(chiSquareRandomNumbers, ref minCount, ref maxCount);

        wg.Graph(counts, new Vector2(minRange, maxRange), new Vector2(minCount, maxCount));
    }
    public void UnityRandomRange()
    {
        wg = windowGraph.GetComponent <Window_Graph>();
        if (wg == null)
        {
            Debug.Log("wg is null");
            return;
        }

        Clear(wg);

        int   numToGen = UI_Conversions.UserInputToInt(numberToGenerate);
        float minRange = UI_Conversions.UserInputToFloat(rangeMinimum);
        float maxRange = UI_Conversions.UserInputToFloat(rangeMaximum);

        if (numToGen == -1 || minRange == -1 || maxRange == -1)
        {
            return;
        }

        List <float> unityRandomRangeNumbers = new List <float>();

        Randomness.Instance.UnityRandom(numToGen, minRange, maxRange, ref unityRandomRangeNumbers);

        if (roundingToggle.isOn)
        {
            //Mild rounding to make it easier
            int decimalPlaceRound = UI_Conversions.UserInputToInt(roundingPlaces.options[roundingPlaces.value].text);
            RoundToDecimalPlaces(ref unityRandomRangeNumbers, decimalPlaceRound);
        }
        //Sort the list
        unityRandomRangeNumbers.Sort();

        //Count the number of occurences of each value
        int            minCount = System.Int32.MaxValue;
        int            maxCount = System.Int32.MinValue;
        List <Vector2> counts   = CountOccurences(unityRandomRangeNumbers, ref minCount, ref maxCount);

        //plot that count vs the value
        wg.Graph(counts, new Vector2(minRange, maxRange), new Vector2(minCount, maxCount));
    }
    public void GaussianRandom()
    {
        wg = windowGraph.GetComponent <Window_Graph>();
        if (wg == null)
        {
            Debug.Log("wg is null");
            return;
        }

        Clear(wg);

        int   numToGen = UI_Conversions.UserInputToInt(numberToGenerate);
        float mean     = UI_Conversions.UserInputToFloat(rangeMinimum);
        float stdDev   = UI_Conversions.UserInputToFloat(rangeMaximum);

        if (numToGen == -1 || mean == -1 || stdDev == -1)
        {
            return;
        }

        List <float> standardDistributionRandomNumbers = new List <float>();

        Randomness.Instance.GaussianRandom(numToGen, mean, stdDev, ref standardDistributionRandomNumbers);

        if (roundingToggle.isOn)
        {
            int decimalPlaceRound = UI_Conversions.UserInputToInt(roundingPlaces.options[roundingPlaces.value].text);
            RoundToDecimalPlaces(ref standardDistributionRandomNumbers, decimalPlaceRound);
        }

        standardDistributionRandomNumbers.Sort();

        int            minCount = System.Int32.MaxValue;
        int            maxCount = System.Int32.MinValue;
        List <Vector2> counts   = CountOccurences(standardDistributionRandomNumbers, ref minCount, ref maxCount);

        wg.Graph(counts, new Vector2(mean + stdDev * -3.0f, mean + stdDev * 3.0f), new Vector2(minCount, maxCount));
    }
    public void CSharpRandom()
    {
        wg = windowGraph.GetComponent <Window_Graph>();
        if (wg == null)
        {
            Debug.Log("wg is null");
            return;
        }

        Clear(wg);

        int   numToGen = UI_Conversions.UserInputToInt(numberToGenerate);
        float minRange = UI_Conversions.UserInputToFloat(rangeMinimum);
        float maxRange = UI_Conversions.UserInputToFloat(rangeMaximum);

        if (numToGen == -1 || minRange == -1 || maxRange == -1)
        {
            return;
        }

        List <float> cSharpRandomNumbers = new List <float>();

        Randomness.Instance.CSharpRandom(numToGen, minRange, maxRange, ref cSharpRandomNumbers);

        if (roundingToggle.isOn)
        {
            int decimalPlaceRound = UI_Conversions.UserInputToInt(roundingPlaces.options[roundingPlaces.value].text);
            RoundToDecimalPlaces(ref cSharpRandomNumbers, decimalPlaceRound);
        }

        cSharpRandomNumbers.Sort();

        int            minCount = System.Int32.MaxValue;
        int            maxCount = System.Int32.MinValue;
        List <Vector2> counts   = CountOccurences(cSharpRandomNumbers, ref minCount, ref maxCount);

        wg.Graph(counts, new Vector2(minRange, maxRange), new Vector2(minCount, maxCount));
    }