Exemplo n.º 1
0
 void Awake ()
 {
     start = false;
     shuffle = new shuffleBag(1, dirshuffle);
 }
Exemplo n.º 2
0
        //Function to stop the pins from spinning, get the results and start a minigame if at least 2 equal symbols are drawn
        IEnumerator stopPins()
        {
            Debug.Log("StopPins");
            yield return new WaitForSeconds(5);
            otherSpinA = false;
            otherSpinB = false;
            otherSpinC = false;
            yield return new WaitForSeconds(0.5f);
            for (int i = 0; i < 3; i++)
            {
                //Switch between shuffle bags to draw from based on the second pins results
                switch (results[i+3])
                {
                    case 0:
                        toUse = sbDef;
                        break;
                    case 1:
                        toUse = sbTempA;
                        break;
                    case 2:
                        toUse = sbTempB;
                        break;
                    case 3:
                        toUse = sbTempC;
                        break;
                }
                results[i] = toUse.Next();
            }
            Debug.Log("The Results are PinA = " + results[0] + " / PinB = " + results[1] + " / PinC = " + results[2]);

            leverAnimator.SetBool("LeverPulled", false); //makes the lever go up
            soundLeverDown.Play(); // plays a lever sound

            for (int i = 1; i<4; i++)
            {
                
                pinIsSpinning[i] = false;
                allPinAudio[i][0].Stop();
                allPinAudio[i][1].Play();
                switch (results[i-1])
                {
                    case 0:
                        GM.Get().scene.miscRefs[i].GetComponent<SpriteRenderer>().sprite = pinSymbolGrape;
                        break;
                    case 1:
                        GM.Get().scene.miscRefs[i].GetComponent<SpriteRenderer>().sprite = pinSymbolBell;
                        break;
                    case 2:
                        GM.Get().scene.miscRefs[i].GetComponent<SpriteRenderer>().sprite = pinSymbolCherry;
                        break;
                    case 3:
                        GM.Get().scene.miscRefs[i].GetComponent<SpriteRenderer>().sprite = pinSymbolSeven;
                        break;
                    case 4:
                        GM.Get().scene.miscRefs[i].GetComponent<SpriteRenderer>().sprite = pinSymbolDimond;
                        break;
                    case 5:
                        GM.Get().scene.miscRefs[i].GetComponent<SpriteRenderer>().sprite = pinSymbolClover;
                        break;
                }
                yield return new WaitForSeconds(1.0f);
            }

            
            leverMode = !leverMode;
            changeColor("greenLightbulp", true);
            changeColor("redLightbulp", false);


            //Starting minigame if at least 2 equal symbols are drawn
            if (results[0] == results[1] || results[0] == results[2] || results[1] == results[2])
            {   
                //If all symbols are equal, extra credits are awarded
                if ((results[0] == results[1]) && (results[1] == results[2]))
                {
                    if      (results[0] == 0) { gbp += bet * 2; }
                    else if (results[0] == 1) { gbp += bet * 3; }
                    else if (results[0] == 2) { gbp += bet * 4; }
                    else if (results[0] == 3) { gbp += bet * 5; }
                    else if (results[0] == 4) { gbp += bet * 10; }
                    else if (results[0] == 5) { gbp += bet * (Random.Range(0, 10)); }

                    Extra_Credit_sound.Play();
                }

                //If at least one clover is drawn bet credits are awarded
                else if (results[0] == 5 || results[1] == 5 || results[2] == 5)
                { gbp += bet;
                  Extra_Credit_sound.Play();
                  coinText.text = gbp.ToString();
                }

                coinText.text = gbp.ToString();
                int RandomMini = Randomizer();
                yield return new WaitForSeconds(1);
                MiniStarts.Play();
                miniGamePopUp.SetActive(true);

                //Display the name of the random minigame selected
                if      (RandomMini == 0) { miniGameText.GetComponent<Text>().text = "Fruit Catcher"; }
                else if (RandomMini == 1) { miniGameText.GetComponent<Text>().text = "Fruit Sorter"; }
                else if (RandomMini == 2) { miniGameText.GetComponent<Text>().text = "Click The Fruit"; }

                gMode = GameMode.MiniGame;
                yield return new WaitForSeconds(5);
                miniGamePopUp.SetActive(false);
              
                //Start the minigame randomly selected
                switch (RandomMini)
                {
                    case 0:
                        miniGame_Type = 1;
                        callMiniGame(MiniGames.mini1);
                        break;
                    case 1:
                        miniGame_Type = 2;
                        callMiniGame(MiniGames.mini2);
                        break;
                    case 2:
                        miniGame_Type = 3;
                        callMiniGame(MiniGames.mini3);
                        break;
                }

            }
            
            //If all symbols are different, reset the multipliers (if applied) and award bet credits if at least one element is a clover
            else
            {
                if (results[0] == 5 || results[1] == 5 || results[2] == 5)
                { gbp += bet;
                  Extra_Credit_sound.Play();
                  coinText.text = gbp.ToString();
                  yield return new WaitForSeconds(1);
                }

                UsedX2 = false;
                UsedX3 = false;
                UsedX4 = false;

                updateMulti();
                No_Equal_Symb.Play();
                checkHighScore();
            }

            yield return null;
        }
