123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776 |
- //================================================================================
- //
- //================================================================================
- using UnityEngine;
- using System.Collections;
- using SimpleJSON;
- using System.Collections.Generic;
- using System;
- //================================================================================
- //
- //================================================================================
- namespace ReaderRabbit
- {
- //================================================================================
- //
- //================================================================================
- public class SceneCloudSpellingChallenge : SceneCommon
- {
- //================================================================================
- //
- //================================================================================
- private enum Characters
- {
- Reader = CharactersCommon.Reader,
- Sam = CharactersCommon.Sam,
- Paige = CharactersCommon.Paige,
- Chester = CharactersCommon.Chester,
- WallyOnLadder = CharactersCommon.StartSceneSpecific,
- WallyStanding
- }
- //================================================================================
- //
- //================================================================================
- private const int WORD_LIST_1_SIZE = 16;
- private const int WORD_LIST_2_SIZE = 20;
- private const int WORD_LIST_3_SIZE = 42;
- private const int WORD_LIST_NON_PRACTICE_SIZE = 3;
- private const int NUMBER_OF_MINIGAME_LEVELS = 3;
- //================================================================================
- //
- //================================================================================
- [SerializeField]
- private CollectableMarble m_Marble;
- [SerializeField]
- private CloudSpellingPhonemesArea m_PhonemesArea;
- [SerializeField]
- private CloudSpellingTreadmillController m_TreadmillController;
- [SerializeField]
- private List<CloudSpellingChallengeObjectsCloud> m_ObjectsClouds;
- [SerializeField]
- private List<CloudSpellingPhonemesRecipient> m_Recipients;
- [SerializeField]
- private Animator m_CloudGuyOnLadder;
- [SerializeField]
- private PrizeLadder m_PrizeLadder;
- [SerializeField]
- private List<GameObject> m_DeliveredClouds;
- private int m_CurrentMinigameLevel;
- private int m_CurrentWordList;
- private int m_WinsCount;
- private Treadmill m_CurrentTreadmill;
- private List<CloudSpellingWordDescription> m_CurrentWordDescriptions;
- private CloudSpellingPhonemesRecipient m_CurrentRecipient;
- private List<CloudSpellingPhonemeBox> m_FreeBoxes;
- private int m_CurrentReaderSamInteractionSpeech = 0;
- private int m_CurrentPaigeInteractionSpeech = 0;
- private int m_CurrentWallyOnLadderInteractionSpeech = 0;
- private Dictionary<string, string> m_PhonemeToSoundMap;
- private Characters m_CurrentActiveWally;
- private int lang;
- public GameObject WallyGOStanding; //mycode --rafael
- //================================================================================
- //
- //================================================================================
- protected override void Start()
- {
- base.Start();
- //============================================================================
- //
- //============================================================================
- lang = PlayerPrefs.GetInt("language");
- if (lang == 0)
- m_SpeechFolder = "Resources_DA/Audio/CloudSpellingChallenge_Speech";
- else if (lang == 1)
- m_SpeechFolder = "Resources_EN/Audio/CloudSpellingChallenge_Speech";
- else if (lang == 2)
- m_SpeechFolder = "Resources_NO/Audio/CloudSpellingChallenge_Speech";
- else if (lang == 3)
- m_SpeechFolder = "Resources_SP/Audio/CloudSpellingChallenge_Speech";
- else if (lang == 4)
- m_SpeechFolder = "Resources_SW/Audio/CloudSpellingChallenge_Speech";
-
- //============================================================================
- //
- //============================================================================
- InitPhonemeSoundMap();
- PlayerData.Instance().SetVisitedCloudSpellingChallenge(true);
- PlayerData.Instance().SetCurrentLocation(Location.CloudSpellingChallenge);
- PlayerData.Instance().UnlockActivity(Activity.CloudSpellingChallenge);
- AudioManager.Instance().PlayBGM("BGM_CloudSpellingChallenge");
- this.m_CurrentMinigameLevel = PlayerData.Instance().GetActivityLevel(Activity.CloudSpellingChallenge) - 1;
- m_Marble.SetParentScene(this);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_Marble.gameObject, false);
- //KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_PrizeLadder.gameObject);
- m_FreeBoxes = new List<CloudSpellingPhonemeBox>();
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_CloudGuyOnLadder.gameObject);
- if (PlayerData.Instance().IsPracticeMode() || PlayerData.Instance().GetLadder() != ItemState.None)
- {
- m_PrizeLadder.gameObject.SetActive(false);
- }
-
- //m_WinsCount = 0;
- CheckAmountOfWins ();
- Invoke("UpdateSizesAndPositions", 0.005f);
- //m_PrizeLadder.DisableClick();
- m_PrizeLadder.SetParentScene(this);
- m_CurrentTreadmill = Treadmill.INVALID_TREADMILL;
- }
- void CheckAmountOfWins (){
- if (PlayerData.Instance ().CSC_WinsCount != 0 && !PlayerData.Instance().IsPracticeMode()) { //mycode --rafael -->original above commented.
- m_WinsCount = PlayerData.Instance ().CSC_WinsCount;
- } else {
- m_WinsCount = 0;
- }
- if (m_WinsCount >= 3) {
- m_PrizeLadder.EnableClick ();
- } else {
- m_PrizeLadder.DisableClick();
- }
- }
- //================================================================================
- //
- //================================================================================
- protected override void PlayFirstEvent()
- {
- if (!PlayerData.Instance().IsPracticeMode())
- {
- if (m_IsFirstTime)
- {
- PlayFirstDialogueFlow();
- }
- else
- {
- PlayWallyRandomWelcomeBackPhrase();
- }
- }
- else
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.WallyStanding, "10182");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.WallyStanding, "10185");
- SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.WallyStanding, "10356");
- SetSequence(3, EventSequenceItem.EventSequenceType.Callback, InvokeLoadNextLevelDelayed);
- SetSequence(4, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(5);
- }
- }
- //================================================================================
- //
- //================================================================================
- private void UpdateSizesAndPositions()
- {
- foreach (GameObject go in m_DeliveredClouds)
- {
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(go);
- }
- if (m_WinsCount < 3 && !PlayerData.Instance().IsPracticeMode()) //mycode --rafael --> original --> if (PlayerData.Instance().GetLadder() == ItemState.None && !PlayerData.Instance().IsPracticeMode())
- {
- m_CharacterAnimations[(int)Characters.WallyOnLadder].gameObject.SetActive(true);
- m_CharacterAnimations[(int)Characters.WallyStanding].gameObject.SetActive(false);
- m_OtherCharacterRectangles[0].gameObject.SetActive(true);
- m_OtherCharacterRectangles[1].gameObject.SetActive(false);
- m_CurrentActiveWally = Characters.WallyOnLadder;
- }
- else if (m_WinsCount >= 3 || PlayerData.Instance().IsPracticeMode()) //mycode --rafael --> original --> else if (PlayerData.Instance().IsPracticeMode() || PlayerData.Instance().GetLadder() != ItemState.None)
- {
- m_CharacterAnimations[(int)Characters.WallyOnLadder].gameObject.SetActive(false);
- m_CharacterAnimations[(int)Characters.WallyStanding].gameObject.SetActive(true);
- m_OtherCharacterRectangles[0].gameObject.SetActive(false);
- m_OtherCharacterRectangles[1].gameObject.SetActive(true);
- m_CurrentActiveWally = Characters.WallyStanding;
- }
- }
- //================================================================================
- //
- //================================================================================
- public void LoadNextLevel()
- {
- //Updates mini-game's next level
- if (!PlayerData.Instance().IsActivityLocked(Activity.CloudSpellingChallenge))
- {
- m_CurrentMinigameLevel++;
- if (m_CurrentMinigameLevel > NUMBER_OF_MINIGAME_LEVELS)
- {
- m_CurrentMinigameLevel = NUMBER_OF_MINIGAME_LEVELS;
- }
- PlayerData.Instance().SetActivityLevel(Activity.CloudSpellingChallenge, m_CurrentMinigameLevel);
- }
- //Get a random word list set
- List<JSONNode> words = GetWords();
- m_CurrentWordDescriptions = new List<CloudSpellingWordDescription>();
- m_CurrentWordDescriptions.Add(new CloudSpellingWordDescription(words[0].Value));
- m_CurrentWordDescriptions.Add(new CloudSpellingWordDescription(words[1].Value));
- m_CurrentWordDescriptions.Add(new CloudSpellingWordDescription(words[2].Value));
- m_PhonemesArea.Setup(m_CurrentWordDescriptions[0].AvailableParts);
- ShowNextWord(((Treadmill)m_CurrentTreadmill + 1));
- }
- //================================================================================
- //
- //================================================================================
- public void InitNextLevel()
- {
- m_CurrentWordDescriptions.Clear();
- AudioManager.Instance().PlaySFX("10280");
- if (m_FreeBoxes != null)
- {
- foreach (CloudSpellingPhonemeBox box in m_FreeBoxes)
- {
- if (box != null)
- {
- GameObject.Destroy(box.gameObject);
- }
- }
- }
- m_FreeBoxes.Clear();
- m_PhonemesArea.Reset();
- foreach (CloudSpellingPhonemesRecipient r in m_Recipients)
- {
- r.Reset();
- }
- foreach (CloudSpellingChallengeObjectsCloud cloud in m_ObjectsClouds)
- {
- cloud.HideCurrentObject();
- foreach (Transform children in cloud.transform){
- if (children.gameObject.name == "Images"){
- children.gameObject.transform.localPosition = cloud.transform.position;
- }
- }
- }
- m_TreadmillController.Reset();
- m_CurrentTreadmill = Treadmill.INVALID_TREADMILL;
- LoadNextLevel();
- }
- //================================================================================
- //
- //================================================================================
- private List<JSONNode> GetWords()
- {
- TextAsset jsonText;
- jsonText = null;
- if(lang == 0) jsonText = Resources.Load<TextAsset>("Resources_DA/CloudSpellingChallenge/r1ca1");
- else if (lang == 1) jsonText = Resources.Load<TextAsset>("Resources_EN/CloudSpellingChallenge/r1ca1");
- else if (lang == 2) jsonText = Resources.Load<TextAsset>("Resources_NO/CloudSpellingChallenge/r1ca1");
- else if (lang == 3) jsonText = Resources.Load<TextAsset>("Resources_SP/CloudSpellingChallenge/r1ca1");
- else if (lang == 4) jsonText = Resources.Load<TextAsset>("Resources_SW/CloudSpellingChallenge/r1ca1");
- JSONNode json = JSONNode.Parse(jsonText.text);
- JSONNode currentLevelWordLists = json["DataSet"]["Level_" + m_CurrentMinigameLevel];
- int amountOfWordList = currentLevelWordLists.Count; //mycode --rafael --> use this and not the constatants in this script. This will help in localization.
- List<JSONNode> result = new List<JSONNode>();
- int currentListSize = amountOfWordList; //mycode --rafael --> original --> int currentListSize = GetCurrentWordListSize();
- currentListSize--;
- int randomIndex = UnityEngine.Random.Range(1, currentListSize);
- for (int i = 0; i < 3; ++i)
- {
- if (m_CurrentMinigameLevel == 3)
- {
- result.Add(currentLevelWordLists["WordList_" + (randomIndex + i)]["Set_1"]);
- }
- else
- {
- result.Add(currentLevelWordLists["WordList_" + (randomIndex + i)]["Set_" + UnityEngine.Random.Range(1, 4)]);
- }
- }
- return result;
- }
- //================================================================================
- //
- //================================================================================
- private int GetCurrentWordListSize()
- {
- int wordListSize = 0;
- //Check number of word lists
- /*if (!PlayerData.Instance().IsPracticeMode() &&
- !PlayerData.Instance().IsActivityLocked(Activity.CloudSpellingChallenge) &&
- PlayerData.Instance().GetLadder() == ItemState.None)
- {
- return WORD_LIST_NON_PRACTICE_SIZE;
- }*/
- if (!PlayerData.Instance().IsPracticeMode() && //mycode --rafael. Original commented above.
- !PlayerData.Instance().IsActivityLocked(Activity.CloudSpellingChallenge) &&
- m_WinsCount < 3)
- {
- return WORD_LIST_NON_PRACTICE_SIZE;
- }
- if (m_CurrentMinigameLevel == 1)
- {
- 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 ShowNextWord(Treadmill treadmill)
- {
- if (treadmill != m_CurrentTreadmill)
- {
- m_CurrentTreadmill = treadmill;
- m_TreadmillController.Setup(m_CurrentWordDescriptions[(int)treadmill], treadmill);
- m_PhonemesArea.Setup(m_CurrentWordDescriptions[(int)treadmill].AvailableParts);
- m_ObjectsClouds[(int)treadmill].ShowObject(m_CurrentWordDescriptions[(int)treadmill].CorrectWord);
- m_CurrentRecipient = m_Recipients[(int)treadmill];
- m_PhonemesArea.EnableDrag();
- }
- PlayLetterOrWordSound(m_CurrentWordDescriptions[(int)treadmill].CorrectWord);
- }
- //================================================================================
- //
- //================================================================================
- public CloudSpellingPhonemeBox IsMouseOverCurrentRecipient()
- {
- return m_CurrentRecipient.IsMouseOverBox();
- }
-
- //================================================================================
- //
- //================================================================================
- public void AddPhonemeBoxToRecipient(CloudSpellingPhonemeBox boxToAdd, CloudSpellingPhonemeBox destiny)
- {
- m_CurrentRecipient.AddMovablePhonemeBox(boxToAdd, destiny);
- }
-
- //================================================================================
- //
- //================================================================================
- public void RemovePhonemeBoxFromRecipient(CloudSpellingPhonemeBox boxToRemove)
- {
- m_CurrentRecipient.RemoveMovablePhonemeBox(boxToRemove);
- }
- //================================================================================
- //
- //================================================================================
- public bool IsCurrentRecipientAnswerCorrect()
- {
- if (m_CurrentTreadmill == Treadmill.INVALID_TREADMILL)
- {
- return false;
- }
- List<CloudSpellingPhonemeBox> phonemes = m_CurrentRecipient.GetCurrentWordPhonemes();
- string correctWord = m_CurrentWordDescriptions[(int)m_CurrentTreadmill].CorrectWord;
- for (int i = 0, j = 0; i < phonemes.Count; ++i)
- {
- int phonemesLength = (phonemes[i].GetText01 == "")? 1 : 2;
- if (correctWord.Substring(j, phonemesLength) != (phonemes[i].GetText00 + phonemes[i].GetText01))
- {
- phonemes[i].RemoveToOriginalPosition();// ReturnToOriginalPosition();
- }
- j += phonemesLength;
- }
- bool result = (m_CurrentRecipient.GetCurrentWord() == m_CurrentWordDescriptions[(int)m_CurrentTreadmill].CorrectWord);
- return result;
- }
- //================================================================================
- //
- //================================================================================
- public bool PlayWrongAnswerSpeech(System.Action callback)
- {
- if (m_PhonemeToSoundMap.ContainsKey(m_CurrentRecipient.GetCurrentWord().ToLower()))
- {
- NewSequence();
- int sequence = 0;
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, m_CurrentActiveWally, m_PhonemeToSoundMap[m_CurrentRecipient.GetCurrentWord().ToLower()]);
- if (UnityEngine.Random.Range(0, 1.0f) > 0.5f)
- {
- float randomCharacter = UnityEngine.Random.Range(0, 1.0f);
- if (randomCharacter > 0.66f)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "10315");
- }
- else if (randomCharacter > 0.33f)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "10316");
- }
- else
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, m_CurrentActiveWally, "10318");
- }
- }
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, callback);
- StartSequence(sequence);
- return true;
- }
- return false;
- }
- //================================================================================
- //
- //================================================================================
- public void OnRightAnswer()
- {
- PlayLetterOrWordSound(m_CurrentRecipient.GetCurrentWord());
- m_FreeBoxes.Add(null);
- this.m_FreeBoxes.AddRange(m_CurrentRecipient.FreeAddedBoxes());
- m_PhonemesArea.DisableDrag();
- }
- //================================================================================
- //
- //================================================================================
- public void RemoveBoxFromPhonemesArea(CloudSpellingPhonemeBox box)
- {
- m_PhonemesArea.RemovePhoneme(box);
- }
- //================================================================================
- //
- //================================================================================
- public void GivePrize()
- {
- //TODO: Play animation
- if (m_WinsCount == 3) //mycode --rafael --> original --> if (m_WinsCount > 2 && PlayerData.Instance().GetLadder() == ItemState.None)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "10228");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.WallyOnLadder, "10235");
- SetSequence(2, EventSequenceItem.EventSequenceType.AnimationWithSfx,
- Characters.WallyOnLadder,
- 3, // Animation index.
- m_CharacterAnimations[(int)Characters.WallyOnLadder].AnimationCyclesString[3],
- "10240");
- SetSequence(3, EventSequenceItem.EventSequenceType.Callback, UpdateEnabledCharacters);
- // TODO: Use WallyStanding once it is added to SceneCode.
- SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.WallyStanding, "10245");
- SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.WallyStanding, "10246");
- SetSequence(6, EventSequenceItem.EventSequenceType.Callback, InitNextLevel);
- StartSequence(7);
- m_PrizeLadder.EnableClick();
- PlayerData.Instance().CSC_WinsCount = m_WinsCount; //mycode --rafael
- PlayerData.Instance().SaveData(); //mycode --rafael
- }
- else if (m_WinsCount > 3) //mycode --rafael --> original --> else if (m_WinsCount > 3 || PlayerData.Instance().GetLadder() != ItemState.None)
- {
- int[] possibleValues = { 0, 1, 2, 5, 6 };
- string sequence = "1026" + possibleValues[UnityEngine.Random.Range(0, possibleValues.Length)];
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.WallyStanding, sequence);
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, InitNextLevel);
- StartSequence(2);
- m_Marble.gameObject.SetActive(true);
- PlayerData.Instance().CSC_WinsCount = m_WinsCount; //mycode --rafael
- PlayerData.Instance().SaveData(); //mycode --rafael
- }
- else
- {
- InitNextLevel();
- }
- }
- void CanCollectLadder(){ //mycode --rafael
- if (m_WinsCount > 2 && WallyGOStanding.activeInHierarchy) //m_WinsCount > 2 && PlayerData.Instance().GetLadder() == ItemState.None
- {
- m_PrizeLadder.canCollect = true;
- }
- }
- protected override void Update() //mycode --rafael
- {
- base.Update();
- CanCollectLadder();
- }
- private void UpdateEnabledCharacters()
- {
- this.m_CurrentActiveWally = Characters.WallyStanding;
- this.m_CharacterAnimations[(int)Characters.WallyStanding].gameObject.SetActive(true);
- this.m_OtherCharacterRectangles[0].gameObject.SetActive(false);
- this.m_CharacterAnimations[(int)Characters.WallyOnLadder].gameObject.SetActive(false);
- this.m_OtherCharacterRectangles[1].gameObject.SetActive(true);
- }
- //================================================================================
- //
- //================================================================================
- public void StoreCloud()
- {
- AudioManager.Instance().PlaySFX("10270");
- m_WinsCount++;
- if (m_WinsCount <= 3) //mycode --rafael --> original: if (m_WinsCount <= 3 && PlayerData.Instance().GetLadder() == ItemState.None)
- {
- m_CloudGuyOnLadder.gameObject.SetActive(true);
- m_CharacterAnimations[(int)Characters.WallyOnLadder].gameObject.SetActive(false);
- m_CloudGuyOnLadder.SetTrigger("GetCloud");
- m_TreadmillController.SetCloudEnabled(false);
- }
- else
- {
- GivePrize();
- }
- }
- //================================================================================
- //
- //================================================================================
- public void OnCloudStored(string whatever)
- {
- if (m_WinsCount == 3)
- {
- m_CloudGuyOnLadder.gameObject.SetActive(false);
- }
- if (m_WinsCount <= 3)
- {
- m_CloudGuyOnLadder.gameObject.SetActive(false);
- m_CharacterAnimations[(int)Characters.WallyOnLadder].gameObject.SetActive(true);
- m_DeliveredClouds[m_WinsCount - 1].SetActive(true);
- }
- GivePrize();
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechPaige()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("SceneCloudSpellingChallenge.PlayReaderSamIntereactionSpeech");
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("SceneCloudSpellingChallenge.PlayReaderSamIntereactionSpeech:m_CurrentReaderSamInteractionSpeech = " + m_CurrentPaigeInteractionSpeech);
- if (m_CurrentPaigeInteractionSpeech > 2)
- {
- m_CurrentPaigeInteractionSpeech = 0;
- }
- NewSequence();
- if (m_CurrentPaigeInteractionSpeech == 0)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "10381");
- }
- else if (m_CurrentPaigeInteractionSpeech == 1)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "10382");
- }
- else if (m_CurrentPaigeInteractionSpeech == 2)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "10380");
- }
- StartSequence(1);
- m_CurrentPaigeInteractionSpeech++;
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechReader()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("SceneCloudSpellingChallenge.PlayReaderSamIntereactionSpeech");
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("SceneCloudSpellingChallenge.PlayReaderSamIntereactionSpeech:m_CurrentReaderSamInteractionSpeech = " + "1040" + (m_CurrentReaderSamInteractionSpeech + 4));
- if (m_CurrentReaderSamInteractionSpeech > 4)
- {
- m_CurrentReaderSamInteractionSpeech = 0;
- }
- NewSequence();
- if (m_CurrentReaderSamInteractionSpeech < 3)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "1040" + (m_CurrentReaderSamInteractionSpeech + 4));
- }
- else
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "1040" + (m_CurrentReaderSamInteractionSpeech + 4));
- }
- StartSequence(1);
- m_CurrentReaderSamInteractionSpeech++;
- }
- //================================================================================
- //
- //================================================================================
- private void PlayWallyOnLadderSpeech()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("SceneCloudSpellingChallenge.PlayWallyOnLadderSpeech");
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("SceneCloudSpellingChallenge.PlayWallyOnLadderSpeech:m_CurrentWallyOnLadderInteractionSpeech = " + "1035" + (m_CurrentWallyOnLadderInteractionSpeech + 4));
-
- if (m_CurrentWallyOnLadderInteractionSpeech > 3)
- {
- m_CurrentWallyOnLadderInteractionSpeech = 0;
- }
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentActiveWally, "1035" + (m_CurrentWallyOnLadderInteractionSpeech + 5));
- StartSequence(1);
- m_CurrentWallyOnLadderInteractionSpeech++;
- }
- //================================================================================
- //
- //================================================================================
- private void PlayWallyRandomWelcomeBackPhrase()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("SceneCloudSpellingChallenge.PlayWallyRandomWelcomeBackPhrase");
- string[] possibleNumbers = {"10", "11", "05"};
- string randomPhraseNumber = possibleNumbers[UnityEngine.Random.Range(0, possibleNumbers.Length)];
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentActiveWally, "102" + randomPhraseNumber);
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, InvokeLoadNextLevelDelayed);
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(3);
- }
- //================================================================================
- //
- //================================================================================
- private void PlayFirstDialogueFlow()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("SceneCloudSpellingChallenge.PlayFirstDialogueFlow");
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "10180");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.WallyOnLadder, "10182");
- SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.WallyOnLadder, "10185");
- SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.WallyOnLadder, "10183");
- SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.WallyOnLadder, "10184");
- SetSequence(5, EventSequenceItem.EventSequenceType.Callback, InvokeLoadNextLevelDelayed);
- SetSequence(6, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(7);
- }
- //================================================================================
- //
- //================================================================================
- private void InvokeLoadNextLevelDelayed()
- {
- Invoke("LoadNextLevel", 0.3f);
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnOtherCharacterInteraction()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCloudSpellingChallenge.OnOtherCharacterInteraction()...");
- if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "WallyOnLadder" ||
- m_CurrentInteractiveRectangle.GetActionParameter(0) == "WallyStanding")
- {
- PlayWallyOnLadderSpeech();
- }
- }
- //================================================================================
- //
- //================================================================================
- public void PlayLetterOrWordSound(string toBePlayed)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, m_CurrentActiveWally, m_PhonemeToSoundMap[toBePlayed.ToLower()]);
- StartSequence(1);
- }
- //================================================================================
- //
- //================================================================================
- private void InitPhonemeSoundMap()
- {
- string[] separators = { "\r\n" };
- string text = "";
- if (lang == 0) text = Resources.Load<TextAsset>("Resources_DA/CloudSpellingChallenge/phonemeToAudioMapping").text;
- else if (lang == 1) text = Resources.Load<TextAsset>("Resources_EN/CloudSpellingChallenge/phonemeToAudioMapping").text;
- else if (lang == 2) text = Resources.Load<TextAsset>("Resources_NO/CloudSpellingChallenge/phonemeToAudioMapping").text;
- else if (lang == 3) text = Resources.Load<TextAsset>("Resources_SP/CloudSpellingChallenge/phonemeToAudioMapping").text;
- else if (lang == 4) text = Resources.Load<TextAsset>("Resources_SW/CloudSpellingChallenge/phonemeToAudioMapping").text;
- string[] words = text.Split(separators, StringSplitOptions.RemoveEmptyEntries);
- m_PhonemeToSoundMap = new Dictionary<string, string>();
- int initialSoundName = 10500;
- foreach (string word in words)
- {
- m_PhonemeToSoundMap.Add(word, initialSoundName.ToString());
- initialSoundName++;
- }
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("m_PhonemeToSoundMap "+ m_PhonemeToSoundMap.Count);
- }
- //================================================================================
- //
- //================================================================================
- public void GetMarble()
- {
- m_Marble.DoAction();
- }
- } // public class SceneCloudSpellingChallenge : SceneCommon
- } // namespace ReaderRabbit
|