123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924 |
- //================================================================================
- //
- //================================================================================
- using UnityEngine;
- using System.Collections;
- using SimpleJSON;
- //================================================================================
- //
- //================================================================================
- namespace ReaderRabbit
- {
- //================================================================================
- //
- //================================================================================
- public class SceneRaingearForestMath : SceneCommon
- {
- //================================================================================
- //
- //================================================================================
- private enum Characters
- {
- Reader = CharactersCommon.Reader,
- Sam = CharactersCommon.Sam,
- Paige = CharactersCommon.Paige,
- Chester = CharactersCommon.Chester,
- Squirrel = CharactersCommon.StartSceneSpecific,
- Tree,
- }
- //================================================================================
- //
- //================================================================================
- private const int SAM_EAT_ANIMATION = (int)SamAnimation.AnimationCycles.Misc1 + 1;
- private const int WORD_LIST_1_SIZE = 11;
- private const int WORD_LIST_2_SIZE = 12;
- private const int WORD_LIST_3_SIZE = 16;
-
- 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_MARBLE = 3;
- public int INITIAL_NUMBER_SPEECH_ID = 0;
- public int NUMBER_ZERO_SPEECH_ID = 0;
- public int OP_PLUS_SPEECH_ID = 0;
- public int OP_MINUS_SPEECH_ID = 0;
- public int OP_EQUAL_SPEECH_ID = 0;
- /*private const int INITIAL_NUMBER_SPEECH_ID = 2748;
- private const int NUMBER_ZERO_SPEECH_ID = 2867;
- private const int OP_PLUS_SPEECH_ID = 18170;
- private const int OP_MINUS_SPEECH_ID = 18171;
- private const int OP_EQUAL_SPEECH_ID = 18172;*/
- //================================================================================
- //
- //================================================================================
- private enum SpeechEquationState
- {
- None = 0,
- MustReadRight,
- MustGetNextTree,
- }
- //================================================================================
- //
- //================================================================================
- [SerializeField] private CollectableMarble m_Marble;
- [SerializeField] private PrizeNut m_PrizeNut;
- [SerializeField] private TreeManager m_TreeManager;
- [SerializeField] private BoxCollider2D m_ScreenBlocker;
- private int m_CurrentMinigameLevel;
- private int m_CurrentWordList;
- private int m_WinsCount;
- private bool m_DidHearSubtractionInstructions;
- private bool m_NutClicked;
- private int m_SquirrelClickCount;
- private bool m_HeardCorrectLeft;
- private bool m_HeardCorrectRight;
- private bool m_IsFirstPlayAfterEntry;
- private SpeechEquationState m_SpeechEquationState;
- //================================================================================
- //
- //================================================================================
- protected override void Start()
- {
- base.Start();
- //============================================================================
- //
- //============================================================================
- int lang = PlayerPrefs.GetInt("language");
- if (lang == 0)
- m_SpeechFolder = "Resources_DA/Audio/RaingearForestMath_Speech";
- else if (lang == 1)
- m_SpeechFolder = "Resources_EN/Audio/RaingearForestMath_Speech";
- else if (lang == 2)
- m_SpeechFolder = "Resources_NO/Audio/RaingearForestMath_Speech";
- else if (lang == 3)
- m_SpeechFolder = "Resources_SP/Audio/RaingearForestMath_Speech";
- else if (lang == 4)
- m_SpeechFolder = "Resources_SW/Audio/RaingearForestMath_Speech";
- //============================================================================
- //
- //============================================================================
- PlayerData.Instance().SetVisitedRaingearForestMath(true);
- PlayerData.Instance().SetCurrentLocation(Location.RaingearForestMath);
- PlayerData.Instance().UnlockActivity(Activity.RaingearForestMath);
- AudioManager.Instance().PlayBGM("BGM_RaingearForestMath");
-
- this.m_CurrentMinigameLevel = PlayerData.Instance().GetActivityLevel(Activity.RaingearForestMath);
- this.m_CurrentWordList = 0;
-
- m_Marble.SetParentScene(this);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_Marble.gameObject, false);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_PrizeNut.gameObject);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_CharacterAnimations[(int)Characters.Tree].gameObject);
- m_IsFirstPlayAfterEntry = true;
- Invoke("LoadNextLevel", 0.01f);
- Invoke("EnableInput", 0.1f);
-
- m_WinsCount = 0;
- m_DidHearSubtractionInstructions = false;
- m_NutClicked = false;
- m_SquirrelClickCount = 0;
- m_HeardCorrectLeft = false;
- m_HeardCorrectRight = false;
- m_SpeechEquationState = SpeechEquationState.None;
- }
- //================================================================================
- //
- //================================================================================
- private void LoadNextLevel()
- {
- TextAsset jsonText = Resources.Load<TextAsset>("Resources_EN/RaingearForestMath/r1ia1");
- JSONNode json = JSONNode.Parse(jsonText.text);
-
- JSONNode currentLevelWordLists = json["DataSet"]["Level_"+m_CurrentMinigameLevel];
- int wordListSize = GetCurrentWordListSize();
-
- m_CurrentWordList++;
-
- if (m_CurrentWordList >= wordListSize) //if (m_CurrentWordList > wordListSize)
- {
- m_CurrentWordList = 1;
-
- //Updates mini-game's next level
- if (m_CurrentWordList < wordListSize && !PlayerData.Instance().IsActivityLocked(Activity.RaingearForestMath)) //if (m_CurrentWordList > wordListSize && !PlayerData.Instance().IsActivityLocked(Activity.RaingearForestMath))
- {
- m_CurrentMinigameLevel++;
-
- if (m_CurrentMinigameLevel > wordListSize)
- {
- m_CurrentMinigameLevel = NUMBER_OF_MINIGAME_LEVELS;
- }
-
- PlayerData.Instance().SetActivityLevel(Activity.RaingearForestMath, m_CurrentMinigameLevel);
- }
- }
-
-
- //Get a random word list set
- JSONNode selectedWordList = currentLevelWordLists["WordList_" + m_CurrentWordList];
- JSONNode wordListSet = selectedWordList["Set_" + Random.Range(1, 4)];
-
- this.m_TreeManager.Reset();
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Set: " + wordListSet.Value);
- m_TreeManager.ReleaseBox(true);
- SetupBoxes(wordListSet);
- DoResetSpeech();
- }
- //================================================================================
- //
- //================================================================================
- private void SetupBoxes(JSONNode wordListSet)
- {
- char[] tokensSeparators = {' '};
- string[] tokens = wordListSet.Value.Split(tokensSeparators, System.StringSplitOptions.RemoveEmptyEntries);
-
- m_TreeManager.SetupBoxes(tokens);
- }
- //================================================================================
- //
- //================================================================================
- 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_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 EnableInput()
- {
- m_ScreenBlocker.enabled = false;
- }
-
- //================================================================================
- //
- //================================================================================
- public void DisableInput()
- {
- m_ScreenBlocker.enabled = true;
- }
-
- //================================================================================
- //
- //================================================================================
- public void GivePrize()
- {
- DisableInput();
- // Play kCorrectSFX.
- AudioManager.Instance().PlaySFX("18310");
- string[] possibleNumbers = { "18300", "18301", "18302", "18303", "18304" };
- int sequence = 0;
- NewSequence();
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, possibleNumbers[Random.Range(0, possibleNumbers.Length)]);
- if (!PlayerData.Instance().IsPracticeMode())
- {
- ++PlayerData.Instance().RFM_RoundsCompleted;
- ++m_WinsCount;
- if (m_WinsCount == NUMBER_OF_WINS_TO_GIVE_MARBLE)
- {
- if (m_Marble.IsEnabled())
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18313");
- }
- else
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18312");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, GiveMarble);
- }
- }
- else
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18311");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, GiveNut);
- }
- }
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, ReadBothEquations);
- StartSequence(sequence);
- }
- //================================================================================
- //
- //================================================================================
- private void ReadBothEquations()
- {
- Invoke("ReadBothEquationsDelayed", 0.1f);
- }
- //================================================================================
- //
- //================================================================================
- private void ReadBothEquationsDelayed()
- {
- m_SpeechEquationState = SpeechEquationState.MustReadRight;
- SpeechEquation(true);
- }
- //================================================================================
- //
- //================================================================================
- private void GetNextTree()
- {
- Invoke("GetNextTreeDelayed", 0.1f);
- }
- //================================================================================
- //
- //================================================================================
- private void GetNextTreeDelayed()
- {
- int sequence = 0;
- NewSequence();
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18315");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, PrepareTreeAnimation);
- SetSequence(sequence++,
- EventSequenceItem.EventSequenceType.Animation,
- Characters.Tree,
- 1,
- m_CharacterAnimations[(int)Characters.Tree].AnimationCyclesString[1]);
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, FinishTreeAnimation);
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, LoadNextLevel);
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, EnableInput);
- StartSequence(sequence);
- }
- //================================================================================
- //
- //================================================================================
- private void PrepareTreeAnimation()
- {
- m_TreeManager.gameObject.SetActive(false);
- m_CharacterAnimations[(int)Characters.Tree].gameObject.SetActive(true);
- }
- //================================================================================
- //
- //================================================================================
- private void FinishTreeAnimation()
- {
- m_TreeManager.gameObject.SetActive(true);
- m_CharacterAnimations[(int)Characters.Tree].gameObject.SetActive(false);
- }
- //================================================================================
- //
- //================================================================================
- private void GiveMarble()
- {
- // TODO: Play kMarbleSFX and marble animation.
- m_Marble.gameObject.SetActive(true);
- m_Marble.Enable();
- m_WinsCount = 0;
- }
- //================================================================================
- //
- //================================================================================
- private void GiveNut()
- {
- m_PrizeNut.gameObject.SetActive(true);
- m_PrizeNut.isCollected = false;
- m_PrizeNut.Enable();
- }
- //================================================================================
- //
- //================================================================================
- public void OnMouseDown()
- {
- m_TreeManager.ReturnBoxToBranch();
- }
- //================================================================================
- //
- //================================================================================
- protected override void PlayFirstEvent()
- {
- if (!PlayerData.Instance().IsPracticeMode())
- {
- if (m_IsFirstTime)
- {
- int sequence = 0;
- NewSequence();
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18303");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18454");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "18455");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18456");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18457");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "18458");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18471");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18472");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, m_TreeManager.AnimateLeftBranchUp);
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, m_TreeManager.AnimateRightBranchUp);
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18460");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "18461");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, CheckIfSubtraction);
- StartSequence(sequence);
- }
- else
- {
- int sequence = 0;
- NewSequence();
- string[] possibleNumbers = { "18250", "18251", "18252" };
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, possibleNumbers[Random.Range(0, possibleNumbers.Length)]);
- // Play the following sequence 50% of the time.
- int randomValue = Random.Range(0, 100);
- if (randomValue < 50)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "18260");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "18261");
- }
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, CheckIfSubtraction);
- StartSequence(sequence);
- }
- }
- else
- {
- SquirrelSpeech(true);
- }
- }
- //================================================================================
- //
- //================================================================================
- private void CheckIfSubtraction()
- {
- if (!m_TreeManager.CurrentOperationIsSum)
- {
- Invoke("DoSubtractionSpeech", 0.1f);
- }
- }
- //================================================================================
- //
- //================================================================================
- private void DoSubtractionSpeech()
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18340");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18341");
- // Subtraction speech is non-interruptible for the first subtraction problem per entry.
- StartSequence(2, m_DidHearSubtractionInstructions);
- m_DidHearSubtractionInstructions = true;
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnNavigation()
- {
- string[] bye1 = { "18104", "18105" };
- string[] bye2 = { "18106", "18107", "18108" };
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, bye1[Random.Range(0, bye1.Length)]);
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, bye2[Random.Range(0, bye2.Length)]);
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, base.OnNavigation);
- StartSequence(3);
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnIdle()
- {
- NewSequence();
- int randomValue = Random.Range(0, 150);
- if (randomValue < 50)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18400");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18402");
- StartSequence(2);
- }
- else if (randomValue < 100)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18403");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18404");
- StartSequence(2);
- }
- else
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "18405");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "18406");
- StartSequence(2);
- }
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechReader()
- {
- NewSequence();
- int randomValue = Random.Range(0, 200);
- if (randomValue < 50)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "18405");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "18406");
- StartSequence(2);
- }
- else if (randomValue < 100)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "18555");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18403");
- SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18404");
- StartSequence(3);
- }
- else if (randomValue < 150)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "18560");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18561");
- SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18337");
- StartSequence(3);
- }
- else
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "18570");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18571");
- StartSequence(2);
- }
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechPaige()
- {
- string[] possibleNumbers = { "18501", "18502", "18503", "18504", "18505", "18506" };
-
- int randomValue = Random.Range(0, m_TreeManager.CurrentOperationIsSum ? possibleNumbers.Length - 1: possibleNumbers.Length);
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, possibleNumbers[randomValue]);
- StartSequence(1);
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnOtherCharacterInteraction()
- {
- if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "Squirrel")
- SquirrelSpeech(false);
- else if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "Target")
- SpeechTarget();
- else if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "Equation1")
- {
- m_SpeechEquationState = SpeechEquationState.None;
- SpeechEquation(true);
- }
- else if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "Equation2")
- {
- m_SpeechEquationState = SpeechEquationState.None;
- SpeechEquation(false);
- }
- }
- //================================================================================
- //
- //================================================================================
- private void SquirrelSpeech(bool fromPlayFirstEvent)
- {
- string[] possibleNumbers = { "18470", "18471", "18472", "18473", "18474" };
- int sequence = 0;
- NewSequence();
- int randomValue = Random.Range(0, 100);
- if (randomValue < 50)
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, possibleNumbers[0]);
- int tempSpeechIndex = m_SquirrelClickCount + 1;
- if (m_CurrentMinigameLevel > 1)
- {
- if (tempSpeechIndex == 1)
- {
- ++m_SquirrelClickCount;
- tempSpeechIndex = m_SquirrelClickCount + 1;
- }
- }
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, possibleNumbers[tempSpeechIndex]);
- if (fromPlayFirstEvent)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, CheckIfSubtraction);
- }
- StartSequence(sequence);
- ++m_SquirrelClickCount;
- if (PlayerData.Instance().IsPracticeMode())
- {
- if (m_SquirrelClickCount == 2)
- m_SquirrelClickCount = 0;
- }
- else
- {
- if (m_SquirrelClickCount == 3)
- m_SquirrelClickCount = 0;
- }
- }
- //================================================================================
- //
- //================================================================================
- private void SpeechTarget()
- {
- int speechId = (INITIAL_NUMBER_SPEECH_ID + m_TreeManager.ExpectedResult) - 1;
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, speechId.ToString());
- StartSequence(1);
- }
- //================================================================================
- //
- //================================================================================
- private void SpeechEquation(bool isLeftEquation)
- {
- int sequence = 0;
- NewSequence();
- int number1 = (INITIAL_NUMBER_SPEECH_ID + m_TreeManager.GetEquationValue(isLeftEquation, 1)) - 1;
- int number2 = (INITIAL_NUMBER_SPEECH_ID + m_TreeManager.GetEquationValue(isLeftEquation, 2)) - 1;
- int number3 = (INITIAL_NUMBER_SPEECH_ID + m_TreeManager.GetEquationValue(isLeftEquation, 3)) - 1;
- int total = (INITIAL_NUMBER_SPEECH_ID + m_TreeManager.GetEquationValue(isLeftEquation, 4)) - 1;
- if (m_TreeManager.GetEquationValue(isLeftEquation, 1) == 0)
- number1 = NUMBER_ZERO_SPEECH_ID;
- if (m_TreeManager.GetEquationValue(isLeftEquation, 2) == 0)
- number2 = NUMBER_ZERO_SPEECH_ID;
- if (m_TreeManager.GetEquationValue(isLeftEquation, 3) == 0)
- number3 = NUMBER_ZERO_SPEECH_ID;
- if (m_TreeManager.GetEquationValue(isLeftEquation, 4) == 0)
- total = NUMBER_ZERO_SPEECH_ID;
- if (m_TreeManager.CurrentOperationIsSum)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, number1.ToString());
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, OP_PLUS_SPEECH_ID.ToString());
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, number2.ToString());
- // Level 1 has hidden values (uses only two boxes, not three).
- if (!m_TreeManager.IsSmallOperation)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, OP_PLUS_SPEECH_ID.ToString());
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, number3.ToString());
- }
-
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, OP_EQUAL_SPEECH_ID.ToString());
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, total.ToString());
- }
- else
- {
- // If second slot is empty ("_") then play kBlankSFX (18173).
- if (m_TreeManager.GetEquationValue(isLeftEquation, 2) == -1)
- number2 = 18173;
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, number1.ToString());
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, OP_MINUS_SPEECH_ID.ToString());
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, number2.ToString());
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, OP_EQUAL_SPEECH_ID.ToString());
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, total.ToString());
- }
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, SpeechEquationFinished);
- StartSequence(sequence);
- }
- //================================================================================
- //
- //================================================================================
- private void SpeechEquationFinished()
- {
- Invoke("SpeechEquationFinishedDelayed", 0.1f);
- }
- //================================================================================
- //
- //================================================================================
- private void SpeechEquationFinishedDelayed()
- {
- switch (m_SpeechEquationState)
- {
- case SpeechEquationState.None:
- break;
- case SpeechEquationState.MustReadRight:
- m_SpeechEquationState = SpeechEquationState.MustGetNextTree;
- SpeechEquation(false);
- break;
- case SpeechEquationState.MustGetNextTree:
- m_SpeechEquationState = SpeechEquationState.None;
- GetNextTree();
- break;
- }
- }
- //================================================================================
- //
- //================================================================================
- public void GetMarble()
- {
- // Play kCOMPickUpSfxID.
- AudioManager.Instance().PlaySFX("1802");
-
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "18600");
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, m_Marble.DoAction);
- if (m_Marble.IsEnabled()){
- m_Marble.SetEnable(false);
-
- }
- StartSequence(2);
- }
- //================================================================================
- //
- //================================================================================
- public void GetNut()
- {
- // Play kCOMPickUpSfxID.
- AudioManager.Instance().PlaySFX("1802");
- int sequence = 0;
- NewSequence();
- if (!m_NutClicked)
- {
- m_NutClicked = true;
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18615");
- }
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, m_PrizeNut.DoAction);
- SetSequence(sequence++,
- EventSequenceItem.EventSequenceType.Animation,
- Characters.Sam,
- SAM_EAT_ANIMATION,
- m_CharacterAnimations[(int)Characters.Sam].AnimationCyclesString[SAM_EAT_ANIMATION]);
- string[] possibleNumbers = { "18611", "18612", "18613", "18614" };
- int randomValue = Random.Range(0, possibleNumbers.Length);
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, possibleNumbers[randomValue]);
- StartSequence(sequence);
- }
- //================================================================================
- //
- //================================================================================
- public void ResetCorrectFeedbackFlag(bool isLeftBranch)
- {
- if (isLeftBranch)
- m_HeardCorrectLeft = false;
- else
- m_HeardCorrectRight = false;
- }
- //================================================================================
- //
- //================================================================================
- public void FeedbackIfCorrect(bool isLeftBranch, int value)
- {
- if (value == m_TreeManager.ExpectedResult)
- {
- if (isLeftBranch && !m_HeardCorrectLeft)
- {
- m_HeardCorrectLeft = true;
- AudioManager.Instance().PlaySFX("18310");
- }
- else if (!isLeftBranch && !m_HeardCorrectRight)
- {
- m_HeardCorrectRight = true;
- AudioManager.Instance().PlaySFX("18310");
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- public void FeedbackIfIncorrect(bool isLeftBranch, int value, int boxCount)
- {
- if (m_TreeManager.CurrentOperationIsSum)
- {
- // Only give feedback if there is enough boxes on branches (based on current level).
- if (boxCount >= m_CurrentMinigameLevel)
- {
- if (value > m_TreeManager.ExpectedResult)
- {
- // Play kWrongSfxID.
- AudioManager.Instance().PlaySFX("18374");
- NewSequence();
- // Heavy speeches 50%.
- int randomValue = Random.Range(0, 100);
- if (randomValue < 50)
- {
- randomValue = Random.Range(0, 100);
- if (randomValue < 50)
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18350");
- else
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18351");
- StartSequence(1);
- }
- }
- else if (value < m_TreeManager.ExpectedResult)
- {
- // Play kWrongSfxID.
- AudioManager.Instance().PlaySFX("18374");
- NewSequence();
- // Light speeches 50%.
- int randomValue = Random.Range(0, 100);
- if (randomValue < 50)
- {
- randomValue = Random.Range(0, 100);
- if (randomValue < 50)
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18360");
- else
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18361");
- StartSequence(1);
- }
- }
- }
- }
- else
- {
- if (value != m_TreeManager.ExpectedResult)
- {
- // Play kWrongSfxID.
- AudioManager.Instance().PlaySFX("18374");
- string[] possibleNumbers = { "18370", "18371", "18372", "18373" };
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, possibleNumbers[Random.Range(0, possibleNumbers.Length)]);
- //SetSequence(1, EventSequenceItem.EventSequenceType.Callback, m_TreeManager.ReturnBoxToBranch);
- // Wait for a brief moment and then put the basket back in the tree.
- // This is done already!
- StartSequence(1);
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- private void DoResetSpeech()
- {
- // Do not play this sfx the first time.
- if (!m_IsFirstPlayAfterEntry)
- AudioManager.Instance().PlaySFX("18345");
- else
- m_IsFirstPlayAfterEntry = false;
- int sequence = 0;
- NewSequence();
- if (PlayerData.Instance().RFM_RoundsCompleted < 7)
- {
- string[] possibleNumbers = { "18325", "18326", "18327", "18328" };
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, possibleNumbers[Random.Range(0, possibleNumbers.Length)]);
- }
- if (PlayerData.Instance().RFM_RoundsCompleted == 1)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "18330");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18331");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18332");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18333");
- }
- else if (PlayerData.Instance().RFM_RoundsCompleted == 2)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "18335");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18336");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Squirrel, "18337");
- }
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, CheckIfSubtraction);
- StartSequence(sequence);
- }
- } // public class SceneRaingearForestMath : SceneCommon
- } // namespace ReaderRabbit
|