Exemplo n.º 3
0
//Function that deals with the buttons on the slot machine assigned in buttonrefs vector in _GM
        public void procCmds(int buttonIndex)
        {
            Debug.Log(gMode);
            switch (buttonIndex)
            {
                //Lever button for main pins spin
                case 0:
                    if (gMode == GameMode.Slots)
                    {
                        if (leverMode && (gbp>=bet))
                        {   //First Pull
                            leverAnimator.SetBool("LeverPulled", true); //makes the lever go down
                            soundLeverDown.Play(); // plays a lever sound
                            changeColor("greenLightbulp", false);
                            changeColor("redLightbulp", true);
                            Debug.Log("Lever Down");
                            leverMode = !leverMode;
                            StartCoroutine(spinPins());
                            otherPinState = 0;
                            StartCoroutine(spinOtherPinA());
                            StartCoroutine(spinOtherPinB());
                            StartCoroutine(spinOtherPinC());
                            results[0] = sbDef.Next();
                            results[1] = sbDef.Next();
                            results[2] = sbDef.Next();
                            toUse = sbDef;
                            gbp -= bet;
                            coinText.text = gbp.ToString();
                        }
                        else
                        {//Second to Fourth Side Pull to control the spinning of the other pins (numbered ones)

                            if (otherPinState < 3)
                            {
                                leverAnimator.SetTrigger("LeverPulledRight"); //makes the lever go right and back again
                                soundLeverRight.Play();                      // plays a lever sound
                                Debug.Log("Lever Side = " + otherPinState);
                                switch (otherPinState)
                                {
                                    case 0:
                                        stopOtherPinA();
                                        break;
                                    case 1:
                                        stopOtherPinB();
                                        break;
                                    case 2:
                                        stopOtherPinC();
                                        break;
                                }

                                otherPinState++;
                            }
                        }
                    }
                    break;

                case 1: // Bets Minus button 
                    if (gMode == GameMode.Slots && bet > 1 && leverMode)
                    {
                        bet--;
                        toBet.text = bet.ToString();
                    }
                    break;

                case 2: // Bets Plus button
                    if (gMode == GameMode.Slots && bet < gbp && leverMode)
                    {
                        bet++;
                        toBet.text = bet.ToString();
                    }
                    break;

                case 3: //Multiplier X2
                    if (gMode == GameMode.Slots && leverMode)
                    {
                        if (multiStored[0] != 0 && !UsedX2 && !UsedX3 && !UsedX4)
                        {
                            multiStored[0]--;
                            UsedX2 = true;
                        }
                        updateMulti();
                    }
                    break;

                case 4: //Multiplier X3
                    if (gMode == GameMode.Slots && leverMode)
                    {
                        if (multiStored[1] != 0 && !UsedX2 && !UsedX3 && !UsedX4)
                        {
                            multiStored[1]--;
                            UsedX3 = true;
                        }
                        updateMulti();
                    }
                    break;

                case 5: //Multiplier X4
                    if (gMode == GameMode.Slots && leverMode)
                    {
                        if (multiStored[2] != 0 && !UsedX2 && !UsedX3 && !UsedX4)
                        {
                            multiStored[2]--;
                            UsedX4 = true;
                        }
                        updateMulti();
                    }
                    break;

                case 6: //Play Again button at gameover
                    resetSlot();
                    break;

                case 7: //Tutorial Text on and off
                    if (tutorialON) { GM.Get().scene.miscRefs[23].SetActive(false);
                                     GM.Get().scene.miscRefs[24].SetActive(false);
                                     tutorialON = false; }

                    else            { GM.Get().scene.miscRefs[23].SetActive(true);
                                      GM.Get().scene.miscRefs[24].SetActive(true);
                                      tutorialON = true; }
                    break;

                case 8: //Game bonus text on and off
                    Debug.Log("Tutorial pressed");
                    if (tutorialON)
                    {
                        GM.Get().scene.miscRefs[23].SetActive(false);
                        GM.Get().scene.miscRefs[24].SetActive(false);
                        tutorialON = false;
                    }
                    else
                    {
                        GM.Get().scene.miscRefs[23].SetActive(true);
                        GM.Get().scene.miscRefs[24].SetActive(true);
                        tutorialON = true;
                    }
                    break;
            }

        }
