123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- //================================================================================
- //
- //================================================================================
- using UnityEngine;
- using System.Collections;
- //================================================================================
- //
- //================================================================================
- namespace ReaderRabbit
- {
- //================================================================================
- //
- //================================================================================
- public class SceneCloudSheepCrossing : SceneCommon
- {
- //================================================================================
- //
- //================================================================================
- private enum Characters
- {
- Reader = CharactersCommon.Reader,
- Sam = CharactersCommon.Sam,
- Paige = CharactersCommon.Paige,
- Chester = CharactersCommon.Chester,
- }
- //================================================================================
- //
- //================================================================================
- private const int SAM_WHISTLE = (int)SamAnimation.AnimationCycles.Misc1 + 1;
- private const int SHEEP_MAX_RATIO_100 = 8;
- private const int SHEEP_MAX_RATIO_125 = 10;
- [SerializeField] private CSC_SheepAnimation[] m_Sheeps;
- private bool m_IsReaderFirstClick;
- private bool m_IsSheepFirstClick;
- private const int PAIGE_MAX_CLICK_COUNT = 1;
- private int m_PaigeClickCount;
- private bool m_IsIdleRandomSpeech;
- private bool m_IsFirstIdle;
- //================================================================================
- //
- //================================================================================
- protected override void Start()
- {
- base.Start();
- //============================================================================
- //
- //============================================================================
- int lang = PlayerPrefs.GetInt("language");
- if (lang == 0)
- m_SpeechFolder = "Resources_DA/Audio/CloudSheepCrossing_Speech";
- else if (lang == 1)
- m_SpeechFolder = "Resources_EN/Audio/CloudSheepCrossing_Speech";
- else if (lang == 2)
- m_SpeechFolder = "Resources_NO/Audio/CloudSheepCrossing_Speech";
- else if (lang == 3)
- m_SpeechFolder = "Resources_SP/Audio/CloudSheepCrossing_Speech";
- else if (lang == 4)
- m_SpeechFolder = "Resources_SW/Audio/CloudSheepCrossing_Speech";
- //============================================================================
- //
- //============================================================================
- PlayerData.Instance().SetVisitedCloudSheepCrossing(true);
- PlayerData.Instance().SetCurrentLocation(Location.CloudSheepCrossing);
- AudioManager.Instance().PlayBGM("BGM_CloudSheepCrossing");
- // Always block this location.
- PlayerData.Instance().BlockLocation(Location.CloudSheepCrossing);
- UpdateOnce();
- if (KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConversionRatio <= 1.0f)
- {
- for (int i = SHEEP_MAX_RATIO_100; i < m_Sheeps.Length; ++i)
- m_Sheeps[i].gameObject.SetActive(false);
- }
- else if (KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ConversionRatio <= 1.25f)
- {
- for (int i = SHEEP_MAX_RATIO_125; i < m_Sheeps.Length; ++i)
- m_Sheeps[i].gameObject.SetActive(false);
- }
- m_IsReaderFirstClick = true;
- m_IsSheepFirstClick = true;
- m_PaigeClickCount = 0;
- m_IsFirstIdle = true;
- // ******************** TODO: REMOVE ME, I'M DEBUG CODE ********************
- //PlayerData.Instance().SetWhistle(ItemState.Inventory);
- // ******************** TODO: REMOVE ME, I'M DEBUG CODE ********************
- }
- //================================================================================
- //
- //================================================================================
- public override void UpdateOnce()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCloudSheepCrossing.UpdateOnce()...");
- // This location will always be blocked (player always need to blow the whistle).
- //if (PlayerData.Instance().IsLocationBlocked(Location.CloudSheepCrossing))
- {
- DisableNavigationAll();
- EnableNavigation("DowntownCloudNine");
- }
- }
- //================================================================================
- //
- //================================================================================
- protected override void PlayFirstEvent()
- {
- if (m_IsFirstTime)
- {
- PlayFirstDialogueFlow();
- }
- else
- {
- PlayReturnDialogueFlow();
- }
- }
- //================================================================================
- //
- //================================================================================
- void PlayFirstDialogueFlow()
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13150");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13151");
- SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13152");
- SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13153");
- SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13154");
- SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13201");
- SetSequence(6, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(7);
- }
- //================================================================================
- //
- //================================================================================
- void PlayReturnDialogueFlow()
- {
- NewSequence();
- if (PlayerData.Instance().GetItemState(ItemEnum.Whistle) == ItemState.Inventory)
- {
- // TODO: Original code is different.
- int randomValue = Random.Range(0, 100);
- if (randomValue < 50)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13205");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13206");
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(3);
- }
- else
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13207");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13168");
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(3);
- }
- }
- else
- {
- int randomValue = Random.Range(0, 100);
- if (randomValue < 50)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13200");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13201");
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(3);
- }
- else
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13202");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13204");
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, DoneFirstTime);
- StartSequence(3);
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- protected override void EnableCharacterAnimatorFirstTime()
- {
- base.EnableCharacterAnimatorFirstTime();
- foreach (CSC_SheepAnimation sheep in m_Sheeps)
- {
- sheep.ChangeToIdle();
- }
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnRightItemUsedInScene(ItemEnum item)
- {
- // Whistle is never discarded.
- Chester.Instance().PutItem(ItemEnum.Whistle, null, 0.0f, 0.0f, true);
- if (PlayerData.Instance().IsLocationBlocked(Location.CloudSheepCrossing))
- {
- base.OnRightItemUsedInScene(item);
- PlayWhistle();
- }
- else
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "7012");
- StartSequence(1);
- }
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnWrongItemUsedInScene(ItemEnum item)
- {
- if (PlayerData.Instance().IsLocationBlocked(Location.CloudSheepCrossing))
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13415");
- StartSequence(1);
- }
- else
- {
- base.OnWrongItemUsedInScene(item);
- }
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnIdle()
- {
- if (m_IsFirstIdle && !PlayerData.Instance().DidVisitNewspaperCarrierScene())
- {
- NewSequence();
- if (PlayerData.Instance().GetItemState(ItemEnum.Whistle) == ItemState.Inventory)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13251");
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
- StartSequence(2);
- }
- else
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13204");
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
- StartSequence(2);
- }
- }
- else
- {
- m_IsIdleRandomSpeech = true;
- ReaderRandomSpeech(false);
- }
- }
- //================================================================================
- //
- //================================================================================
- void PlayWhistle()
- {
- m_IsSheepFirstClick = false;
- PlayerData.Instance().CSC_IsFirstSheepClick = false;
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Animation,
- Characters.Sam,
- SAM_WHISTLE,
- m_CharacterAnimations[(int)Characters.Sam].AnimationCyclesString[SAM_WHISTLE]);
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, SheepAnimation);
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, CheckFirstPlayWhistle);
- StartSequence(3);
- }
- //================================================================================
- //
- //================================================================================
- void SheepAnimation()
- {
- // Unblock location after player uses whistle. Unblock flag is used here only for salute animation,
- // since location always starts blocked.
- PlayerData.Instance().UnblockLocation(Location.CloudSheepCrossing);
- foreach (CSC_SheepAnimation sheep in m_Sheeps)
- {
- if (sheep.gameObject.activeInHierarchy)
- sheep.Salute();
- }
- AudioManager.Instance().PlaySFX("13080");
- }
- //================================================================================
- //
- //================================================================================
- void CheckFirstPlayWhistle()
- {
- Invoke("CheckFirstPlayWhistleDelayed", 1.0f);
- }
- //================================================================================
- //
- //================================================================================
- void CheckFirstPlayWhistleDelayed()
- {
- if (PlayerData.Instance().CSC_IsFirstWhistle)
- {
- PlayerData.Instance().CSC_IsFirstWhistle = false;
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13410");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13411");
- SetSequence(2, EventSequenceItem.EventSequenceType.Callback, EnableNavigationAll);
- StartSequence(3);
- }
- else
- {
- EnableNavigationAll();
- }
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnBlockedNavigation()
- {
- PlaySheepSpeech();
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnOtherCharacterInteraction()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCloudNineGateway.OnOtherCharacterInteraction()...");
- if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "BlowSign")
- {
- // Play SoftClick SFX.
- AudioManager.Instance().PlaySFX("1805");
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13154");
- StartSequence(1);
- }
- else if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "Sheep")
- {
- if (PlayerData.Instance().IsLocationBlocked(Location.CloudSheepCrossing))
- PlaySheepSpeech();
- }
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechReader()
- {
- if (PlayerData.Instance().GetItemState(ItemEnum.Whistle) == ItemState.Inventory && PlayerData.Instance().CSC_IsFirstWhistle)
- {
- NewSequence();
-
- int randomValue = Random.Range(0, 100);
- if (randomValue < 50)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13350");
- StartSequence(1);
- }
- else
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13168");
- StartSequence(1);
- }
- }
- else
- {
- if (m_IsReaderFirstClick && PlayerData.Instance().GetItemState(ItemEnum.Whistle) != ItemState.Inventory)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13204");
- StartSequence(1);
- m_IsReaderFirstClick = false;
- }
- else
- {
- m_IsIdleRandomSpeech = false;
- ReaderRandomSpeech(true);
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- public override void ReaderRandomSpeech(bool ignoreSomebodySpeaking)
- {
- if (ignoreSomebodySpeaking || !IsSomebodySpeaking())
- {
- int sequence = 0;
-
- NewSequence();
- int randomValue = Random.Range(0, 200);
- if (randomValue < 50)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13267");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13268");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13269");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13270");
- }
- else if (randomValue < 100)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13260");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13261");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13262");
- }
- else if (randomValue < 150)
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13255");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13256");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13257");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13258");
- }
- else
- {
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13265");
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13266");
- }
- if (m_IsIdleRandomSpeech)
- SetSequence(sequence++, EventSequenceItem.EventSequenceType.Callback, UpdateIdleDelay);
- StartSequence(sequence);
- }
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechPaige()
- {
- NewSequence();
- if (PlayerData.Instance().GetItemState(ItemEnum.Whistle) != ItemState.Inventory)
- {
- if (m_IsFirstTime)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "1330" + m_PaigeClickCount.ToString());
- StartSequence(1);
- ++m_PaigeClickCount;
- if (m_PaigeClickCount > PAIGE_MAX_CLICK_COUNT)
- m_PaigeClickCount = 0;
- }
- else
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "13301");
- StartSequence(1);
- }
- }
- else
- {
- if (PlayerData.Instance().CSC_IsFirstWhistle)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "13302");
- StartSequence(1);
- }
- else
- {
- string[] possibleNumbers = { "13303", "13304", "13305", "13306" };
- string randomPhraseNumber = possibleNumbers[Random.Range(0, possibleNumbers.Length)];
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, randomPhraseNumber);
- StartSequence(1);
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- void PlaySheepSpeech()
- {
- if (PlayerData.Instance().CSC_IsFirstSheepClick)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13400");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13401");
- StartSequence(2);
- PlayerData.Instance().CSC_IsFirstSheepClick = false;
- }
- else
- {
- if (m_IsSheepFirstClick)
- {
- NewSequence();
- if (PlayerData.Instance().CSC_IsFirstWhistle)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "13403");
- StartSequence(1);
- }
- else
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "13405");
- StartSequence(1);
- }
- m_IsSheepFirstClick = false;
- }
- else
- {
- SpeechReader();
- }
- }
- }
- } // public class SceneCloudSheepCrossing : SceneCommon
- } // namespace ReaderRabbit
|