//================================================================================ // //================================================================================ using UnityEngine; using System.Collections; //================================================================================ // //================================================================================ namespace ReaderRabbit { //================================================================================ // //================================================================================ public class SceneEdgeOfCloudNine : SceneCommon { //================================================================================ // //================================================================================ private enum Characters { Reader = CharactersCommon.Reader, Sam = CharactersCommon.Sam, Paige = CharactersCommon.Paige, Chester = CharactersCommon.Chester, Announcer = CharactersCommon.StartSceneSpecific, } //================================================================================ // //================================================================================ private enum Items { Bell = 0, Cloud, } //================================================================================ // //================================================================================ private int m_IdleHelpIndex; private const int MAX_IDLE_INDEX = 2; private bool m_IsShipVideoOpening; //================================================================================ // //================================================================================ protected override void Start() { base.Start(); //============================================================================ // //============================================================================ int lang = PlayerPrefs.GetInt("language"); if (lang == 0) m_SpeechFolder = "Resources_DA/Audio/EdgeOfCloudNine_Speech"; else if (lang == 1) m_SpeechFolder = "Resources_EN/Audio/EdgeOfCloudNine_Speech"; else if (lang == 2) m_SpeechFolder = "Resources_NO/Audio/EdgeOfCloudNine_Speech"; else if (lang == 3) m_SpeechFolder = "Resources_SP/Audio/EdgeOfCloudNine_Speech"; else if (lang == 4) m_SpeechFolder = "Resources_SW/Audio/EdgeOfCloudNine_Speech"; //============================================================================ // //============================================================================ PlayerData.Instance().SetVisitedEdgeOfCloudNine(true); PlayerData.Instance().SetCurrentLocation(Location.EdgeOfCloudNine); UpdateIsVideoOpening(); if (!m_IsShipVideoOpening) AudioManager.Instance().PlayBGM("BGM_EdgeOfCloudNine"); UpdateOnce(); m_IdleHelpIndex = 0; } //================================================================================ // //================================================================================ private void UpdateIsVideoOpening() { m_IsShipVideoOpening = PlayerData.Instance().GetPreviousLocation() == Location.RaingearIsland; } //================================================================================ // //================================================================================ private void VideoPlayed() { m_IsShipVideoOpening = false; if (!AudioManager.Instance().IsPlayingBGM("BGM_EdgeOfCloudNine")) AudioManager.Instance().PlayBGM("BGM_EdgeOfCloudNine"); } //================================================================================ // //================================================================================ protected override void DoneFirstTime() { base.DoneFirstTime(); if (!AudioManager.Instance().IsPlayingBGM("BGM_EdgeOfCloudNine")) AudioManager.Instance().PlayBGM("BGM_EdgeOfCloudNine"); } //================================================================================ // //================================================================================ protected override void PlayFirstEvent() { if (m_IsFirstTime) { PlayerData.Instance().EOCN_IsSecondTime = true; NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Video, VideoType.CloudNine); SetSequence(1, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14200"); SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14201"); SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14202"); SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14160"); SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14161"); SetSequence(7, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime); SetSequence(8, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); StartSequence(9); // This is the first time the player is playing, so we need to unlock the Introduction video as well. PlayerData.Instance().UnlockVideo(VideoType.Introduction); PlayerData.Instance().UnlockVideo(VideoType.CloudNine); } else if (PlayerData.Instance().EOCN_IsSecondTime) { PlayerData.Instance().EOCN_IsSecondTime = false; int sequence = 0; NewSequence(); if (m_IsShipVideoOpening) { SetSequence(sequence++, EventSequenceItem.EventSequenceType.Video, VideoType.GotoEdgeOfCloudNine); SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); } SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14250"); SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, VideoPlayed); SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime); SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); StartSequence(sequence); } else if (m_IsShipVideoOpening) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); SetSequence(1, EventSequenceItem.EventSequenceType.Video, VideoType.GotoEdgeOfCloudNine); SetSequence(2, EventSequenceItem.EventSequenceType.Callback, VideoPlayed); SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime); SetSequence(4, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); StartSequence(5); } } //================================================================================ // //================================================================================ public override void UpdateOnce() { if (PlayerData.Instance().IsLocationBlocked(Location.EdgeOfCloudNine)) { PlayerData.Instance().EOCN_IsCloudVisible = true; DisableNavigation("RaingearIsland"); } else { PlayerData.Instance().EOCN_IsCloudVisible = false; EnableNavigationAll(); } } //================================================================================ // //================================================================================ protected override void OnIdle() { ++m_IdleHelpIndex; if (m_IdleHelpIndex > (MAX_IDLE_INDEX * 3)) m_IdleHelpIndex = 0; if (!IsSomebodySpeaking()) { if (m_IdleHelpIndex % 3 == 2) { NewSequence(); int randomValue = Random.Range(0, 100); if (randomValue < 50) { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14300"); SetSequence(1, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); StartSequence(2); } else { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14301"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14302"); SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); StartSequence(3); } } else { AnnouncerRandomSpeech(false); } } } //================================================================================ // //================================================================================ protected override void OnOtherCharacterInteraction() { AnnouncerRandomSpeech(true); } //================================================================================ // //================================================================================ public void AnnouncerRandomSpeech(bool ignoreSomebodySpeaking) { if ((ignoreSomebodySpeaking || !IsSomebodySpeaking()) && !m_IsPlayingSequence) { NewSequence(); int randomValue = Random.Range(0, m_CharacterAnimations[(int)Characters.Announcer].MaxRandomSpeech - 1); switch (randomValue) { case 0: SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14160"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14161"); SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); StartSequence(3); break; case 1: SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14162"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14163"); SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); StartSequence(3); break; case 2: SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14164"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14165"); SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); StartSequence(3); break; case 3: SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14166"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14167"); SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); StartSequence(3); break; case 4: SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14168"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Announcer, "14169"); SetSequence(2, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay); StartSequence(3); break; } } } //================================================================================ // //================================================================================ public override void SpeechReader() { if (PlayerData.Instance().GetBell() == ItemState.None) { NewSequence(); SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "14350"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14351"); StartSequence(2); } else { ReaderRandomSpeech(true); } } //================================================================================ // //================================================================================ public override void ReaderRandomSpeech(bool ignoreSomebodySpeaking) { if (ignoreSomebodySpeaking || !IsSomebodySpeaking()) { NewSequence(); int randomValue = Random.Range(0, 100); if (randomValue < 50) { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14400"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14401"); StartSequence(2); } else { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14402"); StartSequence(1); } } } //================================================================================ // //================================================================================ public override void SpeechPaige() { NewSequence(); if (PlayerData.Instance().GetBell() == ItemState.None) { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "14350"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14351"); StartSequence(2); } else { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "14352"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14353"); StartSequence(2); } } //================================================================================ // //================================================================================ public void SpeechItemBell() { NewSequence(); // Play Pickup SFX. AudioManager.Instance().PlaySFX("1802"); // Sam and Reader talk in two different ways when player gets the bell. // One way is when the player gets it without going to CloudNineGateway and the other way is after going to CloudNineGateway and back. if (PlayerData.Instance().DidVisitCloudNineGateway()) { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14453"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14454"); SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14452"); SetSequence(3, EventSequenceItem.EventSequenceType.Callback, m_Items[(int)Items.Bell].DoAction); StartSequence(4); } else { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14450"); SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14451"); SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14452"); SetSequence(3, EventSequenceItem.EventSequenceType.Callback, m_Items[(int)Items.Bell].DoAction); StartSequence(4); } } //================================================================================ // //================================================================================ public void SpeechItemCloud(bool isVisible) { NewSequence(); if (isVisible) { // Sometimes Reader talks, sometimes Sam talks. int randomValue = Random.Range(0, 100); if (randomValue < 50) { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14120"); StartSequence(1); } else { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "14121"); StartSequence(1); } } else { SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "14251"); StartSequence(1); } } } // public class SceneEdgeOfCloudNine : SceneCommon } // namespace ReaderRabbit