123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599 |
- //================================================================================
- //
- //================================================================================
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using KishiTechUnity.KishiTechDebug;
- //================================================================================
- //
- //================================================================================
- namespace ReaderRabbit
- {
- //================================================================================
- //
- //================================================================================
- public class SceneCommon : KishiTechUnity.ScreenResolution.SceneRoot
- {
-
- //================================================================================
- //
- //================================================================================
- public enum CharactersCommon
- {
- Reader = 0,
- Sam,
- Paige,
- Chester,
- StartSceneSpecific,
- }
- //================================================================================
- //
- //================================================================================
- [SerializeField] protected SceneIndex m_SceneIndex;
- [SerializeField] protected ChesterInSceneAnimation m_ChesterInScene;
- [SerializeField] protected RRInteractiveRectangle m_ChesterRectangle;
- [SerializeField] protected RRInteractiveRectangle[] m_CharacterRectangles;
- [SerializeField] protected RRInteractiveRectangle[] m_OtherCharacterRectangles;
- [SerializeField] protected RRInteractiveRectangle[] m_NavigationRectangles;
- protected RRInteractiveRectangle m_CurrentInteractiveRectangle;
- [SerializeField] protected HUDCommon[] m_HUD;
- [SerializeField] protected ItemCommon[] m_Items;
- [SerializeField] protected CharacterAnimation[] m_CharacterAnimations;
- protected CharacterAnimation m_CurrentCharacterAnimation;
- [SerializeField] protected float m_MinIdleDelay = 30.0f;
- protected float m_IdleDelay;
- // HACK: When map or Chester is closed, wait for n milliseconds before processing the next click,
- // otherwise we might navigate to another location when we should not (e.g. player has just closed map).
- protected float m_DelayForNextClick;
- // HACK: When map or Chester is closed, wait for n milliseconds before processing the next click,
- // otherwise we might navigate to another location when we should not (e.g. player has just closed map).
- protected const float DELAY_NEXT_CLICK = 0.1f;
- // Speech config.
- protected string m_SpeechFolder;
- protected string m_LastSpeech;
- protected int m_SpeechCount;
- // Event sequence.
- [SerializeField] protected int m_EventSequenceMaxItems = 10;
- protected EventSequenceItem[] m_CurrentSequence;
- protected int m_CurrentSequenceItems;
- protected int m_CurrentSequenceIndex;
- protected bool m_IsPlayingSequence;
- protected bool m_SkipCurrentSequence;
- protected bool m_IsSequenceSkippable;
- protected float m_SequenceStartTime;
- protected float m_SequenceWaitDelayBeforeSkip;
- bool m_CanHideLoading;
- protected bool m_IsFirstTime;
- private bool canPressInput; //mycode --rafael
- private float clockToResetInput; //mycode --rafael
- private const float TIME_TO_RESET = 1f; //mycode --rafael
- private const float TIME_FINAL = 0f; //mycode --rafael
- //================================================================================
- //
- //================================================================================
- protected virtual void Awake()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.Awake()...");
- m_CanHideLoading = false;
- canPressInput = true; //mycode --rafael
- clockToResetInput = TIME_TO_RESET; //mycode --rafael
- }
- //================================================================================
- //
- //================================================================================
- void OnLevelWasLoaded(int level)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnLevelWasLoaded()...");
- if (level == (int)m_SceneIndex)
- m_CanHideLoading = true;
- }
- //================================================================================
- //
- //================================================================================
- void OnApplicationPause(bool pauseStatus)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnApplicationPause(" + pauseStatus + ")...");
- if (pauseStatus)
- PlayerData.Instance().SaveData();
- else
- {
- PlayerData.Instance().LoadData();
- AudioController.EnableMusic(PlayerData.Instance().IsBackgroundMusicEnabled());
- }
- }
-
- //================================================================================
- //
- //================================================================================
- void OnApplicationFocus(bool focusStatus)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnApplicationFocus(" + focusStatus + ")...");
- if (!focusStatus)
- PlayerData.Instance().SaveData();
- else
- {
- PlayerData.Instance().LoadData();
- AudioController.EnableMusic(PlayerData.Instance().IsBackgroundMusicEnabled());
- }
- }
- //================================================================================
- //
- //================================================================================
- void OnApplicationQuit()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnApplicationQuit()...");
- PlayerData.Instance().SaveData();
- }
- //================================================================================
- //
- //================================================================================
- protected override void Start()
- {
- m_IsFirstTime = !PlayerData.Instance().DidVisit(m_SceneIndex);
- Map.Instance().Close();
- Options.Instance().Close();
- Chester.Instance().Close();
- Chester.Instance().SetChesterInSceneAnimation(m_ChesterInScene);
- if (m_ChesterRectangle != null)
- Chester.Instance().SetInitialPosition(float.Parse(m_ChesterRectangle.GetActionParameter(0)), float.Parse(m_ChesterRectangle.GetActionParameter(1)));
- Chester.Instance().SetRightItemUsedInSceneCallback(OnRightItemUsedInScene);
- Chester.Instance().SetWrongItemUsedInSceneCallback(OnWrongItemUsedInScene);
- if (m_ChesterRectangle != null)
- m_ChesterRectangle.SetCallback(ProcessAction);
- if (m_CharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_CharacterRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.SetCallback(ProcessAction);
- }
- }
- if (m_OtherCharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_OtherCharacterRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.SetCallback(ProcessAction);
- }
- }
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.SetCallback(ProcessAction);
- }
- }
- if (m_Items != null)
- {
- foreach (ItemCommon item in m_Items)
- item.SetParentScene(this);
- }
- if (m_CharacterAnimations != null)
- {
- foreach (CharacterAnimation characterAnimation in m_CharacterAnimations)
- {
- characterAnimation.SetParentScene(this);
- characterAnimation.SetOnAnimatorFinishedCallback(OnCharacterAnimationFinished);
- characterAnimation.SetOnAnimatorCustomTimelineEvent1Callback(OnCharacterAnimationCustomTimelineEvent1);
- characterAnimation.SetOnSpeechFinishedCallback(OnCharacterSpeechFinished);
- characterAnimation.SetCanRandomizeIdle(!m_IsFirstTime);
- }
- }
- m_LastSpeech = "";
- m_SpeechCount = 0;
- if (m_CurrentSequence == null)
- m_CurrentSequence = new EventSequenceItem[m_EventSequenceMaxItems];
- for (int i = 0; i < m_EventSequenceMaxItems; ++i)
- {
- if (m_CurrentSequence[i] == null)
- m_CurrentSequence[i] = new EventSequenceItem();
- m_CurrentSequence[i].Reset();
- }
- m_CurrentSequenceItems = 0;
- m_CurrentSequenceIndex = 0;
- m_IsPlayingSequence = false;
- m_SkipCurrentSequence = false;
- m_SequenceWaitDelayBeforeSkip = 0.5f;
- base.Start();
- UpdateIdleDelay();
- // HACK: Show loading screen so player does not see a bunch of animations on top of each other.
- //KishiTechUnity.Loading.Loading.Instance().Show();
- Invoke("EnableCharacterAnimatorFirstTime", 0.1f);
- }
-
- //================================================================================
- //
- //================================================================================
- protected virtual void EnableCharacterAnimatorFirstTime()
- {
- if (m_CharacterAnimations != null)
- {
- foreach (CharacterAnimation characterAnimation in m_CharacterAnimations)
- {
- characterAnimation.ChangeToIdle();
- }
- }
- if (m_CanHideLoading)
- KishiTechUnity.Loading.Loading.Instance().Hide();
- PlayFirstEvent();
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void PlayFirstEvent()
- {
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void DoneFirstTime()
- {
- if (m_CharacterAnimations != null)
- {
- foreach (CharacterAnimation characterAnimation in m_CharacterAnimations)
- {
- characterAnimation.SetCanRandomizeIdle(true);
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- void DebugEnableAll()
- {
- if (m_ChesterRectangle != null)
- m_ChesterRectangle.DebugEnable();
- if (m_CharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_CharacterRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.DebugEnable();
- }
- }
- if (m_OtherCharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_OtherCharacterRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.DebugEnable();
- }
- }
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.DebugEnable();
- }
- }
- }
-
- //================================================================================
- //
- //================================================================================
- void DebugDisableAll()
- {
- if (m_ChesterRectangle != null)
- m_ChesterRectangle.DebugDisable();
- if (m_CharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_CharacterRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.DebugDisable();
- }
- }
- if (m_OtherCharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_OtherCharacterRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.DebugDisable();
- }
- }
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.DebugDisable();
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- void UpdateDebugEnabledAll()
- {
- if (m_ChesterRectangle != null)
- m_ChesterRectangle.UpdateDebugEnabled();
- if (m_CharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_CharacterRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.UpdateDebugEnabled();
- }
- }
- if (m_OtherCharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_OtherCharacterRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.UpdateDebugEnabled();
- }
- }
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.UpdateDebugEnabled();
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- public virtual void UpdateOnce()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.UpdateOnce()...");
- }
-
- //================================================================================
- //
- //================================================================================
- protected void EnableNavigationAll()
- {
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.Enable();
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- protected void EnableNavigation(string gotoName)
- {
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle != null && interactiveRectangle.GetActionParameter(0) == gotoName)
- {
- interactiveRectangle.Enable();
- break;
- }
- }
- }
- }
-
- //================================================================================
- //
- //================================================================================
- protected void DisableNavigationAll()
- {
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.Disable();
- }
- }
- }
-
- //================================================================================
- //
- //================================================================================
- protected void DisableNavigation(string gotoName)
- {
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle != null && interactiveRectangle.GetActionParameter(0) == gotoName)
- {
- interactiveRectangle.Disable();
- break;
- }
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- protected void RestorePreviousIsEnabledNavigationAll()
- {
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle != null)
- interactiveRectangle.RestorePreviousIsEnabled();
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- public virtual void OnLevelChanged()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnLevelChanged()...");
- }
- //================================================================================
- //
- //================================================================================
- public virtual void OnPopupClose()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnPopupClose()...");
- }
- //================================================================================
- //
- //================================================================================
- public virtual void OnMapClose()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnMapClose()...");
- }
- //================================================================================
- //
- //================================================================================
- public virtual void OnVideoClose()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnVideoClose()...");
- this.gameObject.SetActive(true);
- AudioManager.Instance().PlayCurrentBGM();
- if (m_IsPlayingSequence)
- {
- if (IsPreviousSequenceIndexValid())
- {
- if (m_CurrentSequence[m_CurrentSequenceIndex - 1].EventType == EventSequenceItem.EventSequenceType.Video)
- {
- ProcessSequence();
- }
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- public virtual void OnChesterOpened()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnChesterOpened()...");
- }
- //================================================================================
- //
- //================================================================================
- public virtual void OnChesterClosed()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnChesterClosed()...");
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnRightItemUsedInScene(ItemEnum item)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnRightItemUsedInScene()...");
- Chester.Instance().Close();
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnWrongItemUsedInScene(ItemEnum item)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnWrongItemUsedInScene()...");
- CharactersCommon[] characters = {
- CharactersCommon.Sam,
- CharactersCommon.Reader,
- CharactersCommon.Sam,
- CharactersCommon.Reader,
- CharactersCommon.Reader
- };
- string[] possibleNumbers = { "7010", "7011", "7012", "7013" };//, "7014" };
-
- int randomValue = Random.Range(0, possibleNumbers.Length);
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, characters[randomValue], possibleNumbers[randomValue]);
- StartSequence(1);
- }
- //================================================================================
- //
- //================================================================================
- public void ChesterSpeechRubberBandNone()
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, CharactersCommon.Reader, "7451");
- StartSequence(1);
- }
-
- //================================================================================
- //
- //================================================================================
- public void ChesterSpeechHoopNone()
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, CharactersCommon.Reader, "7450");
- StartSequence(1);
- }
- //================================================================================
- //
- //================================================================================
- public void ChesterSpeechPillowNone()
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, CharactersCommon.Sam, "7452");
- StartSequence(1);
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnNavigation()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnNavigation()...");
- if (m_CurrentInteractiveRectangle.IsEnabled())
- {
- // Player clicked on an enabled navigation rectangle; start fading. When fade is finished, we load the level inside FinishedFadeOut().
- KishiTechUnity.ScreenFade.ScreenFade.Instance().StartFading(KishiTechUnity.ScreenFade.ScreenFade.FadeType.FadeOut, 0.25f);
- }
- else
- {
- // Player tried to navigate to a blocked location. We might want to give the player some feedback.
- OnBlockedNavigation();
- }
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnBlockedNavigation()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnBlockedNavigation()...");
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnCharacterInteraction()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnCharacterInteraction()...");
- if (m_CurrentInteractiveRectangle.GetActionParameter(0) == "Paige")
- {
- SpeechPaige();
- }
- else
- {
- SpeechReader();
- }
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnOtherCharacterInteraction()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnOtherCharacterInteraction()...");
- }
- //================================================================================
- //
- //================================================================================
- public virtual Vector2 GetChesterPosition()
- {
- return new Vector2(float.Parse(m_ChesterRectangle.GetActionParameter(0)), float.Parse(m_ChesterRectangle.GetActionParameter(1)));
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OpenChester(float x, float y)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OpenChester()...");
- Chester.Instance().Open(this, x, y);
- }
- //================================================================================
- //
- //================================================================================
- protected override void FinishedFadeOut()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.FinishedFadeOut()...");
-
- Chester.Instance().CloseInstantly();
- KishiTechUnity.Loading.Loading.Instance().Show();
- // We know from ProcessAction that this RRInteractiveRectangle is of type kActionTypeLoadLevel, so we called started the fade out there.
- // When fade out is over, we load the level defined as Action param 0.
- Application.LoadLevel(m_CurrentInteractiveRectangle.GetActionParameter(0));
- }
-
- //================================================================================
- //
- //================================================================================
- public virtual void ProcessAction(RRInteractiveRectangle interactiveRectangle)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.ProcessAction()...");
- if (Chester.Instance().IsOpened() || Chester.Instance().IsOpening() || Map.Instance().IsOpened())
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Cancelling SceneCommon.ProcessAction(): Chester or Map is opened.");
- return;
- }
- m_CurrentInteractiveRectangle = interactiveRectangle;
-
- switch (m_CurrentInteractiveRectangle.GetActionType())
- {
- case ActionType.Navigation:
- {
- OnNavigation();
- } break;
-
- case ActionType.OtherCharacter:
- {
- OnOtherCharacterInteraction();
- } break;
-
- case ActionType.Character:
- {
- OnCharacterInteraction();
- } break;
-
- case ActionType.Chester:
- {
- OpenChester(float.Parse(m_CurrentInteractiveRectangle.GetActionParameter(0)), float.Parse(m_CurrentInteractiveRectangle.GetActionParameter(1)));
- } break;
- }
- }
- //================================================================================
- //
- //================================================================================
- protected virtual bool CheckHUD()
- {
- if (m_HUD != null)
- {
- foreach (HUDCommon hud in m_HUD)
- {
- if (hud.WasUpAsButton() || hud.DidExitWhileDown())
- {
- hud.ClearWasUpAsButton();
- hud.ClearDidExitWhileDown();
- return true;
- }
- }
- }
-
- return false;
- }
-
- //================================================================================
- //
- //================================================================================
- protected virtual bool CheckItems()
- {
- if (m_Items != null)
- {
- foreach (ItemCommon item in m_Items)
- {
- if (item.WasUpAsButton())
- {
- item.ClearWasUpAsButton();
- return true;
- }
- }
- }
-
- return false;
- }
-
- //================================================================================
- //
- //================================================================================
- protected virtual bool CheckChester(float x, float y)
- {
- if (m_ChesterRectangle != null && m_ChesterRectangle.GetActionType() == ActionType.Chester)
- return m_ChesterRectangle.ExecuteIfPointInside(x, y);
-
- return false;
- }
-
- //================================================================================
- //
- //================================================================================
- protected virtual bool CheckCharacters(float x, float y)
- {
- if (m_CharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_CharacterRectangles)
- {
- if (interactiveRectangle.ExecuteIfPointInside(x, y))
- return true;
- }
- }
-
- return false;
- }
-
- //================================================================================
- //
- //================================================================================
- protected virtual bool CheckOtherCharacters(float x, float y)
- {
- if (m_OtherCharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_OtherCharacterRectangles)
- {
- if (interactiveRectangle.ExecuteIfPointInside(x, y))
- return true;
- }
- }
-
- return false;
- }
-
- //================================================================================
- //
- //================================================================================
- protected virtual bool CheckNavigation(float x, float y)
- {
- if (PlayerData.Instance().IsPracticeMode())
- return false;
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle.ExecuteIfPointInside(x, y))
- return true;
-
- // For navigation rectangles, we ignore the InteractiveRectangle.IsEnabled flag,
- // because when a location is blocked (navigation rectangle is disabled) we
- // might need to give the player some feedback.
- // We decide what to do inside OnNavigation() method.
- if (interactiveRectangle.IsPointInside(x, y) && !interactiveRectangle.IsEnabled())
- {
- interactiveRectangle.ExecuteCommand();
- // We return false so we don't skip the sequenced events feedback.
- return false;
- }
- }
- }
-
- return false;
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void CheckAll(float x, float y)
- {
- // HUD priority is #1.
- bool clickedOnHUD = CheckHUD();
- if (!clickedOnHUD)
- {
- // Chester priority is #2.
- bool clickedOnChester = CheckChester(x, y);
- if (!clickedOnChester)
- {
- // Game characters priority is #3.
- bool clickedOnCharacter = CheckCharacters(x, y);
- if (!clickedOnCharacter)
- {
- // Other game characters priority is #4.
- bool clickedOnOtherCharacter = CheckOtherCharacters(x, y);
- if (!clickedOnOtherCharacter)
- {
- // Item priority is #5.
- bool clickedOnItem = CheckItems();
- if (!clickedOnItem)
- {
- // Navigation priority is #6.
- if (CheckNavigation(x, y))
- {
- // We do not skip the Video event. If we did, the player would never see the "From EdgeOfCloudNine to RaingearIsland" and
- // "From RaingearIsland to EdgeOfCloudNine" videos (down and up ship videos).
- if (m_IsPlayingSequence
- && m_IsSequenceSkippable
- && IsPreviousSequenceIndexValid()
- && m_CurrentSequence[m_CurrentSequenceIndex - 1].EventType != EventSequenceItem.EventSequenceType.Video)
- {
- SkipSequence();
- }
- }
- }
- }
- }
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- public void CheckAllDown(float x, float y)
- {
- }
-
- //================================================================================
- //
- //================================================================================
- protected virtual void SetCurrentToChester()
- {
- if (m_ChesterRectangle != null)
- {
- m_CurrentInteractiveRectangle = m_ChesterRectangle;
- }
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void SetCurrentToCharacter(string name)
- {
- if (m_CharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_CharacterRectangles)
- {
- if (interactiveRectangle.GetActionParameter(0) == name)
- {
- m_CurrentInteractiveRectangle = interactiveRectangle;
- break;
- }
- }
- }
- }
-
- //================================================================================
- //
- //================================================================================
- protected virtual void SetCurrentToOtherCharacter(string name)
- {
- if (m_OtherCharacterRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_OtherCharacterRectangles)
- {
- if (interactiveRectangle.GetActionParameter(0) == name)
- {
- m_CurrentInteractiveRectangle = interactiveRectangle;
- break;
- }
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void SetCurrentToNavigation(string name)
- {
- if (m_NavigationRectangles != null)
- {
- foreach (RRInteractiveRectangle interactiveRectangle in m_NavigationRectangles)
- {
- if (interactiveRectangle.GetActionParameter(0) == name)
- {
- m_CurrentInteractiveRectangle = interactiveRectangle;
- break;
- }
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnAnimatorFinished()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnAnimatorFinished()...");
- //ProcessSequence();
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnCharacterAnimationFinished(CharacterAnimation character)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnCharacterAnimationFinished(" + character + ")...");
- if (m_IsPlayingSequence)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnCharacterAnimationFinished(" + character + ")...");
- if (IsPreviousSequenceIndexValid())
- {
- int previousSequenceIndex = m_CurrentSequenceIndex - 1;
- if (m_CurrentSequence[previousSequenceIndex].EventType == EventSequenceItem.EventSequenceType.Animation
- || m_CurrentSequence[previousSequenceIndex].EventType == EventSequenceItem.EventSequenceType.AnimationWithSfx)
- {
- int characterIndex = (int)m_CurrentSequence[previousSequenceIndex].Values[0];
- if (m_CharacterAnimations[characterIndex].Equals(character))
- ProcessSequence();
- }
- }
- }
- }
-
- //================================================================================
- //
- //================================================================================
- protected virtual void OnCharacterAnimationCustomTimelineEvent1(CharacterAnimation character)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnCharacterAnimationCustomTimelineEvent1(" + character + ")...");
- }
- //================================================================================
- //
- //================================================================================
- protected void DecSpeechCount()
- {
- if (m_SpeechCount > 0)
- --m_SpeechCount;
- }
- //================================================================================
- //
- //================================================================================
- protected void IncSpeechCount()
- {
- ++m_SpeechCount;
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnCharacterSpeechFinished(CharacterAnimation character)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnCharacterSpeechFinished(" + character + ")...");
- DecSpeechCount();
- if (m_IsPlayingSequence)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnCharacterSpeechFinished(" + character + ")...");
- if (IsPreviousSequenceIndexValid())
- {
- int previousSequenceIndex = m_CurrentSequenceIndex - 1;
- // HACK: When event type is DoubleSpeech, this method will be called twice. So change it from DoubleSpeech to Speech the first time.
- // If we do not do this, the next event in the sequence will not work properly.
- if (m_CurrentSequence[previousSequenceIndex].EventType == EventSequenceItem.EventSequenceType.DoubleSpeech)
- {
- m_CurrentSequence[previousSequenceIndex].EventType = EventSequenceItem.EventSequenceType.Speech;
- m_CurrentSequence[previousSequenceIndex].Values[0] = m_CurrentSequence[previousSequenceIndex].Values[1];
- return;
- }
- if (m_CurrentSequence[previousSequenceIndex].EventType == EventSequenceItem.EventSequenceType.Speech)
- {
- int characterIndex = (int)m_CurrentSequence[previousSequenceIndex].Values[0];
- //string speechID = m_CurrentSequence[m_CurrentSequenceIndex - 1].Values[1].ToString();
- if (m_CharacterAnimations[characterIndex].Equals(character))// && speechID.Equals(m_LastSpeech))
- ProcessSequence();
- }
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- public bool IsSomebodySpeaking()
- {
- return m_SpeechCount > 0;
- }
- //================================================================================
- //
- //================================================================================
- public virtual void CharacterTriggerAnimation(int characterIndex, int animationIndex, string triggerName)
- {
- m_CharacterAnimations[characterIndex].TriggerAnimation(animationIndex, triggerName);
- }
- //================================================================================
- //
- //================================================================================
- public virtual void CharacterPlaySpeech(int characterIndex, string speechID)
- {
- m_LastSpeech = speechID;
- m_CharacterAnimations[characterIndex].PlaySpeech(m_SpeechFolder, m_LastSpeech);
- IncSpeechCount();
- }
- //================================================================================
- //
- //================================================================================
- public virtual void CharacterPlayDoubleSpeech(int characterIndex, int characterIndex2, string speechID)
- {
- m_LastSpeech = speechID;
- m_CharacterAnimations[characterIndex].PlaySpeech(m_SpeechFolder, m_LastSpeech);
- m_CharacterAnimations[characterIndex2].PlaySpeechAnimationOnly(m_SpeechFolder, m_LastSpeech);
- IncSpeechCount();
- IncSpeechCount();
- }
- //================================================================================
- //
- //================================================================================
- public virtual void CharacterPlaySpeechAnimationOnly(int characterIndex, string speechID)
- {
- m_LastSpeech = speechID;
- m_CharacterAnimations[characterIndex].PlaySpeechAnimationOnly(m_SpeechFolder, m_LastSpeech);
- IncSpeechCount();
- }
- //================================================================================
- //
- //================================================================================
- public string SpeechFolder
- {
- get { return m_SpeechFolder; }
- }
- //================================================================================
- //
- //================================================================================
- public bool IsPlayingSequence()
- {
- return m_IsPlayingSequence;
- }
- //================================================================================
- //
- //================================================================================
- public bool IsSkippingCurrentSequence()
- {
- return m_SkipCurrentSequence;
- }
- //================================================================================
- //
- //================================================================================
- public virtual void SpeechReader()
- {
- }
- //================================================================================
- //
- //================================================================================
- public virtual void ReaderRandomSpeech(bool ignoreSomebodySpeaking)
- {
- }
- //================================================================================
- //
- //================================================================================
- public virtual void SamRandomSpeech(bool ignoreSomebodySpeaking)
- {
- }
- //================================================================================
- //
- //================================================================================
- public virtual void SpeechPaige()
- {
- }
- //================================================================================
- //
- //================================================================================
- public virtual void PaigeRandomSpeech(bool ignoreSomebodySpeaking)
- {
- }
- //================================================================================
- //
- //================================================================================
- public void DisableColliders()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.DisableColliders()...");
- foreach (ItemCommon item in m_Items)
- item.Disable();
-
- foreach (HUDCommon hud in m_HUD)
- hud.Disable();
- DisableNavigationAll();
- }
-
- //================================================================================
- //
- //================================================================================
- public void RestoreColliders()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.RestoreColliders()...");
- foreach (ItemCommon item in m_Items)
- {
- //item.RestorePrevious();
- item.Enable();
- item.ClearWasUpAsButton();
- }
-
- foreach (HUDCommon hud in m_HUD)
- {
- //hud.RestorePrevious();
- hud.Enable();
- hud.ClearWasUpAsButton();
- }
- RestorePreviousIsEnabledNavigationAll();
- // We are assuming that RestoreColliders is called when map or Chester is closed.
- m_DelayForNextClick = Time.time + DELAY_NEXT_CLICK;
- }
- //================================================================================
- //
- //================================================================================
- protected void SetSequence(int index, EventSequenceItem.EventSequenceType eventSequenceType, params System.Object[] values)
- {
- if (index <= m_CurrentSequence.Length) {
- m_CurrentSequence [index].Setup (eventSequenceType, values);
- } else {
- Debug.Log("Something goes wrong: " + index);
- }
- }
- //================================================================================
- //
- //================================================================================
- protected void SetSequence(int index, EventSequenceItem.EventSequenceType eventSequenceType, System.Action callback, params System.Object[] values)
- {
- m_CurrentSequence[index].Setup(eventSequenceType, callback, values);
- }
- //================================================================================
- //
- //================================================================================
- protected void SetSequenceCallbackWithParameters(int index, EventSequenceItem.EventSequenceType eventSequenceType, System.Action<System.Object[]> callback, params System.Object[] values)
- {
- m_CurrentSequence[index].SetupCallbackWithParameters(eventSequenceType, callback, values);
- }
- //================================================================================
- //
- //================================================================================
- bool IsPreviousSequenceIndexValid()
- {
- return m_CurrentSequenceIndex < m_CurrentSequence.Length && m_CurrentSequenceIndex > 0;
- }
- //================================================================================
- //
- //================================================================================
- protected void NewSequence()
- {
- if (m_IsPlayingSequence)
- SkipSequence();
- }
- //================================================================================
- //
- //================================================================================
- protected void StartSequence(int sequenceItems, bool isSequenceSkippable = true)
- {
- if (PlayVideo.Instance().IsOpened())
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("StartSequence not started - Video is opened!");
- return;
- }
- if (m_IsPlayingSequence)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("There is a sequence being played, skipping to start a new one...");
- SkipSequence();
- }
- m_CurrentSequenceItems = Mathf.Min(sequenceItems, m_EventSequenceMaxItems);
- m_CurrentSequenceIndex = 0;
- m_IsPlayingSequence = true;
- m_SkipCurrentSequence = false;
- m_SequenceStartTime = Time.time;
- m_IsSequenceSkippable = isSequenceSkippable;
- ProcessSequence();
- }
- //================================================================================
- //
- //================================================================================
- protected void SkipSequence()
- {
- m_SkipCurrentSequence = true;
- for (int i = 0; i < m_CharacterAnimations.Length; ++i)
- m_CharacterAnimations[i].StopSpeech();
- if (Chester.Instance().IsOpening())// || Chester.Instance().IsOpened())
- Chester.Instance().CloseInstantly();
- if (IsPreviousSequenceIndexValid())
- {
- // There is a video playing in the current sequence event.
- if (m_CurrentSequence[m_CurrentSequenceIndex - 1].EventType == EventSequenceItem.EventSequenceType.Video)
- {
- PlayVideo.Instance().Stop();
- }
- }
- ProcessSequence();
- }
- //================================================================================
- //
- //================================================================================
- protected void ProcessSequence()
- {
- if (m_SkipCurrentSequence)
- {
- for (int i = m_CurrentSequenceIndex; i < m_CurrentSequenceItems; ++i)
- {
- if (m_CurrentSequence[i].DidProcess || m_CurrentSequence[i].EventType == EventSequenceItem.EventSequenceType.Unknown)
- continue;
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("ProcessSequence: " + m_CurrentSequenceIndex + ", " + m_CurrentSequence[m_CurrentSequenceIndex]);
- m_CurrentSequence[i].DidProcess = true;
- if (m_CurrentSequence[i].EventType == EventSequenceItem.EventSequenceType.Callback)
- {
- if (m_CurrentSequence[i].Callback != null)
- m_CurrentSequence[i].Callback();
- }
- else if (m_CurrentSequence[i].EventType == EventSequenceItem.EventSequenceType.CallbackWithParameters)
- {
- if (m_CurrentSequence[i].CallbackWithParameters != null)
- m_CurrentSequence[i].CallbackWithParameters(m_CurrentSequence[i].Values.ToArray());
- }
- else if (m_CurrentSequence[i].EventType == EventSequenceItem.EventSequenceType.Video)
- {
- VideoType videoType = (VideoType)m_CurrentSequence[i].Values[0];
- if ((int)videoType < (int)VideoType.Quantity)
- PlayerData.Instance().UnlockVideo(videoType);
- }
- }
- OnSequenceFinished();
- return;
- }
- if (m_CurrentSequenceIndex < m_CurrentSequenceItems)
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("ProcessSequence: " + m_CurrentSequenceIndex + ", " + m_CurrentSequence[m_CurrentSequenceIndex]);
- bool callProcessSequence = false;
- m_CurrentSequence[m_CurrentSequenceIndex].DidProcess = true;
- switch (m_CurrentSequence[m_CurrentSequenceIndex].EventType)
- {
- case EventSequenceItem.EventSequenceType.Speech:
- CharacterPlaySpeech((int)m_CurrentSequence[m_CurrentSequenceIndex].Values[0],
- m_CurrentSequence[m_CurrentSequenceIndex].Values[1].ToString());
- break;
- case EventSequenceItem.EventSequenceType.Animation:
- CharacterTriggerAnimation((int)m_CurrentSequence[m_CurrentSequenceIndex].Values[0],
- (int)m_CurrentSequence[m_CurrentSequenceIndex].Values[1],
- m_CurrentSequence[m_CurrentSequenceIndex].Values[2].ToString());
- break;
- case EventSequenceItem.EventSequenceType.AnimationWithSfx:
- CharacterTriggerAnimation((int)m_CurrentSequence[m_CurrentSequenceIndex].Values[0],
- (int)m_CurrentSequence[m_CurrentSequenceIndex].Values[1],
- m_CurrentSequence[m_CurrentSequenceIndex].Values[2].ToString());
-
- AudioManager.Instance().PlaySFX(m_CurrentSequence[m_CurrentSequenceIndex].Values[3].ToString());
- break;
- case EventSequenceItem.EventSequenceType.AnimationNoWait:
- callProcessSequence = true;
- CharacterTriggerAnimation((int)m_CurrentSequence[m_CurrentSequenceIndex].Values[0],
- (int)m_CurrentSequence[m_CurrentSequenceIndex].Values[1],
- m_CurrentSequence[m_CurrentSequenceIndex].Values[2].ToString());
- break;
- case EventSequenceItem.EventSequenceType.Callback:
- callProcessSequence = true;
-
- if (m_CurrentSequence[m_CurrentSequenceIndex].Callback != null)
- m_CurrentSequence[m_CurrentSequenceIndex].Callback();
- break;
- case EventSequenceItem.EventSequenceType.CallbackWithParameters:
- callProcessSequence = true;
-
- if (m_CurrentSequence[m_CurrentSequenceIndex].CallbackWithParameters != null)
- m_CurrentSequence[m_CurrentSequenceIndex].CallbackWithParameters(m_CurrentSequence[m_CurrentSequenceIndex].Values.ToArray());
- break;
- case EventSequenceItem.EventSequenceType.Video:
- //callProcessSequence = true;
- VideoType videoType = (VideoType)m_CurrentSequence[m_CurrentSequenceIndex].Values[0];
- if ((int)videoType < (int)VideoType.Quantity)
- PlayerData.Instance().UnlockVideo(videoType);
- this.gameObject.SetActive(false);
- AudioManager.Instance().StopBGM();
- PlayVideo.Instance().LoadAndPlay(this, videoType, null, PlayerPrefs.GetInt("language"));
- break;
- case EventSequenceItem.EventSequenceType.DoubleSpeech:
- CharacterPlayDoubleSpeech((int)m_CurrentSequence[m_CurrentSequenceIndex].Values[0],
- (int)m_CurrentSequence[m_CurrentSequenceIndex].Values[1],
- m_CurrentSequence[m_CurrentSequenceIndex].Values[2].ToString());
- break;
- case EventSequenceItem.EventSequenceType.GetItem:
- callProcessSequence = true;
- break;
- case EventSequenceItem.EventSequenceType.UseItem:
- callProcessSequence = true;
- break;
- case EventSequenceItem.EventSequenceType.Unknown:
- callProcessSequence = true;
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().LogWarning("ProcessSequence --- processed an Unknown sequence. Is that correct???");
- break;
- }
- ++m_CurrentSequenceIndex;
- if (callProcessSequence)
- ProcessSequence();
- }
- else
- {
- OnSequenceFinished();
- }
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnSequenceFinished()
- {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Calling SceneCommon.OnSequenceFinished()...");
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("m_SkipCurrentSequence: " + m_SkipCurrentSequence);
- for (int i = 0; i < m_EventSequenceMaxItems; ++i)
- m_CurrentSequence[i].Reset();
- m_CurrentSequenceItems = 0;
- m_CurrentSequenceIndex = 0;
- m_IsPlayingSequence = false;
- m_SkipCurrentSequence = false;
- }
- //================================================================================
- //
- //================================================================================
- protected virtual void OnIdle()
- {
- }
- //================================================================================
- //
- //================================================================================
- protected void UpdateIdleDelay()
- {
- m_IdleDelay = Time.time + m_MinIdleDelay;
- }
- //================================================================================
- //
- //================================================================================
- protected void TimeToNextInput() //mycode --rafael --> use this to avoid constant clicks.
- {
- if (!canPressInput) {
- clockToResetInput -= Time.deltaTime;
- if (clockToResetInput <= TIME_FINAL){
- clockToResetInput = TIME_TO_RESET;
- canPressInput = true;
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- protected override void Update()
- {
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().Update();
- // Chester, Options and Map have priority over game scene when it is opened.
- if (!m_CanUpdate
- || Time.time <= m_DelayForNextClick
- || Chester.Instance().IsOpening()
- || Options.Instance().IsOpened()
- || Map.Instance ().IsOpened()
- )
- return;
- //=====
- // TODO: REMOVE ME - temp code (for debug purposes).
- if (Input.GetKeyDown(KeyCode.F6))
- {
- //PlayerData.Instance().CheatAllItemsInInventory();
- }
- if (Time.time > m_IdleDelay && !m_IsPlayingSequence)
- {
- OnIdle();
- UpdateIdleDelay();
- }
- if (Input.GetMouseButtonDown(KishiTechUnity.KTInput.MouseButton.kLeft) || Input.GetMouseButtonUp(KishiTechUnity.KTInput.MouseButton.kLeft))
- UpdateIdleDelay();
- // A sequence is playing.
- if (m_IsPlayingSequence)
- {
- if (m_IsSequenceSkippable)
- {
- if (Time.time > m_SequenceStartTime + m_SequenceWaitDelayBeforeSkip)
- {
- if (Input.GetMouseButtonUp(KishiTechUnity.KTInput.MouseButton.kLeft))
- {
- SkipSequence();
- return;
- }
- }
- }
- else
- {
- return;
- }
- }
- // Chester has priority over game scene when it is open.
- if (Chester.Instance().IsOpened())
- {
- clockToResetInput = TIME_FINAL; //mycode --rafael --> use this to reset clock. Without this, while chester is opened, the time is fronzen.
- if (Item.isDragingItem == true || Chester.isDragingChester == true){// my code --rafael. Isto evita o bug de arrastar o baú ou item quando algum personagem fala.
- SkipSequence();
- }
- Chester.Instance().CheckLocker(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
- if (Input.GetMouseButtonDown(KishiTechUnity.KTInput.MouseButton.kLeft))
- {
- //KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Input.mousePosition.x = " + Input.mousePosition.x + ", Input.mousePosition.y = " + Input.mousePosition.y + ", Screen.height - Input.mousePosition.y = " + (Screen.height - Input.mousePosition.y));
- Chester.Instance().CheckAllDown(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
- }
- else if (Input.GetMouseButtonUp(KishiTechUnity.KTInput.MouseButton.kLeft))
- {
- //KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Input.mousePosition.x = " + Input.mousePosition.x + ", Input.mousePosition.y = " + Input.mousePosition.y + ", Screen.height - Input.mousePosition.y = " + (Screen.height - Input.mousePosition.y));
- Chester.Instance().CheckAll(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
- }
- return;
- }
- if (Input.GetMouseButton (KishiTechUnity.KTInput.MouseButton.kLeft)) {
- KishiTechUnity.KishiTechDebug.KTDebug.Instance ().Log ("Input.mousePosition.x = " + Input.mousePosition.x + ", Input.mousePosition.y = " + Input.mousePosition.y + ", Screen.height - Input.mousePosition.y = " + (Screen.height - Input.mousePosition.y));
- CheckAllDown (Input.mousePosition.x, Screen.height - Input.mousePosition.y);
- } else if (Input.GetMouseButtonUp (KishiTechUnity.KTInput.MouseButton.kLeft) && canPressInput) { //mycode --rafael --> add canPressInput to condition.
- canPressInput = false; //mycode --rafael
- //KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("Input.mousePosition.x = " + Input.mousePosition.x + ", Input.mousePosition.y = " + Input.mousePosition.y + ", Screen.height - Input.mousePosition.y = " + (Screen.height - Input.mousePosition.y));
- CheckAll (Input.mousePosition.x, Screen.height - Input.mousePosition.y);
- }
- TimeToNextInput (); //mycode --rafael
- }
-
- } // public class public class SceneCommon : KishiTechUnity.ScreenResolution.SceneRoot
- } // namespace ReaderRabbit
|