123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- //================================================================================
- //
- //================================================================================
- 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
|