12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232 |
- //================================================================================
- //
- //================================================================================
- using UnityEngine;
- using System.Collections;
- using SimpleJSON;
- using System.Collections.Generic;
- //================================================================================
- //
- //================================================================================
- namespace ReaderRabbit
- {
- //================================================================================
- //
- //================================================================================
- public class SceneGumballScience : SceneCommon
- {
- //================================================================================
- //
- //================================================================================
- private enum Characters
- {
- Reader = CharactersCommon.Reader,
- Sam = CharactersCommon.Sam,
- Paige = CharactersCommon.Paige,
- Chester = CharactersCommon.Chester,
- Gum = CharactersCommon.StartSceneSpecific,
- }
- //================================================================================
- //
- //================================================================================
- private const int SAM_CANDY_ANIMATION = (int)SamAnimation.AnimationCycles.Misc1 + 1;
- private const int SAM_WHISTLE_ANIMATION = SAM_CANDY_ANIMATION + 1;
- //================================================================================
- //
- //================================================================================
- private const int WORD_LIST_1_SIZE = 11;
- private const int WORD_LIST_2_SIZE = 12;
- private const int WORD_LIST_3_SIZE = 12;
- private const int WORD_LIST_1_NON_PRACTICE_SIZE = 3;
- private const int NUMBER_OF_MINIGAME_LEVELS = 3;
- private const int NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE = 3;
- public int INITIAL_SENTENCE_LIST = 25750;
- private Vector3 PRIZES_EXIT_POSITION = new Vector3(582, -316, -0.25f);
- private int lang;
- //================================================================================
- //
- //================================================================================
- [SerializeField] private GameObject m_PrizeCandy;
- [SerializeField] private GameObject m_PrizeMarble;
- [SerializeField] private GameObject m_PrizeWhistle;
- [SerializeField] private GameObject m_AnimationCandy;
- [SerializeField] private GameObject m_AnimationMarble;
- [SerializeField] private GameObject m_AnimationWhistle;
- [SerializeField] private List<Transform> m_AnimationCandyPath;
- [SerializeField] private List<Transform> m_AnimationMarblePath;
- [SerializeField] private List<Transform> m_AnimationWhistlePath;
- [SerializeField] private CollectableMarble m_Marble;
- [SerializeField]
- private GumballMachine m_GumballMachine;
- private int m_CurrentWordList;
- public int m_CurrentMinigameLevel;
- private int m_WinsCount;
- private int m_TotalCorrectCount;
- private int m_NumGumClicks;
- private int m_NumPaigeClicks;
- private int m_MarbleSpeechCount;
- private int m_WrongCount;
- private int m_NumberOfCurGuiderClicks;
- private int m_NumberCandyClicks;
- private int m_WordClicks;
- private bool m_BoolRampClicked;
- private bool m_BoolTokenReleaseClicked;
- private bool m_BoolSentenceClicked;
- private GumballScienceBallGuider m_CurrentClickedGuider;
- private Dictionary<string, string> m_WordsList;
- private List<string> m_SentencesList;
- private PrizeCandy m_PrizeCandyScript; // mycode --rafael
- public Collider2D blocker;
- //================================================================================
- //
- //================================================================================
- protected override void Start()
- {
- base.Start();
- //============================================================================
- //
- //============================================================================
- lang = PlayerPrefs.GetInt("language");
- switch (lang)
- {
- case 0:
- m_SpeechFolder = "Resources_DA/Audio/GumballScience_Speech";
- break;
- case 1:
- m_SpeechFolder = "Resources_EN/Audio/GumballScience_Speech";
- break;
- case 2:
- m_SpeechFolder = "Resources_NO/Audio/GumballScience_Speech";
- break;
- case 3:
- m_SpeechFolder = "Resources_SP/Audio/GumballScience_Speech";
- break;
- case 4:
- m_SpeechFolder = "Resources_SW/Audio/GumballScience_Speech";
- break;
- }
- //============================================================================
- //
- //============================================================================
- m_PrizeCandyScript = m_PrizeCandy.GetComponent<PrizeCandy>(); // mycode --rafael
- PlayerData.Instance().SetVisitedGumballScience(true);
- PlayerData.Instance().SetCurrentLocation(Location.GumballScience);
- PlayerData.Instance().UnlockActivity(Activity.GumballScience);
- AudioManager.Instance().PlayBGM("BGM_GumballScience");
- this.m_CurrentMinigameLevel = PlayerData.Instance().GetActivityLevel(Activity.GumballScience);
- this.m_CurrentWordList = 0;
- this.m_WinsCount = 0;
- this.m_TotalCorrectCount = 0;
- this.m_NumGumClicks = 0;
- this.m_NumPaigeClicks = 0;
- this.m_MarbleSpeechCount = 0;
- this.m_WrongCount = 0;
- this.m_NumberOfCurGuiderClicks = 0;
- this.m_WordClicks = 0;
- this.m_BoolTokenReleaseClicked = false; //myCode --rafael. Anteriormente o valor era "false".
- this.m_BoolRampClicked = false;
- this.m_BoolSentenceClicked = false;
- //TODO: Manage animations instead of initializing it directly.
- //Invoke("LoadNextLevel", 0.5f);
- SetupWordsList();
- SetupSentencesList();
- Invoke("UpdateSizesAndPositions", 0.01f);
- m_Marble.SetParentScene(this);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_Marble.gameObject, false);
- }
- //================================================================================
- //
- //================================================================================
- private void SetupWordsList()
- {
- TextAsset text;
- text = null;
- switch (lang)
- {
- case 0:
- text = Resources.Load<TextAsset>("Resources_DA/GumballScience/r1la1words");
- break;
- case 1:
- text = Resources.Load<TextAsset>("Resources_EN/GumballScience/r1la1words");
- break;
- case 2:
- text = Resources.Load<TextAsset>("Resources_NO/GumballScience/r1la1words");
- break;
- case 3:
- text = Resources.Load<TextAsset>("Resources_SP/GumballScience/r1la1words");
- break;
- case 4:
- text = Resources.Load<TextAsset>("Resources_SW/GumballScience/r1la1words");
- break;
- }
- m_WordsList = new Dictionary<string,string>();
- string[] separators = {"\r","\n"};
- string[] tokens = text.ToString().Split(separators, System.StringSplitOptions.RemoveEmptyEntries);
- foreach(string token in tokens)
- {
- Debug.Log(token);
- m_WordsList.Add(token.Split(';')[1], token.Split(';')[0]);
- }
- }
- //================================================================================
- //
- //================================================================================
- private void SetupSentencesList()
- {
- TextAsset jsonText;
- jsonText = null;
- switch (lang)
- {
- case 0:
- jsonText = Resources.Load<TextAsset>("Resources_DA/GumballScience/r1la1data");
- break;
- case 1:
- jsonText = Resources.Load<TextAsset>("Resources_EN/GumballScience/r1la1data");
- break;
- case 2:
- jsonText = Resources.Load<TextAsset>("Resources_NO/GumballScience/r1la1data");
- break;
- case 3:
- jsonText = Resources.Load<TextAsset>("Resources_SP/GumballScience/r1la1data");
- break;
- case 4:
- jsonText = Resources.Load<TextAsset>("Resources_SW/GumballScience/r1la1data");
- break;
- }
- JSONNode json = JSONNode.Parse(jsonText.text);
- m_SentencesList = new List<string>();
- for (int i = 1; i <= 3; ++i)
- {
- JSONNode currentLevelWordLists = json["DataSet"]["Level_" + i];
-
- int j = 1;
- while (currentLevelWordLists["DataSet_" + j] != null)
- {
- JSONNode dataSet = currentLevelWordLists["DataSet_" + j];
- for (int k = 1; k <= 3; ++k)
- {
- JSONNode set = dataSet["Set_" + k];
- string fullSentence = set.ToString().Split('.')[0].Replace("\"", "").Replace("\\", "") + ".";
- string[] sentenceTokens = fullSentence.Split('_');
- string sentenceToken = sentenceTokens[0];
- if (sentenceToken.EndsWith(" "))
- {
- sentenceToken = sentenceToken.Remove(sentenceToken.Length - 1, 1);
- }
- if (!m_SentencesList.Contains(sentenceToken))
- {
- m_SentencesList.Add(sentenceToken);
- }
- sentenceToken = sentenceTokens[1];
- if (sentenceToken.StartsWith(" "))
- {
- sentenceToken = sentenceToken.Remove(0, 1);
- }
- if (!m_SentencesList.Contains(sentenceToken))
- {
- m_SentencesList.Add(sentenceToken);
- }
- }
- j++;
- }
- }
- m_SentencesList.Sort((x, y) => string.Compare(x, y));
- }
- //================================================================================
- //
- //================================================================================
- private void UpdateSizesAndPositions()
- {
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_PrizeCandy);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_PrizeMarble, false);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_PrizeWhistle);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_AnimationCandy);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_AnimationMarble);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_AnimationWhistle);
- }
- //================================================================================
- //
- //================================================================================
- protected override void PlayFirstEvent()
- {
- base.PlayFirstEvent();
- int numberOfSpeeches = 0;
- NewSequence();
- if (!PlayerData.Instance().IsPracticeMode())
- {
- if (m_IsFirstTime)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25150");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25151");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, LoadNextLevel);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25350");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25351");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25354");
- //TODO: Blink hook
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25360");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25361");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25362");
- }
- else if (PlayerData.Instance().GetWhistle() == ItemState.None)
- {
- if (this.m_PrizeWhistle.activeSelf)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25180");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25181");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25182");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25183");
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25175");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25176");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25177");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25178");
- }
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, LoadNextLevel);
- }
- else if (PlayerData.Instance().GetWhistle() != ItemState.None)
- {
- int randomNumber = Random.Range(1, 3);
- if (randomNumber == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25190");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25176");
- }
- else if (randomNumber == 2)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25182");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25183");
- }
- else if (randomNumber == 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25196");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25197");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25198");
- }
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, LoadNextLevel);
- }
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25360");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25361");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, LoadNextLevel);
- }
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- private void LoadNextLevel()
- {
- TextAsset jsonText;
- jsonText = null;
- switch (lang)
- {
- case 0:
- jsonText = Resources.Load<TextAsset>("Resources_DA/GumballScience/r1la1data");
- break;
- case 1:
- jsonText = Resources.Load<TextAsset>("Resources_EN/GumballScience/r1la1data");
- break;
- case 2:
- jsonText = Resources.Load<TextAsset>("Resources_NO/GumballScience/r1la1data");
- break;
- case 3:
- jsonText = Resources.Load<TextAsset>("Resources_SP/GumballScience/r1la1data");
- break;
- case 4:
- jsonText = Resources.Load<TextAsset>("Resources_SW/GumballScience/r1la1data");
- break;
- }
- JSONNode json = JSONNode.Parse(jsonText.text);
- JSONNode currentLevelWordLists = json["DataSet"]["Level_" + m_CurrentMinigameLevel];
- int wordListSize = GetCurrentWordListSize();
- m_CurrentWordList++;
- if (m_CurrentWordList >= wordListSize) //(m_CurrentWordList > wordListSize)
- {
- m_CurrentWordList = 1;
- //Updates mini-game's next level
- if (m_CurrentWordList < wordListSize && !PlayerData.Instance().IsActivityLocked(Activity.RaingearForestMath)) //(m_CurrentWordList > wordListSize && !PlayerData.Instance().IsActivityLocked(Activity.RaingearForestMath))
- {
- m_CurrentMinigameLevel++;
- if (m_CurrentMinigameLevel > NUMBER_OF_MINIGAME_LEVELS)
- {
- m_CurrentMinigameLevel = NUMBER_OF_MINIGAME_LEVELS;
- }
- currentLevelWordLists = json["DataSet"]["Level_" + m_CurrentMinigameLevel]; //myCode --rafael.
- PlayerData.Instance().SetActivityLevel(Activity.GumballScience, m_CurrentMinigameLevel);
- }
- }
- //Get a random word list set
- JSONNode selectedWordList = currentLevelWordLists["DataSet_" + m_CurrentWordList];
- JSONNode wordListSet = selectedWordList["Set_" + Random.Range(1, 4)];
- m_GumballMachine.Setup(wordListSet.Value, m_CurrentMinigameLevel);
- }
- //================================================================================
- //
- //================================================================================
- private int GetCurrentWordListSize()
- {
- int wordListSize = 0;
- //Check number of word lists
- if (m_CurrentMinigameLevel == 1)
- {
- if (!PlayerData.Instance().IsPracticeMode() && !PlayerData.Instance().IsActivityLocked(Activity.RaingearForestMath))
- {
- wordListSize = WORD_LIST_1_SIZE;//my code --rafael -> anteriormente era a seguinte constante WssORD_LIST_1_NON_PRACTICE_SIZE;
- }
- else
- {
- wordListSize = WORD_LIST_1_SIZE;
- }
- }
- else if (m_CurrentMinigameLevel == 2)
- {
- wordListSize = WORD_LIST_2_SIZE;
- }
- else
- {
- wordListSize = WORD_LIST_3_SIZE;
- }
- return wordListSize;
- }
- //================================================================================
- //
- //================================================================================
- public void ExecuteBallPath()
- {
- DisableInput();
- m_GumballMachine.ExecutePath();
- }
- //================================================================================
- //
- //================================================================================
- public void EnableInput()
- {
- blocker.enabled = false;
- m_GumballMachine.BallGuidersManager.EnableGuidersInput();
- m_GumballMachine.BallGuidersManager.EnableHook();
- }
- //================================================================================
- //
- //================================================================================
- public void DisableInput()
- {
- blocker.enabled = true;
- m_GumballMachine.BallGuidersManager.DisableHook();
- }
- //================================================================================
- //
- //================================================================================
- public void PlayCorrectAnswerSequence(string[] sentenceParts)
- {
- m_TotalCorrectCount++;
- int numberOfSpeeches = 0;
- NewSequence();
- string[] possibleWords = { "25205", "25206", "25207", "25208", "25209", "25210" };
- int randomNumber = Random.Range(0, possibleWords.Length);
- AudioManager.Instance().PlaySFX("25200");
- numberOfSpeeches = PlaySentence(sentenceParts, numberOfSpeeches);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, possibleWords[randomNumber]);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, GivePrize);
- if (!PlayerData.Instance().IsPracticeMode())
- {
- if (m_WinsCount + 1 == NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE && PlayerData.Instance().GetWhistle() == ItemState.None)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25226");
- }
- else
- {
- if ((m_WinsCount + 1) % NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE == 0 && (PlayerData.Instance().GetWhistle() != ItemState.None ||
- m_PrizeWhistle.gameObject.activeSelf))
- {
- AudioManager.Instance().PlaySFX("2143");
- m_MarbleSpeechCount++;
- if (m_MarbleSpeechCount == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25230");
- }
- else if (m_MarbleSpeechCount == 2)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25231");
- }
- else if (m_MarbleSpeechCount == 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25232");
- m_MarbleSpeechCount = 0;
- }
- }
- }
- StartSequence(numberOfSpeeches);
- }
- else
- {
- GivePrize();
- }
- }
- //================================================================================
- //
- //================================================================================
- public void PlayWrongAnswerSequence(string[] sentenceParts, bool sameWord)
- {
- m_WrongCount++;
- int numberOfSpeeches = 0;
- string[] possibleWords = { "25261", "25262", "25263", "25264", "25265", "25266" };
- Characters[] possibleCharacters = { Characters.Gum, Characters.Sam, Characters.Reader, Characters.Gum, Characters.Sam, Characters.Reader };
- int randomNumber = Random.Range(0, possibleWords.Length);
- numberOfSpeeches = PlaySentence(sentenceParts, numberOfSpeeches);
- AudioManager.Instance().PlaySFX("25260");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomNumber], possibleWords[randomNumber]);
- if (sameWord)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25268");
- }
- if (m_WrongCount == 4 && m_NumPaigeClicks == 0 && m_NumGumClicks == 0)
- {
- string[] possibleCharactersSpeeches = { "25270", "25271", "25273"}; //mycode --rafael --> I can found audio 25272 in the game project. This audio goes in that array.
- Characters[] possibleCharacters2 = { Characters.Gum, Characters.Paige, Characters.Paige, Characters.Paige };
- //randomNumber = Random.Range(0, possibleWords.Length);
- randomNumber = Random.Range(0, 3); //mycode --rafael --> original code commented above.
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, possibleCharacters2[randomNumber], possibleCharactersSpeeches[randomNumber]);
- m_WrongCount = 0;
- }
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, m_GumballMachine.BallGuidersManager.Reset);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, EnableInput);
- StartSequence(numberOfSpeeches, false);
- }
- //================================================================================
- //
- //================================================================================
- public void PlayMissedSlotFeedback(bool sameSide)
- {
- if (sameSide)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25268");
- StartSequence(1);
- }
- else
- {
- string[] possibleWords = { "25250", "25251", "25252", "25253", "25254"};
- Characters[] possibleCharacters = { Characters.Sam, Characters.Reader, Characters.Sam, Characters.Reader, Characters.Sam };
- int randomNumber = Random.Range(0, possibleWords.Length);
-
- NewSequence();
- /*SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomNumber], possibleWords[randomNumber]);
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, m_GumballMachine.BallGuidersManager.Reset);
- StartSequence(2);*/
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomNumber], possibleWords[randomNumber]);
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, m_GumballMachine.BallGuidersManager.Reset);
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, EnableInput); //mycode --rafael --original commented above.
- StartSequence(3, false);
- BoolTokenReleaseClicked = false; //mycode --rafael
- }
- }
- //================================================================================
- //
- //================================================================================
- public void GivePrize()
- {
- m_GumballMachine.BallGuidersManager.Reset(m_CurrentMinigameLevel);
- m_GumballMachine.Tray.CloseTray(() =>
- {
- DisableInput();
- if (!PlayerData.Instance().IsPracticeMode())
- {
- m_WinsCount++;
- if (m_WinsCount < NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE)
- {
- m_GumballMachine.UpdateWhistleState(m_WinsCount + 1);
- }
- if (m_WinsCount == NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE && PlayerData.Instance().GetWhistle() == ItemState.None)
- {
- m_GumballMachine.UpdateWhistleState(m_WinsCount + 1);
- PlayGivePrizeAnimation(m_PrizeWhistle);
- }
- else if (m_WinsCount % NUMBER_OF_WINS_TO_GIVE_REAL_PRIZE == 0)
- {
- PlayGivePrizeAnimation(m_PrizeMarble);
- }
- else
- {
- m_PrizeCandyScript.isCollected = false; //mycode --rafael.
- PlayGivePrizeAnimation(m_PrizeCandy);
- }
- }
- else
- {
- LoadNextLevel();
- }
- });
- }
- //================================================================================
- //
- //================================================================================
- private void PlayGivePrizeAnimation(GameObject prize)
- {
- List<Vector3> path = new List<Vector3>();
- string onComplete = "";
- GameObject prizeAnimation = null;
- AudioManager.Instance().PlaySFX("25220");
- if (prize == m_PrizeCandy)
- {
- m_AnimationCandy.SetActive(true);
- m_AnimationCandy.transform.position = KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConvertPointToResolution(PRIZES_EXIT_POSITION.x, PRIZES_EXIT_POSITION.y);
- prizeAnimation = m_AnimationCandy;
- foreach (Transform t in m_AnimationCandyPath)
- {
- path.Add(t.position);
- }
- onComplete = "EnableCandy";
- }
- else if (prize == m_PrizeMarble)
- {
- m_AnimationMarble.SetActive(true);
- m_AnimationMarble.transform.position = KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConvertPointToResolution(PRIZES_EXIT_POSITION.x, PRIZES_EXIT_POSITION.y);
- prizeAnimation = m_AnimationMarble;
- foreach (Transform t in m_AnimationMarblePath)
- {
- path.Add(t.position);
- }
- onComplete = "EnableMarble";
- }
- else if (prize == m_PrizeWhistle)
- {
- m_AnimationWhistle.SetActive(true);
- m_AnimationWhistle.transform.position = KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConvertPointToResolution(PRIZES_EXIT_POSITION.x, PRIZES_EXIT_POSITION.y);
- prizeAnimation = m_AnimationWhistle;
- foreach (Transform t in m_AnimationWhistlePath)
- {
- path.Add(t.position);
- }
- onComplete = "EnableWhistle";
- }
- iTween.MoveTo(prizeAnimation, iTween.Hash(new object[] {
- "path", path.ToArray(), "time", 1f, "easetype", iTween.EaseType.linear, "oncompletetarget", this.gameObject, "oncomplete", onComplete
- }));
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnIdle()
- {
- base.OnIdle();
- if (!PlayerData.Instance().IsPracticeMode())
- {
- int randomNumber = Random.Range(1, 4);
- int numberOfSpeeches = 0;
- NewSequence();
- if (randomNumber == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25300");
- }
- else if (randomNumber == 2)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25301");
- }
- else if (randomNumber == 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25304");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25305");
- }
- else if (randomNumber == 4)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25306");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25307");
- }
- StartSequence(numberOfSpeeches);
- }
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechReader()
- {
- base.SpeechReader();
- if (!PlayerData.Instance().IsPracticeMode())
- {
- int randomNumber = Random.Range(1, 4);
- int numberOfSpeeches = 0;
- NewSequence();
- if (PlayerData.Instance().GetWhistle() == ItemState.None && !this.m_PrizeWhistle.activeSelf)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25152");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25456");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25457");
- }
- else if (PlayerData.Instance().GetWhistle() == ItemState.None && this.m_PrizeWhistle.activeSelf)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25465");
- }
- else if (PlayerData.Instance().GetWhistle() != ItemState.None)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25470");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25300");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25472");
- }
- StartSequence(numberOfSpeeches);
- }
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechPaige()
- {
- base.SpeechPaige();
- int numberOfSpeeches = 0;
- m_NumPaigeClicks++;
- NewSequence();
- if (PlayerData.Instance().GetWhistle() == ItemState.None && !this.m_PrizeWhistle.activeSelf)
- {
- if (!m_BoolRampClicked)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25405");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25406");
- }
- else
- {
- if (!m_BoolTokenReleaseClicked)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25407");
- }
- else
- {
- string[] possibleSpeehces = {"25268", "25405", "25406", "25407", "25415", "25416", "25417", "25418", "25419", "25420", "25425", "25426", "25410"};
- int index = 4 + m_NumPaigeClicks - 1;
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, possibleSpeehces[index]);
- }
- }
- }
- else if (PlayerData.Instance().GetWhistle() == ItemState.None && this.m_PrizeWhistle.activeSelf)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25425");
- }
- else if (PlayerData.Instance().GetWhistle() != ItemState.None)
- {
- string[] possibleSpeehces = { "25426", "25416", "25417", "25418", "25419", "25420"};
- int index = m_NumPaigeClicks - 1;
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, possibleSpeehces[index]);
- }
- int maxPaigeClicks = 3;
- if (m_CurrentMinigameLevel == 3 && ((PlayerData.Instance().GetWhistle() == ItemState.None && !this.m_PrizeWhistle.activeSelf) || PlayerData.Instance().GetWhistle() != ItemState.None))
- {
- maxPaigeClicks = 6;
- }
- if (m_NumPaigeClicks >= maxPaigeClicks)
- {
- m_NumPaigeClicks = 0;
- }
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnOtherCharacterInteraction()
- {
- base.OnOtherCharacterInteraction();
- int numberOfSpeeches = 0;
- bool seqDone = false;
- m_NumGumClicks++;
- NewSequence();
- if ((PlayerData.Instance().GetWhistle() == ItemState.None && this.m_PrizeWhistle.activeSelf) ||
- (PlayerData.Instance().GetWhistle() != ItemState.None))
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25378");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25380");
- }
- else if(PlayerData.Instance().GetWhistle() == ItemState.None && !this.m_PrizeWhistle.activeSelf)
- {
- if (!m_BoolRampClicked)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25370");
- }
- else
- {
- if (!m_BoolTokenReleaseClicked)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25371");
- }
- else
- {
- if (m_TotalCorrectCount == 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25372");
- }
- else
- {
- seqDone = true;
- }
- }
- }
- if (!m_BoolSentenceClicked)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25373");
- }
- if (seqDone && m_BoolSentenceClicked)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25376");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, "25377");
- }
- }
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- public void OnClickWhistle()
- {
- int numberOfSpeeches = 0;
- NewSequence();
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25152");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25456");
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- public void GetWhistle()
- {
- AudioManager.Instance().PlaySFX("1802");
- int numberOfSpeeches = 0;
- NewSequence();
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.AnimationWithSfx,
- Characters.Sam,
- SAM_WHISTLE_ANIMATION,
- m_CharacterAnimations[(int)Characters.Sam].AnimationCyclesString[SAM_WHISTLE_ANIMATION],
- "25224"); //TODO: confirm sfx
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25571");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, AddWhistleToChest);
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- public void OnClickCandy()
- {
- int numberOfSpeeches = 0;
- m_NumberCandyClicks++;
- NewSequence();
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.AnimationWithSfx,
- Characters.Sam,
- SAM_CANDY_ANIMATION,
- m_CharacterAnimations[(int)Characters.Sam].AnimationCyclesString[SAM_CANDY_ANIMATION],
- "1802"); //TODO: confirm sfx
- if (m_NumberCandyClicks < 4)
- {
- string[] possibleSpeeches = {"25555", "25556", "25557", "25558", "25559", "25560", "25561", "25562", "25563" };
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, possibleSpeeches[m_NumberCandyClicks-1]);
- }
- else
- {
- int randomNumber = Random.Range(1, 4);
- if (randomNumber == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25561");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25562");
- }
- else if (randomNumber == 2)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25559");
- }
- else if (randomNumber == 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "25560");
- }
- else if (randomNumber == 4)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25563");
- }
- }
-
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- private void AddWhistleToChest()
- {
- Chester.Instance().PutItem(ItemEnum.Whistle, this, this.GetChesterPosition().x, this.GetChesterPosition().y);
- }
- //================================================================================
- //
- //================================================================================
- public void OnClickGuider(GumballScienceBallGuider guider)
- {
- this.BoolRampClicked = true;
- if (!guider.Blocked)
- {
- if (m_CurrentClickedGuider == guider)
- {
- m_NumberOfCurGuiderClicks++;
- }
- else
- {
- m_CurrentClickedGuider = guider;
- }
- if (!m_BoolTokenReleaseClicked && m_NumberOfCurGuiderClicks == 3)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25407");
- StartSequence(1);
- m_NumberOfCurGuiderClicks = 0;
- }
- }
- else
- {
- AudioManager.Instance().PlaySFX("25127");
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25410");
- StartSequence(1);
- }
- }
- //================================================================================
- //
- //================================================================================
- public void EnableCandy()
- {
- m_AnimationCandy.SetActive(false);
- m_PrizeCandy.SetActive(true);
- Invoke("LoadNextLevel", 0.5f);
- }
- //================================================================================
- //
- //================================================================================
- public void EnableMarble()
- {
- m_AnimationMarble.SetActive(false);
- //rafael alteration.
- Vector2 gunballPosition = m_GumballMachine.transform.position;
- gunballPosition.x = -134;
- gunballPosition.y = 18;
- m_PrizeMarble.transform.localPosition = gunballPosition;
- m_PrizeMarble.SetActive(true);
- Invoke("LoadNextLevel", 0.5f);
- }
- //================================================================================
- //
- //================================================================================
- public void EnableWhistle()
- {
- m_AnimationWhistle.SetActive(false);
- m_PrizeWhistle.SetActive(true);
- Invoke("LoadNextLevel", 0.5f);
- }
- //================================================================================
- //
- //================================================================================
- public void OnClickMarble()
- {
- if (PlayerData.Instance().GetGreenMarbleCount() == 0)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "25572");
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, m_PrizeMarble.GetComponent<CollectableMarble>().DoAction);
- StartSequence(2);
- }
- else
- {
- m_PrizeMarble.GetComponent<CollectableMarble>().DoAction();
- }
- }
- //================================================================================
- //
- //================================================================================
- public void OnClickWord(string word)
- {
- m_WordClicks++;
- int numberOfSpeeches = 0;
- NewSequence();
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, m_WordsList[word]);
- if (!m_BoolTokenReleaseClicked && m_WordClicks == 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25407");
- m_WordClicks = 0;
- }
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- public void OnClickSentence(string sentence)
- {
- m_WordClicks++;
- int numberOfSpeeches = 0;
- NewSequence();
- int indexOfFirstUnderscore = sentence.IndexOf("_");
- sentence = sentence.Replace("_", "");
- sentence = sentence.Insert(indexOfFirstUnderscore, "_");
- string[] separators = { " " };
- string[] tokenizedSentence = sentence.Split(separators, System.StringSplitOptions.RemoveEmptyEntries);
- string part = "";
- foreach (string token in tokenizedSentence)
- {
- if (token == "_")
- {
- if (part.Length > 0)
- {
- if (part.EndsWith(" "))
- {
- part = part.Remove(part.Length - 1, 1);
- }
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, GetSentencePartSpeechId(part));
- }
- part = "";
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, PlayBlankSFX);
- }
- else
- {
- part += token + " ";
- }
- }
- if (part.Length > 0)
- {
- if (part.EndsWith(" "))
- {
- part = part.Remove(part.Length - 1, 1);
- }
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, GetSentencePartSpeechId(part));
- }
- if (!m_BoolTokenReleaseClicked && m_WordClicks == 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "25407");
- m_WordClicks = 0;
- }
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- public int PlaySentence(string[] sentenceParts, int numberOfSpeeches)
- {
- for (int i = 0; i < sentenceParts.Length; ++i)
- {
- if (sentenceParts[i].StartsWith(" "))
- {
- sentenceParts[i] = sentenceParts[i].Remove(0, 1);
- }
- if (sentenceParts[i].EndsWith(" "))
- {
- sentenceParts[i] = sentenceParts[i].Remove(sentenceParts[i].Length - 1, 1);
- }
- }
- foreach (string part in sentenceParts)
- {
- if (int.Parse(GetSentencePartSpeechId(part)) >= INITIAL_SENTENCE_LIST)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("++++++++++++ " + GetSentencePartSpeechId(part));
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, GetSentencePartSpeechId(part));
- }
- else if (int.Parse(GetSentencePartSpeechId(part + ".")) >= INITIAL_SENTENCE_LIST)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("++++++++++++ ." + GetSentencePartSpeechId(part + "."));
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, GetSentencePartSpeechId(part + "."));
- }
- else if (part.Equals("."))//mycode --rafael. Correct the problem with frases like "A young dog is called a _____"
- {
- numberOfSpeeches++;
- }
- else
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("++++++++++++ " + part);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Gum, m_WordsList[part]);
- }
- }
- return numberOfSpeeches;
- }
- //================================================================================
- //
- //================================================================================
- private void PlayBlankSFX()
- {
- AudioManager.Instance().PlaySFX("25999");
- }
- //================================================================================
- //
- //================================================================================
- public string GetSentencePartSpeechId(string sentencePart)
- {
- int partId = INITIAL_SENTENCE_LIST + m_SentencesList.IndexOf(sentencePart) - 1;
- return partId.ToString();
- }
- //================================================================================
- //
- //================================================================================
- public int CurrentMinigameLevel
- {
- get { return m_CurrentMinigameLevel; }
- }
- //================================================================================
- //
- //================================================================================
- public bool BoolRampClicked
- {
- get { return m_BoolRampClicked; }
- set { m_BoolRampClicked = value; }
- }
- //================================================================================
- //
- //================================================================================
- public bool BoolTokenReleaseClicked
- {
- get { return m_BoolTokenReleaseClicked; }
- set { m_BoolTokenReleaseClicked = value; }
- }
- //================================================================================
- //
- //================================================================================
- public bool BoolSentenceClicked
- {
- get { return m_BoolSentenceClicked; }
- set { m_BoolSentenceClicked = value; }
- }
- } // public class SceneGumballScience : SceneCommon
- } // namespace ReaderRabbit
|