123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- //================================================================================
- //
- //================================================================================
- using UnityEngine;
- using System.Collections;
- //================================================================================
- //
- //================================================================================
- namespace ReaderRabbit
- {
- //================================================================================
- //
- //================================================================================
- public class SceneAmazingArtGallery : SceneCommon
- {
- //================================================================================
- //
- //================================================================================
- private enum Characters
- {
- Reader = CharactersCommon.Reader,
- Sam = CharactersCommon.Sam,
- Paige = CharactersCommon.Paige,
- }
- //================================================================================
- //
- //================================================================================
- [SerializeField] private Painter m_Painter;
- private const int REQUIRED_PAGES = 4;
- private const int READER_MAX_SPEECH_INDEX = 7;
- private int m_ReaderSpeechIndex;
- private int m_GameState;
- //================================================================================
- //
- //================================================================================
- protected override void Start()
- {
- base.Start();
- //============================================================================
- //
- //============================================================================
- int lang = PlayerPrefs.GetInt("language");
- if (lang == 0)
- m_SpeechFolder = "Resources_DA/Audio/AmazingArtGallery_Speech";
- else if (lang == 1)
- m_SpeechFolder = "Resources_EN/Audio/AmazingArtGallery_Speech";
- else if (lang == 2)
- m_SpeechFolder = "Resources_NO/Audio/AmazingArtGallery_Speech";
- else if (lang == 3)
- m_SpeechFolder = "Resources_SP/Audio/AmazingArtGallery_Speech";
- else if (lang == 4)
- m_SpeechFolder = "Resources_SW/Audio/AmazingArtGallery_Speech";
- //============================================================================
- //
- //============================================================================
- PlayerData.Instance().SetVisitedAmazingArtGallery(true);
- PlayerData.Instance().SetCurrentLocation(Location.AmazingArtGallery);
- PlayerData.Instance().UnlockActivity(Activity.AmazingArtGallery);
- AudioManager.Instance().PlayBGM("BGM_AmazingArtGallery");
- m_ReaderSpeechIndex = 0;
- if (m_Painter.FramesManager.GetMarkedFrameCount() > 0)
- m_GameState = 3;
- else
- {
- if (m_IsFirstTime)
- m_GameState = 2;
- else
- {
- if (SelectedPaintingFrame != null && (SelectedPaintingFrame.Equals("Blue") || SelectedPaintingFrame.Equals("Cyan")))
- m_GameState = 2;
- else
- m_GameState = 1;
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- public static string SelectedPaintingFrame
- {
- get; set;
- }
- //================================================================================
- //
- //================================================================================
- protected override void StartedFadeOut ()
- {
- base.StartedFadeOut();
- m_Painter.SaveCurrentFrames();
- }
- //================================================================================
- //
- //================================================================================
- protected override void PlayFirstEvent()
- {
- switch (m_GameState)
- {
- case 1:
- ++PlayerData.Instance().AAG_Enter1Count;
- if (PlayerData.Instance().AAG_Enter1Count == 1)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11350");
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
- StartSequence(2);
- }
- else
- {
- Characters[] possibleCharacters = { Characters.Sam, Characters.Reader, Characters.Sam };
- string[] possibleNumbers = { "11351", "11352", "11353" };
- int randomValue = Random.Range(0, possibleNumbers.Length);
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomValue], possibleNumbers[randomValue]);
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
- StartSequence(2);
- }
- break;
- case 2:
- ++PlayerData.Instance().AAG_Enter2Count;
- if (PlayerData.Instance().AAG_Enter2Count == 1)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11360");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11361");
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
- StartSequence(3);
- }
- else
- {
- Characters[] possibleCharacters = { Characters.Reader, Characters.Sam, Characters.Reader };
- string[] possibleNumbers = { "11370", "11371", "11372" };
- int randomValue = Random.Range(0, possibleNumbers.Length);
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomValue], possibleNumbers[randomValue]);
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
- StartSequence(2);
- }
- break;
- case 3:
- ++PlayerData.Instance().AAG_Enter3Count;
- if (PlayerData.Instance().AAG_Enter3Count == 1)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11380");
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
- StartSequence(2);
- }
- else
- {
- Characters[] possibleCharacters = { Characters.Reader, Characters.Sam, Characters.Reader };
- string[] possibleNumbers = { "11381", "11382", "11383" };
- int randomValue = Random.Range(0, possibleNumbers.Length);
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomValue], possibleNumbers[randomValue]);
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, PaigeHelpSpeech);
- StartSequence(2);
- }
- break;
- }
- }
- //================================================================================
- //
- //================================================================================
- private void PaigeHelpSpeech()
- {
- Invoke("PaigeHelpSpeechDelayed", 0.1f);
- }
- //================================================================================
- //
- //================================================================================
- private void PaigeHelpSpeechDelayed()
- {
- int k = 0;
- if (!PlayerData.Instance().AAG_PaintUsed)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Callback, m_Painter.ToolsManager.SelectBrush);
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11600");
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, m_Painter.ToolsManager.RestorePreviousSelectedTool);
- SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(4);
- k = 1;
- }
- if (k == 0 && !PlayerData.Instance().AAG_TwoPagesUsed)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Callback, m_Painter.NextButtonHighlight);
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11601");
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, m_Painter.NextButtonNoHighlight);
- SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(4);
- k = 2;
- }
- if (k == 0 && !PlayerData.Instance().AAG_FillUsed)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Callback, m_Painter.ToolsManager.SelectBucket);
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11602");
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, m_Painter.ToolsManager.RestorePreviousSelectedTool);
- SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(4);
- k = 3;
- }
- if (k == 0 && !PlayerData.Instance().AAG_StampUsed)
- {
- // TODO: Highlight all stamps.
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11603");
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(2);
- k = 4;
- }
- if (k == 0 && !PlayerData.Instance().AAG_PlayUsed)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Callback, m_Painter.PlayButtonHighlight);
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11604");
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, m_Painter.PlayButtonNoHighlight);
- SetSequence(3, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(4);
- k = 5;
- }
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnIdle()
- {
- string[] possibleNumbers = { "11500", "11501", "11502", "11503" };
- Characters[] possibleCharacters = { Characters.Reader, Characters.Sam, Characters.Reader, Characters.Sam };
- int randomValue = Random.Range(0, possibleNumbers.Length);
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, possibleCharacters[randomValue], possibleNumbers[randomValue]);
- StartSequence(1);
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechReader()
- {
- ++m_ReaderSpeechIndex;
- if (m_ReaderSpeechIndex > READER_MAX_SPEECH_INDEX)
- m_ReaderSpeechIndex = 1;
- switch (m_ReaderSpeechIndex)
- {
- case 1:
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11650");
- StartSequence(1);
- break;
- case 2:
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11651");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11652");
- StartSequence(2);
- break;
- case 3:
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11653");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11654");
- SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11655");
- StartSequence(3);
- break;
- case 4:
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11656");
- StartSequence(1);
- break;
- case 5:
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11657");
- StartSequence(1);
- break;
- case 6:
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11658");
- StartSequence(1);
- break;
- case 7:
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11659");
- StartSequence(1);
- break;
- }
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechPaige()
- {
- NewSequence();
- int sequence = 0;
- bool queued = false;
- if (m_Painter.FramesManager.CurrentFrameIndex != 0
- && m_Painter.FramesManager.IsFrameMarked(m_Painter.FramesManager.CurrentFrameIndex - 1)
- && !PlayerData.Instance().AAG_PaigeClicked)
- {
- PlayerData.Instance().AAG_PaigeClicked = true;
- // User it not on first page and the previous page is not blank.
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11550");
- queued = true;
- }
- if (m_Painter.FramesManager.GetMarkedFrameCount() == 1 && !queued)
- {
- // User has only drawn on page 1.
- int randomValue = Random.Range(0, 100);
- if (randomValue < 50)
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11552");
- else
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11553");
- queued = true;
- }
- if (m_Painter.FramesManager.GetMarkedFrameCount() < REQUIRED_PAGES
- && !PlayerData.Instance().IsPracticeMode()
- && !queued)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11554");
- queued = true;
- }
- if (!queued)
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11555");
- StartSequence(sequence);
- }
- //================================================================================
- //
- //================================================================================
- public void NextClick(int frameIndex)
- {
- if (PlayerData.Instance().AAG_NextClickCount == 0)
- {
- ++PlayerData.Instance().AAG_NextClickCount;
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11700");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "11701");
- SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11702");
- StartSequence(3);
- }
- if (PlayerData.Instance().AAG_NextClickCount == 1 && frameIndex == 3)
- {
- ++PlayerData.Instance().AAG_NextClickCount;
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "11703");
- StartSequence(1);
- }
- }
- //================================================================================
- //
- //================================================================================
- public void UndoClick()
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "11239");
- StartSequence(1);
- }
- } // public class SceneAmazingArtGallery : SceneCommon
- } // namespace ReaderRabbit
|