//================================================================================ // //================================================================================ using UnityEngine; using System.Collections; //================================================================================ // //================================================================================ namespace ReaderRabbit { //================================================================================ // //================================================================================ public class SceneRaingearThrowingMachine : SceneCommon { //================================================================================ // //================================================================================ private enum Characters { Reader = CharactersCommon.Reader, Sam = CharactersCommon.Sam, Paige = CharactersCommon.Paige, Chester = CharactersCommon.Chester, Fluffy = CharactersCommon.StartSceneSpecific, RaingearThrowingMachine, } //================================================================================ // //================================================================================ private enum Items { Sandwich = 0, Bowl, } //================================================================================ // //================================================================================ private const int READER_CATAPULT = (int)ReaderAnimation.AnimationCycles.Misc1 + 1; //================================================================================ // //================================================================================ protected override void Start() { base.Start(); //============================================================================ // //============================================================================ int lang = PlayerPrefs.GetInt("language"); if (lang == 0) m_SpeechFolder = "Resources_DA/Audio/RaingearThrowingMachine_Speech"; else if (lang == 1) m_SpeechFolder = "Resources_EN/Audio/RaingearThrowingMachine_Speech"; else if (lang == 2) m_SpeechFolder = "Resources_NO/Audio/RaingearThrowingMachine_Speech"; else if (lang == 3) m_SpeechFolder = "Resources_SP/Audio/RaingearThrowingMachine_Speech"; else if (lang == 4) m_SpeechFolder = "Resources_SW/Audio/RaingearThrowingMachine_Speech"; //============================================================================ // //============================================================================ PlayerData.Instance().SetVisitedRaingearThrowingMachine(true); PlayerData.Instance().SetCurrentLocation(Location.RaingearThrowingMachine); AudioManager.Instance().PlayBGM("BGM_RaingearThrowingMachine"); } //================================================================================ // //================================================================================ public override void UpdateOnce() { if (PlayerData.Instance().RTM_IsCatapultReady) EnableNavigation("RaingearIslandRainbow"); else DisableNavigation("RaingearIslandRainbow"); m_Items[(int)Items.Bowl].gameObject.SetActive(!PlayerData.Instance().RTM_IsFluffySleeping); m_Items[(int)Items.Sandwich].gameObject.SetActive(false); m_CharacterAnimations[(int)Characters.Fluffy].ChangeToIdle(); if (PlayerData.Instance().RTM_IsFluffySleeping) ((RTM_FluffyAnimation)m_CharacterAnimations[(int)Characters.Fluffy]).PlaySleepAnimation(); } //================================================================================ // //================================================================================ protected override void PlayFirstEvent() { if (PlayerData.Instance().RTM_IsCatapultReady) EnableNavigation("RaingearIslandRainbow"); else DisableNavigation("RaingearIslandRainbow"); m_Items[(int)Items.Bowl].gameObject.SetActive(!PlayerData.Instance().RTM_IsFluffySleeping); m_Items[(int)Items.Sandwich].gameObject.SetActive(false); m_CharacterAnimations[(int)Characters.Fluffy].ChangeToIdle(); if (PlayerData.Instance().RTM_VisitCount < 4) ++PlayerData.Instance().RTM_VisitCount; if (m_IsFirstTime) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28150"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28151"); SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28152"); SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28153"); StartSequence(4); } else { if (PlayerData.Instance().RTM_IsFluffySleeping) { if (PlayerData.Instance().RTM_IsCatapultReady) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28210"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28211"); StartSequence(2); } } else { if (PlayerData.Instance().RTM_VisitCount < 4) { switch (PlayerData.Instance().RTM_VisitCount) { case 1: NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28200"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28201"); StartSequence(2); break; case 2: NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28202"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Fluffy, "28250"); StartSequence(2); break; case 3: NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28204"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28205"); StartSequence(2); break; } } } } } //================================================================================ // //================================================================================ protected override void OnIdle() { if (PlayerData.Instance().RTM_IsFluffySleeping) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "28253"); StartSequence(1); } else { string[] possibleNumbers = { "0", "1", "2" }; string randomPhraseNumber = possibleNumbers[Random.Range(0, possibleNumbers.Length)]; NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Fluffy, "2825" + randomPhraseNumber); StartSequence(1); } } //================================================================================ // //================================================================================ public override void SpeechReader() { if (PlayerData.Instance().RTM_IsFluffySleeping) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28363"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28364"); StartSequence(2); } else { if (PlayerData.Instance().RTM_UsedCatapultCount == 0) { int randomValue = Random.Range(0, 100); if (randomValue < 50) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28355"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28356"); StartSequence(2); } else { if (PlayerData.Instance().GetSandwich() == ItemState.Inventory) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28350"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28352"); StartSequence(2); } else { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28350"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28351"); StartSequence(2); } } } else { int randomValue = Random.Range(0, 150); if (randomValue < 50) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28357"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28358"); StartSequence(2); } else if (randomValue < 100) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28359"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28360"); StartSequence(2); } else { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28361"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28362"); StartSequence(2); } } } } //================================================================================ // //================================================================================ public override void SpeechPaige() { if (PlayerData.Instance().RTM_IsFluffySleeping) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "28253"); StartSequence(1); } else { string[] possibleNumbers = { "0", "1", "2", "3" }; string randomPhraseNumber = possibleNumbers[Random.Range(0, possibleNumbers.Length)]; NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "2830" + randomPhraseNumber); StartSequence(1); } } //================================================================================ // //================================================================================ protected override void OnOtherCharacterInteraction() { if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "Fluffy") { PlaySpeechFluffy(); } } //================================================================================ // //================================================================================ private void PlaySpeechFluffy() { if (!PlayerData.Instance().RTM_IsFluffySleeping) { int randomValue = Random.Range(0, 150); if (randomValue < 50) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Fluffy, "28250"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28400"); StartSequence(2); } else if (randomValue < 100) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Fluffy, "28251"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28205"); SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28401"); StartSequence(3); } else { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Fluffy, "28252"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28402"); StartSequence(2); } } } //================================================================================ // //================================================================================ public void PlaySpeechBowl() { int randomValue = Random.Range(0, 100); if (randomValue < 50) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28405"); StartSequence(1); } else { if (PlayerData.Instance().GetSandwich() == ItemState.Inventory) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28406"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28352"); StartSequence(2); } else { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28406"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28351"); StartSequence(2); } } } //================================================================================ // //================================================================================ protected override void OnRightItemUsedInScene(ItemEnum item) { base.OnRightItemUsedInScene(item); if (PlayerData.Instance().RTM_IsFluffySleeping) { Characters[] characters = { Characters.Sam, Characters.Reader, Characters.Sam, Characters.Reader }; string[] possibleNumbers = { "7010", "7011", "7012", "7013" }; int randomValue = Random.Range(0, possibleNumbers.Length); NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, characters[randomValue], possibleNumbers[randomValue]); } else { FeedFluffy(); } } //================================================================================ // //================================================================================ protected override void OnWrongItemUsedInScene(ItemEnum item) { int randomValue = Random.Range(0, 100); if (randomValue < 50) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28421"); StartSequence(1); } else { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28422"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28423"); StartSequence(2); } } //================================================================================ // //================================================================================ private void FeedFluffy() { bool isFirstSandwich = PlayerData.Instance().RTM_IsFirstSandwich; PlayerData.Instance().RTM_IsCatapultReady = true; PlayerData.Instance().RTM_IsFluffySleeping = true; m_Items[(int)Items.Sandwich].gameObject.SetActive(PlayerData.Instance().GetSandwich() == ItemState.Used); int sequence = 0; NewSequence(); if (PlayerData.Instance().RTM_IsFirstSandwich) { PlayerData.Instance().RTM_IsFirstSandwich = false; SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28411"); } else { Characters[] characters = { Characters.Reader, Characters.Sam, Characters.Reader }; string[] possibleNumbers = { "28411", "28412", "28413" }; int randomValue = Random.Range(0, possibleNumbers.Length); SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, characters[randomValue], possibleNumbers[randomValue]); } SetSequence(sequence++, EventSequenceItem.EventSequenceType.AnimationWithSfx, Characters.Fluffy, 4, m_CharacterAnimations[(int)Characters.Fluffy].AnimationCyclesString[4], "28410"); SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, FluffyAteSandwich); Characters[] characters2 = { Characters.Reader, Characters.Sam, Characters.Reader }; string[] possibleNumbers2 = { "28416", "28417", "28419" }; int randomValue2 = Random.Range(0, possibleNumbers2.Length); SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, characters2[randomValue2], possibleNumbers2[randomValue2]); if (isFirstSandwich) SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28420"); SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, UpdateOnce); StartSequence(sequence); } //================================================================================ // //================================================================================ private void FluffyAteSandwich() { //m_Items[(int)Items.Sandwich].gameObject.SetActive(false); if (PlayerData.Instance().RTM_IsFluffySleeping) ((RTM_FluffyAnimation)m_CharacterAnimations[(int)Characters.Fluffy]).PlaySleepAnimation(); } //================================================================================ // //================================================================================ protected override void OnNavigation() { if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "RaingearIslandRainbow") { if (m_CurrentInteractiveRectangle.IsEnabled()) UseCatapult(); } else { base.OnNavigation(); } } //================================================================================ // //================================================================================ protected override void OnBlockedNavigation() { int randomValue = Random.Range(0, 150); if (randomValue < 50) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28430"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28431"); StartSequence(2); } else if (randomValue < 100) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28204"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28205"); StartSequence(2); } else { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "28200"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28201"); StartSequence(2); } } //================================================================================ // //================================================================================ private void UseCatapult() { if (PlayerData.Instance().RTM_UsedCatapultCount < 2) ++PlayerData.Instance().RTM_UsedCatapultCount; NewSequence(); if (PlayerData.Instance().RTM_UsedCatapultCount == 1) { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "28435"); } else { string[] possibleNumbers = { "28436", "28437" }; string randomPhraseNumber = possibleNumbers[Random.Range(0, possibleNumbers.Length)]; SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, randomPhraseNumber); } SetSequence(1, EventSequenceItem.EventSequenceType.Callback, HideSam); SetSequence(2, EventSequenceItem.EventSequenceType.Callback, HideMachine); SetSequence(3, EventSequenceItem.EventSequenceType.Animation, Characters.Reader, READER_CATAPULT, m_CharacterAnimations[(int)Characters.Reader].AnimationCyclesString[READER_CATAPULT]); SetSequence(4, EventSequenceItem.EventSequenceType.Callback, HideReader); SetSequence(5, EventSequenceItem.EventSequenceType.Callback, GotoDowntownCloudNineViaRaingearIslandRainbow); StartSequence(6, false); } //================================================================================ // //================================================================================ private void HideSam() { m_CharacterAnimations[(int)Characters.Sam].gameObject.SetActive(false); } //================================================================================ // //================================================================================ private void HideReader() { m_CharacterAnimations[(int)Characters.Reader].gameObject.SetActive(false); } //================================================================================ // //================================================================================ private void HideMachine() { m_CharacterAnimations[(int)Characters.RaingearThrowingMachine].gameObject.SetActive(false); } //================================================================================ // //================================================================================ void GotoDowntownCloudNineViaRaingearIslandRainbow() { // Going up the rainbow. PlayerData.Instance().RGIR_Direction = 1; KishiTechUnity.Loading.Loading.Instance().Show(); SetCurrentToNavigation("RaingearIslandRainbow"); base.OnNavigation(); } //================================================================================ // //================================================================================ protected override void OnCharacterAnimationCustomTimelineEvent1(CharacterAnimation character) { if (character == m_CharacterAnimations[(int)Characters.Fluffy]) { m_Items[(int)Items.Bowl].gameObject.SetActive(!PlayerData.Instance().RTM_IsFluffySleeping); m_Items[(int)Items.Sandwich].gameObject.SetActive(false); } } } // public class SceneRaingearThrowingMachine : SceneCommon } // namespace ReaderRabbit