Esempio n. 1
0
    /// <summary>
    /// Roll the slot machine for random time in milliseconds for each roller
    /// </summary>
    void Play()
    {
        // Don't roll again if there are still rollers rolling
        foreach (SlotManager slot in slotManager)
        {
            if (slot.Rolling)
            {
                return;
            }
        }

        // First roller will be rolling for drawn time in milliseconds between 17 and 27
        Random.seed = System.DateTime.Now.Millisecond;
        int slot1Rotations = Random.Range(17, 27);

        // For every roller increase the amount of time it will take to finish rolling by random amount
        for (int i = 0; i < slotManager.Length; i++)
        {
            // Pass time to keep rolling to the roller
            DrawnFields[i] = slotManager[i].RollSlotByRotations(slot1Rotations);
            // Add random between 3 to 7 and 1 to 4 milliseconds to the rolling time alternately
            slot1Rotations += (i % 2 == 1) ? Random.Range(3, 7) : Random.Range(1, 4);
        }

        // Fire animation on the arm
        arm.Animate();

        // Subtract points from the score to initiate rolling, if there was not enough points PayToPlay() will return false
        gameOver = !scoreUpdateScript.PayToPlay();
    }