Exemplo n.º 4
0
        int[] results = new int[] { 0, 0, 0, 0, 0, 0}; // Vector holding values for the pins symbols. first three for main Pins, second three for secondary Pins

      //Init Function
        protected override void Awake()
        {
            //Settin up references to Components listed in the GM script (Buttons and other 'miscellaneous' references such as texts, sounds etc.)
            GM.Get().data.initSaveGame();
            CurrentMultUsed = GM.Get().scene.miscRefs[14].GetComponent<Text>();
            helpText = GM.Get().scene.miscRefs[0].GetComponent<Text>();
            coinText = GM.Get().scene.miscRefs[7].GetComponent<Text>();
            pinAText = GM.Get().scene.miscRefs[1].GetComponent<Text>();
            pinBText = GM.Get().scene.miscRefs[2].GetComponent<Text>();
            pinCText = GM.Get().scene.miscRefs[3].GetComponent<Text>();
            TotalScore = GM.Get().scene.miscRefs[13].GetComponent<Text>();
            HighScore = GM.Get().scene.miscRefs[17].GetComponent<Text>();
            Display_HighScore = GM.Get().scene.miscRefs[22].GetComponent<Text>();
            FinalGameScore = GM.Get().scene.miscRefs[9].GetComponent<Text>();
            otherPinAText = GM.Get().scene.miscRefs[4].GetComponentInChildren<Text>();
            otherPinBText = GM.Get().scene.miscRefs[5].GetComponentInChildren<Text>();
            otherPinCText = GM.Get().scene.miscRefs[6].GetComponentInChildren<Text>();
            extraMultiA = GM.Get().scene.buttonRefs[3].GetComponentInChildren<Text>();
            extraMultiB = GM.Get().scene.buttonRefs[4].GetComponentInChildren<Text>();
            extraMultiC = GM.Get().scene.buttonRefs[5].GetComponentInChildren<Text>();
            toBet = GM.Get().scene.miscRefs[8].GetComponent<Text>();

            //Setting up game states and activate/deactivate specific elements
            GM.Get().scene.miscRefs[23].SetActive(false);
            GM.Get().scene.miscRefs[24].SetActive(false);
            gMode = 0;


            //lever variables are innitalized
            leverMode = true;
            leverGameObject = GameObject.FindGameObjectWithTag("lever"); //Accessing the lever game object
            leverAnimator = leverGameObject.GetComponent<Animator>(); //Accessing the animator componenet on the lever object
            leverAudio = leverGameObject.GetComponents<AudioSource>(); //Accessing all the sound componenets on the lever object
            soundLeverDown = leverAudio[0]; //references to specific audio sources
            soundLeverRight = leverAudio[1];


            //pin variables are initialized
            pinSymbols = new Sprite[6];
            pinSymbols[0] = pinSymbolGrape;
            pinSymbols[1] = pinSymbolBell;
            pinSymbols[2] = pinSymbolDimond;
            pinSymbols[3] = pinSymbolSeven;
            pinSymbols[4] = pinSymbolCherry;
            pinSymbols[5] = pinSymbolClover;

            pinIsSpinning = new bool [4];
            allPinAudio = new AudioSource[4][];

          //Audio for pins
            allPinAudio[1] = GM.Get().scene.miscRefs[1].GetComponents<AudioSource>();
            allPinAudio[2] = GM.Get().scene.miscRefs[2].GetComponents<AudioSource>();
            allPinAudio[3] = GM.Get().scene.miscRefs[3].GetComponents<AudioSource>();

            //Other audio sources initialized
            Extra_Credit_sound = GM.Get().scene.miscRefs[18].GetComponent<AudioSource>();
            GameOver_sound = GM.Get().scene.miscRefs[19].GetComponent<AudioSource>();
            MiniStarts = GM.Get().scene.miscRefs[20].GetComponent<AudioSource>();
            No_Equal_Symb = GM.Get().scene.miscRefs[21].GetComponent<AudioSource>();

            //Setting up instances for other minigame-related text objects
            miniGameText = GameObject.FindGameObjectWithTag("miniGameText");
            miniGamePopUp = GameObject.FindGameObjectWithTag("miniGamePopUp");

            changeColor("greenLightbulp", true);
            changeColor("redLightbulp", false);


            result = new float[2];//Vector containing at position 0 information about the multiplier and at position 1 the output score of a minigame
            sbDef = new shuffleBag(3, defShuffle); //Scale is the number of times the shuffle bag stores multiple copies of the ratio before resetting (essentially maximimum times the best results should repeat kind of)
            sbTempA = new shuffleBag(3, shuffleA);
            sbTempB = new shuffleBag(3, shuffleB);
            sbTempC = new shuffleBag(3, shuffleC);
           

        }