示例#1
0
    public int getSymbol()
    {
        int chosen = -1;

        while (chosen == -1)
        {
            //int selectedFrequency = UnityEngine.Random.Range(1,totalFrequency+1);
            uint selectedFrequency = RNGManager.getRandomRange(slot.activeRNG, 1, totalFrequency + 1);
            for (int index = 0; index < cumulativeFrequencyList.Count; index++)
            {
                if (selectedFrequency <= cumulativeFrequencyList[index])
                {
                    chosen = index; break;
                }
            }
            int maxPerReel = slot.symbolPrefabs[chosen].GetComponent <SlotSymbol>().clampPerReel;
            if (maxPerReel > 0)
            {
                if (getSymbolCountCurrentlyOnReel(chosen) >= maxPerReel)
                {
                    chosen = -1; continue;
                }
                int maxTotal = slot.symbolPrefabs[chosen].GetComponent <SlotSymbol>().clampTotal;
                if (maxTotal > 0)
                {
                    if (slot.getSymbolCountCurrentlyTotal(chosen) >= maxTotal)
                    {
                        chosen = -1;
                    }
                }
            }
        }

        return(chosen);
    }
示例#2
0
    /*
     * public int getSymbol()
     * {
     *      int chosen = -1;
     *      while (chosen == -1)
     *      {
     *              //int selectedFrequency = UnityEngine.Random.Range(1,totalFrequency+1);
     *              uint selectedFrequency = RNGManager.getRandomRange(slot.activeRNG, 1, totalFrequency+1);
     *              for (int index = 0; index < cumulativeFrequencyList.Count; index++)
     *              {
     *                      if (selectedFrequency <= cumulativeFrequencyList[index]) { chosen = index; break; }
     *              }
     *              int maxPerReel = slot.symbolPrefabs[chosen].GetComponent<SlotSymbol>().clampPerReel;
     *              if (maxPerReel > 0)
     *              {
     *                      if (getSymbolCountCurrentlyOnReel(chosen) >= maxPerReel) { chosen = -1; continue; }
     *                      int maxTotal = slot.symbolPrefabs[chosen].GetComponent<SlotSymbol>().clampTotal;
     *                      if (maxTotal > 0)
     *                              if (slot.getSymbolCountCurrentlyTotal(chosen) >= maxTotal) chosen = -1;
     *              }
     *      }
     *
     *      return chosen;
     * }
     */

    public int getSymbol(int reelIndex)
    {
        List <int> cumulativeFrequencyList = new List <int>();
        int        totalFrequency          = 0;

        for (int index = 0; index < slot.symbolFrequencies.Count; index++)
        {
            SlotSymbol symbol = slot.symbolPrefabs[index].GetComponent <SlotSymbol>();
            if (symbol.perReelFrequency)
            {
                totalFrequency += slot.reelFrequencies[index].freq[reelIndex];
            }
            else
            {
                totalFrequency += slot.symbolFrequencies[index];
            }
            cumulativeFrequencyList.Add(totalFrequency);
        }

        int chosen = -1;

        while (chosen == -1)
        {
            uint selectedFrequency = RNGManager.getRandomRange(slot.activeRNG, 1, totalFrequency + 1);

            if (selectedFrequency == totalFrequency + 1)
            {
                Debug.Log("wtf");
            }
            for (int index = 0; index < cumulativeFrequencyList.Count; index++)
            {
                if (selectedFrequency <= cumulativeFrequencyList[index])
                {
                    chosen = index; break;
                }
            }
            int maxPerReel = slot.symbolPrefabs[chosen].GetComponent <SlotSymbol>().clampPerReel;
            if (maxPerReel > 0)
            {
                if (getSymbolCountCurrentlyOnReel(reelIndex, chosen) >= maxPerReel)
                {
                    chosen = -1; continue;
                }
                int maxTotal = slot.symbolPrefabs[chosen].GetComponent <SlotSymbol>().clampTotal;
                if (maxTotal > 0)
                {
                    if (getSymbolCountCurrentlyTotal(chosen) >= maxTotal)
                    {
                        chosen = -1;
                    }
                }
            }
        }

        return(chosen);
    }