123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095 |
- //================================================================================
- //
- //================================================================================
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using SimpleJSON;
- //================================================================================
- //
- //================================================================================
- namespace ReaderRabbit
- {
- //================================================================================
- //
- //================================================================================
- public class SceneSillySandwichShop : SceneCommon
- {
- private enum Characters
- {
- Reader = CharactersCommon.Reader,
- Sam = CharactersCommon.Sam,
- Paige = CharactersCommon.Paige,
- Chester = CharactersCommon.Chester,
- LizardCashier = CharactersCommon.StartSceneSpecific,
- }
- private const int WORD_LIST_1_SIZE = 15;
- private const int WORD_LIST_2_SIZE = 27;
- private const int WORD_LIST_3_SIZE = 15;
-
- [SerializeField] private IngredientSelectionMachine m_IngredientSelectionMachine;
- [SerializeField] private CoinManager m_CoinManager;
- [SerializeField] private SandwichManager m_SandwichManager;
- [SerializeField] private SandwichHook m_SandwichHook;
- [SerializeField] private CollectableMarble m_Marble;
-
- private IngredientDescriptor m_SelectedIngredient;
- private IngredientDescriptor m_DraggedIngredient;
- private SpriteRenderer m_DraggedIngredientSprite;
- private int m_CurrentMinigameLevel;
- private bool m_SandwichIsClosing;
- private Vector3 m_PreviousMousePosition;
- private int m_WrongGuesses;
- private bool m_NotEnoughMoneySpchHeard;
- private bool m_TooMuchMoneySpchHeard;
- private int m_IdleHelpIndex;
- private int m_NumItemsUnlocked;
- private int m_MainCharSpchIndex;
- private int m_NumClicksPaige;
- private int m_ClawClickedCount;
- private bool m_FirstToppingSpchHeard;
- private bool m_RingBellSamSpchHeard;
- private int lang;
- //================================================================================
- //
- //================================================================================
- protected override void Start()
- {
- base.Start();
- //============================================================================
- //
- //============================================================================
- lang = PlayerPrefs.GetInt("language");
- if (lang == 0)
- m_SpeechFolder = "Resources_DA/Audio/SillySandwichShop_Speech";
- else if (lang == 1)
- m_SpeechFolder = "Resources_EN/Audio/SillySandwichShop_Speech";
- else if (lang == 2)
- m_SpeechFolder = "Resources_NO/Audio/SillySandwichShop_Speech";
- else if (lang == 3)
- m_SpeechFolder = "Resources_SP/Audio/SillySandwichShop_Speech";
- else if (lang == 4)
- m_SpeechFolder = "Resources_SW/Audio/SillySandwichShop_Speech";
- //============================================================================
- //
- //============================================================================
- PlayerData.Instance().SetVisitedSillySandwichShop(true);
- PlayerData.Instance().SetCurrentLocation(Location.SillySandwichShop);
- PlayerData.Instance().UnlockActivity(Activity.SillySandwichShop);
- AudioManager.Instance().PlayBGM("BGM_SillySandwichShop");
- this.m_WrongGuesses = 0;
- this.m_IdleHelpIndex = 0;
- this.m_NumItemsUnlocked = 0;
- this.m_MainCharSpchIndex = 0;
- this.m_NumClicksPaige = 0;
- this.m_NotEnoughMoneySpchHeard = false;
- this.m_TooMuchMoneySpchHeard = false;
- this.m_IngredientSelectionMachine.Owner = this;
- this.m_RingBellSamSpchHeard = false;
- this.m_ClawClickedCount = 0;
- // TODO: Load the saved level
- this.m_CurrentMinigameLevel = PlayerData.Instance().GetActivityLevel(Activity.SillySandwichShop);
- this.m_SandwichIsClosing = false;
- m_Marble.SetParentScene(this);
- KishiTechUnity.ScreenResolution.ScreenResolutionManager.Instance().ForceUpdateGameObject(m_Marble.gameObject, false);
- LoadIngredientsDescriptions();
- }
- //================================================================================
- //
- //================================================================================
- protected override void PlayFirstEvent()
- {
- base.PlayFirstEvent();
- if (!PlayerData.Instance().IsPracticeMode())
- {
- if (m_IsFirstTime)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19300");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19301");
- SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19302");
- SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19303");
- SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19304");
- SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19305");
- SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19306");
- SetSequence(7, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19307");
- SetSequence(8, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19308");
- SetSequence(9, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19309");
- StartSequence(10);
- }
- else
- {
- int randomNumber = Random.Range(0, 1);
- string [] possibleSpeeches = {"19350", "19351"};
-
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, possibleSpeeches[randomNumber]);
- StartSequence(1);
- }
- }
- else
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19300");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19301");
- SetSequence(2, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19302");
- SetSequence(3, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19303");
- SetSequence(4, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19304");
- SetSequence(5, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19305");
- SetSequence(6, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19306");
- SetSequence(7, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19307");
- SetSequence(8, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19308");
- SetSequence(9, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19309");
- StartSequence(10);
- }
- }
- //================================================================================
- //
- //================================================================================
- public void OnChangeIngredient()
- {
- if (m_SandwichIsClosing)
- {
- GivePrize();
- return;
- }
- if (m_DraggedIngredient != null)
- {
- GameObject.Destroy(m_DraggedIngredient.gameObject);
- m_DraggedIngredient = null;
- m_DraggedIngredientSprite = null;
- }
- m_CoinManager.DisableAllCoins();
- }
- //================================================================================
- //
- //================================================================================
- public void PlayIngredientName(IngredientDescriptor ingredient)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, ingredient.SoundId);
- StartSequence(1);
- }
- //================================================================================
- //
- //================================================================================
- public void TriggerMinigameStart(IngredientDescriptor ingredient)
- {
- if (m_SandwichIsClosing)
- {
- GivePrize();
- return;
- }
- int numberOfSpeeches = 0;
- NewSequence();
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, ingredient.SoundId);
- if (m_SelectedIngredient == null)
- {
- if (!ingredient.Purchased)
- {
- AudioManager.Instance().PlaySFX("1806");
- if (!m_FirstToppingSpchHeard)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19700");
- m_FirstToppingSpchHeard = true;
- }
- int randomNumber = Random.Range(5, 9);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "1970" + randomNumber);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19710");
- KishiTechUnity.KishiTechDebug.KTDebug.Instance().Log("ingredient.Price: " + ingredient.Price);
- numberOfSpeeches = SayPrice(ingredient.Price, numberOfSpeeches);
- }
- else
- {
- if (m_SandwichManager.IsIngredientMaxed(ingredient))
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19746");
- }
- }
- }
- else
- {
- if (!ingredient.Purchased)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19715");
- numberOfSpeeches = SayPrice(ingredient.Price, numberOfSpeeches);
- AudioManager.Instance().PlaySFX("19711");
- if (m_CoinManager.TotalPrice == 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19716");
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19717");
- }
- }
- else
- {
- if (m_SandwichManager.IsIngredientMaxed(ingredient))
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19746");
- }
- }
- }
- m_SelectedIngredient = ingredient;
- m_WrongGuesses = 0;
- m_CoinManager.Setup(ingredient.AvailableCoins[0],
- ingredient.AvailableCoins[1],
- ingredient.AvailableCoins[2],
- ingredient.AvailableCoins[3]);
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- private void LoadIngredientsDescriptions()
- {
- TextAsset jsonText = null;
- if(lang == 0) jsonText = Resources.Load<TextAsset>("Resources_DA/SillySandwichShop/r1ia2");
- else if(lang == 1) jsonText = Resources.Load<TextAsset>("Resources_EN/SillySandwichShop/r1ia2");
- else if (lang == 2) jsonText = Resources.Load<TextAsset>("Resources_NO/SillySandwichShop/r1ia2");
- else if (lang == 3) jsonText = Resources.Load<TextAsset>("Resources_SP/SillySandwichShop/r1ia2");
- else if (lang == 4) jsonText = Resources.Load<TextAsset>("Resources_SW/SillySandwichShop/r1ia2");
- JSONNode json = JSONNode.Parse(jsonText.text);
-
- JSONNode currentLevelWordLists = json["DataSet"]["Level_"+m_CurrentMinigameLevel];
- int wordListSize = 0;
-
- if (currentLevelWordLists == 1)
- {
- wordListSize = WORD_LIST_1_SIZE;
- }
- else if (currentLevelWordLists == 2)
- {
- wordListSize = WORD_LIST_2_SIZE;
- }
- else
- {
- wordListSize = WORD_LIST_3_SIZE;
- }
-
- m_IngredientSelectionMachine.SetupIngredientsDescriptions(currentLevelWordLists, wordListSize);
- }
- //================================================================================
- //
- //================================================================================
- public void OnClickRingBell()
- {
- if (m_SandwichIsClosing)
- {
- GivePrize();
- return;
- }
- if (m_SelectedIngredient == null)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19550");
- StartSequence(1);
- }
- else
- {
- m_CoinManager.UpdateTotalPrice();
- if (m_CoinManager.TotalPrice == 0)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19603");
- StartSequence(0);
- }
- else if (!m_SelectedIngredient.Purchased)
- {
- m_CoinManager.UpdateTotalPrice();
- if (m_CoinManager.TotalPrice == m_SelectedIngredient.Price)
- {
- int numberOfSpeeches = 0;
- int randomNumber = Random.Range(0, 3);
- int randomNumber2 = Random.Range(0, 4);
- string[] possibleSpeeches = { "19400", "19401", "19402", "19403" };
- string[] possibleSpeeches2 = { "19404", "19405", "19406", "19407", "19408" };
- NewSequence();
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, possibleSpeeches[randomNumber]);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, possibleSpeeches2[randomNumber2]);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Callback, PlayUnlockSfx);
- if (m_NumItemsUnlocked == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19415");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19416");
- }
- else if (m_NumItemsUnlocked == 2)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19554");
- }
- else if (m_NumItemsUnlocked == 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19417");
- }
- StartSequence(numberOfSpeeches++);
- m_SelectedIngredient.Purchased = true;
- AudioManager.Instance().PlaySFX("19420");
- m_CoinManager.DisableAllCoins(false);
- m_IngredientSelectionMachine.UpdateIngredientsAreaBorder(m_SelectedIngredient);
- m_WrongGuesses = 0;
- m_NumItemsUnlocked++;
- }
- else
- {
- SayIncorrectPrice();
- }
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- public void PlayUnlockSfx()
- {
- AudioManager.Instance().PlaySFX("19410");
- }
- //================================================================================
- //
- //================================================================================
- public void OnClickLizard()
- {
- int numberOfSpeeches = 0;
- NewSequence();
- if (m_SelectedIngredient == null)
- {
- if (m_NumItemsUnlocked == 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19550");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19551");
- }
- else if (m_NumItemsUnlocked == 1 && m_SandwichManager.GetNumberOfDifferendIngredients() == 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19552");
- }
- else if (m_NumItemsUnlocked == 1 && m_SandwichManager.GetNumberOfDifferendIngredients() > 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19553");
- }
- else if (m_NumItemsUnlocked > 1 && m_SandwichManager.GetNumberOfDifferendIngredients() < 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19554");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19555");
- }
- else if (m_NumItemsUnlocked > 2)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19556");
- }
- }
- else
- {
- if (m_CoinManager.TotalPrice == 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19560");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19561");
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19562");
- }
- }
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnOtherCharacterInteraction()
- {
- base.OnOtherCharacterInteraction();
- OnClickLizard();
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechReader()
- {
- base.SpeechReader();
- m_MainCharSpchIndex++;
- if (m_MainCharSpchIndex > 4)
- {
- m_MainCharSpchIndex = 1;
- }
- NewSequence();
- if (m_MainCharSpchIndex == 1)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19650");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19651");
- }
- else if (m_MainCharSpchIndex == 2)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19652");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19653");
- }
- else if (m_MainCharSpchIndex == 3)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19654");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19655");
- }
- else if (m_MainCharSpchIndex == 4)
- {
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19656");
- SetSequence(1, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19657");
- }
- StartSequence(2);
- }
- //================================================================================
- //
- //================================================================================
- public override void SpeechPaige()
- {
- base.SpeechPaige();
- int numberOfSpeeches = 0;
- NewSequence();
- if (m_SelectedIngredient == null)
- {
- if (m_SandwichManager.GetNumberOfDifferendIngredients() == 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19600");
- }
- else
- {
- if (m_SandwichManager.GetNumberOfDifferendIngredients() < 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19601");
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19602");
- }
- }
- }
- else
- {
- if (m_CoinManager.TotalPrice == 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19603");
- }
- else
- {
- m_NumClicksPaige++;
- if(m_NumClicksPaige > 4)
- {
- m_NumClicksPaige = 1;
- }
- if (m_NumItemsUnlocked == 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19610");
- }
- else
- {
- if (m_NumClicksPaige == 4)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19611");
- }
- else if (m_NumClicksPaige == 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19612");
- }
- else if (m_NumClicksPaige == 2)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19613");
- }
- else if (m_NumClicksPaige == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Paige, "19614");
- }
- }
- }
- }
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- protected override void Update()
- {
- base.Update();
- if (m_SandwichIsClosing)
- {
- if (Input.GetMouseButton(0))
- {
- GivePrize();
- }
- }
- else if (m_DraggedIngredient != null)
- {
- //this.m_DraggedIngredient.transform.position += (Camera.main.ScreenToWorldPoint(Input.mousePosition) - m_PreviousMousePosition);
- m_PreviousMousePosition = Input.mousePosition;
- m_PreviousMousePosition.y = -(Screen.height - m_PreviousMousePosition.y);
- m_PreviousMousePosition.y += this.m_DraggedIngredientSprite.bounds.extents.y;
- m_PreviousMousePosition.x -= this.m_DraggedIngredientSprite.bounds.extents.x;
- this.m_DraggedIngredient.transform.position = m_PreviousMousePosition;
- #if UNITY_IPHONE || UNITY_ANDROID
- if (Input.GetMouseButtonUp(0))
- {
- if (m_DraggedIngredient.Purchased)
- UpPurchasedIngredient(m_DraggedIngredient);
- }
- #endif
- }
- //m_PreviousMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
- }
- //================================================================================
- //
- //================================================================================
- public void SetSelectedIngredient(IngredientDescriptor ingredient)
- {
- if (m_DraggedIngredient == null)
- m_DraggedIngredient = m_IngredientSelectionMachine.InstantiatePurchasedIngredient(ingredient);
- if (m_DraggedIngredient != null)
- m_DraggedIngredientSprite = m_DraggedIngredient.GetComponent<SpriteRenderer>();
- }
- //================================================================================
- //
- //================================================================================
- public void ReleasePurchasedIngredient(bool destroy)
- {
- m_DraggedIngredient.GetComponent<Collider2D>().enabled = false;
- if (destroy)
- {
- GameObject.Destroy(m_DraggedIngredient.gameObject);
- }
- m_DraggedIngredient = null;
- m_DraggedIngredientSprite = null;
- }
- //================================================================================
- //
- //================================================================================
- public void UpPurchasedIngredient(IngredientDescriptor ingredient)
- {
- SetSelectedIngredient(ingredient);
- if (IsSelectedIngredient(ingredient))
- {
- Vector2 mousePosition = Input.mousePosition;
- mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
- ReleasePurchasedIngredient(!SandwichManager.ProcessIngredientAddition(ingredient, mousePosition));
- }
- }
- //================================================================================
- //
- //================================================================================
- public bool IsSelectedIngredient(IngredientDescriptor ingredient)
- {
- return (m_DraggedIngredient == ingredient);
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnIdle()
- {
- base.OnIdle();
- m_IdleHelpIndex++;
- if (m_IdleHelpIndex > 2)
- {
- m_IdleHelpIndex = 1;
- }
- int numberOfSpeeches = 0;
- NewSequence();
- if (m_CoinManager.TotalPrice > 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19500");
- }
- if(m_IdleHelpIndex == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19501");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19502");
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19503");
- }
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- public IngredientSelectionMachine IngredientSelectionMachine
- {
- get { return m_IngredientSelectionMachine; }
- }
- //================================================================================
- //
- //================================================================================
- public CoinManager CoinManager
- {
- get { return m_CoinManager; }
- }
- //================================================================================
- //
- //================================================================================
- public SandwichManager SandwichManager
- {
- get { return m_SandwichManager; }
- }
- //================================================================================
- //
- //================================================================================
- public void OnClickHook()
- {
- if (SandwichManager.HasEnoughIngredients())
- {
- AudioManager.Instance().PlaySFX("19725");
- m_SandwichHook.CloseSandwich();
- Invoke ("EnableClickToGivePrize", 0.1f);
- }
- PlayOnClickClawSpeech();
- }
- //================================================================================
- //
- //================================================================================
- private void EnableClickToGivePrize()
- {
- m_SandwichIsClosing = true;
- }
- //================================================================================
- //
- //================================================================================
- private void GivePrize()
- {
- m_SandwichIsClosing = false;
- // TODO: Check if in practice mode
- PlayCollecItemSpeech();
-
- Chester.Instance().PutItemMultiple(ItemMultipleEnum.Sandwich, this, this.GetChesterPosition().x, this.GetChesterPosition().y);
-
- if (m_CurrentMinigameLevel < 3 && !PlayerData.Instance().IsActivityLocked(Activity.SillySandwichShop))
- {
- m_CurrentMinigameLevel++;
- }
-
- PlayerData.Instance().SetActivityLevel(Activity.SillySandwichShop, m_CurrentMinigameLevel);
-
- RestartMinigame();
- }
- //================================================================================
- //
- //================================================================================
- public void EnableMarble()
- {
- AudioManager.Instance().PlaySFX("19735");
- m_Marble.gameObject.SetActive(true);
- }
- //================================================================================
- //
- //================================================================================
- private void RestartMinigame()
- {
- this.LoadIngredientsDescriptions();
- this.m_SandwichHook.Reset();
- this.m_SandwichManager.Reset();
- this.m_CoinManager.Reset();
- this.m_IngredientSelectionMachine.Reset();
- this.m_NumItemsUnlocked = 0;
- this.m_WrongGuesses = 0;
- }
- //================================================================================
- //
- //================================================================================
- protected override void OnNavigation()
- {
- string[] possibleSpeeches = { "19110", "19111", "19112", "19113" };
- Characters[] characters = { Characters.Reader, Characters.Sam, Characters.LizardCashier, Characters.LizardCashier };
- int random = Random.Range(0, possibleSpeeches.Length);
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, characters[random], possibleSpeeches[random]);
- SetSequence(1, EventSequenceItem.EventSequenceType.Callback, base.OnNavigation);
- StartSequence(2, false);
- }
- //================================================================================
- //
- //================================================================================
- public void OnClickCashRegister()
- {
- if (m_CoinManager.TotalPrice == m_SelectedIngredient.Price)
- {
- SayPrice();
- }
- else
- {
- SayIncorrectPrice();
- }
- }
- //================================================================================
- //
- //================================================================================
- public void SayPrice()
- {
- SayPrice(m_CoinManager.TotalPrice, 0);
- }
- //================================================================================
- //
- //================================================================================
- public int SayPrice(params object[] parameters)
- {
- int price = (int)parameters[0];
- int cents = price % 100;
- int dollars = (price - cents) / 100;
- int numberOfSpeeches = (int)parameters[1];
- if (price > 199)
- {
- if (price > 1999)
- {
- int onesDigit = dollars % 10;
- int tensDigit = dollars / 10 - onesDigit / 10;
- if (tensDigit > 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19279 + tensDigit - 2).ToString());
- }
- else if (tensDigit == 1)
- {
- onesDigit = onesDigit + 10;
- }
- if (onesDigit > 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19260 + onesDigit - 1).ToString());
- }
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19287");
- if (cents > 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19292");
- }
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19260 + dollars - 1).ToString());
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19289");
- if (cents > 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19292");
- }
- }
- }
- else
- {
- if (price > 99)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19260 + dollars - 1).ToString());
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19288");
- if (cents > 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19292");
- }
- }
- }
- if (cents > 0)
- {
- if (cents == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19260");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19291");
- }
- else
- {
- int onesDigit = cents % 10;
- int tensDigit = cents / 10 - onesDigit / 10;
- if (tensDigit > 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19279 + tensDigit - 2).ToString());
- }
- else if (tensDigit == 1)
- {
- onesDigit = onesDigit + 10;
- }
- if (onesDigit > 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, (19260 + onesDigit - 1).ToString());
- }
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19290");
- }
- }
- if (dollars == 0 && cents == 0)
- {
- //TODO: Could not found the sound 2867
- //SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "2867");
- }
- return numberOfSpeeches;
- }
- //================================================================================
- //
- //================================================================================
- public void SayIncorrectPrice()
- {
- m_WrongGuesses++;
- int numberOfSpeeches = 0;
- NewSequence();
- if (m_CoinManager.TotalPrice < m_SelectedIngredient.Price)
- {
- string[] possibleSpeeches = { "19450", "19451", "19452" };
- if (!m_NotEnoughMoneySpchHeard)
- {
- int randomNumber = Random.Range(1, 3);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, possibleSpeeches[randomNumber - 1]);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19453");
- numberOfSpeeches = SayPrice(m_SelectedIngredient.Price, numberOfSpeeches);
- if (m_CurrentMinigameLevel == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19454");
- numberOfSpeeches = SayPrice(m_CoinManager.TotalPrice, numberOfSpeeches);
- }
- m_NotEnoughMoneySpchHeard = true;
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19460");
- numberOfSpeeches = SayPrice(m_SelectedIngredient.Price - m_CoinManager.TotalPrice, numberOfSpeeches);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19462");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19464");
- numberOfSpeeches = SayPrice(m_SelectedIngredient.Price - m_CoinManager.TotalPrice, numberOfSpeeches);
- }
- }
- else
- {
- string[] possibleSpeeches = { "19475", "19476", "19477" };
- if (!m_TooMuchMoneySpchHeard)
- {
- int randomNumber = Random.Range(1, 3);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, possibleSpeeches[randomNumber - 1]);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19453");
- numberOfSpeeches = SayPrice(m_SelectedIngredient.Price, numberOfSpeeches);
- if (m_CurrentMinigameLevel == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19454");
- numberOfSpeeches = SayPrice(m_CoinManager.TotalPrice, numberOfSpeeches);
- }
- m_TooMuchMoneySpchHeard = true;
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19480");
- numberOfSpeeches = SayPrice(m_CoinManager.TotalPrice - m_SelectedIngredient.Price, numberOfSpeeches);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19482");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19484");
- numberOfSpeeches = SayPrice(m_CoinManager.TotalPrice - m_SelectedIngredient.Price, numberOfSpeeches);
- }
- }
- if (m_WrongGuesses == 5)
- {
- int randomNumber = Random.Range(1, 2);
- if (randomNumber == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19490");
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19491");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19492");
- }
- }
- else if (m_WrongGuesses == 7)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19493");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19494");
- }
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- public void PlayReleaseCoinSpeech()
- {
- if (this.m_CurrentMinigameLevel == 1)
- {
- if (m_CoinManager.TotalPrice == m_SelectedIngredient.Price && !m_RingBellSamSpchHeard)
- {
- m_RingBellSamSpchHeard = true;
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19722");
- StartSequence(1);
- }
- }
- }
- //================================================================================
- //
- //================================================================================
- public void PlayChangedYourMindSpeech(IngredientDescriptor ingredient)
- {
- AudioManager.Instance().PlaySFX("19172");
- if (m_SelectedIngredient == null || m_SelectedIngredient.IngredientName == ingredient.IngredientName)
- {
- NewSequence();
- SetSequence(0, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19720");
- StartSequence(1);
- }
- }
- //================================================================================
- //
- //================================================================================
- public void PlayOnClickClawSpeech()
- {
- m_ClawClickedCount++;
- if (m_ClawClickedCount > 3)
- {
- m_ClawClickedCount = 1;
- }
- int numberOfSpeeches = 0;
- NewSequence();
- if (m_SandwichManager.HasEnoughIngredients())
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19726");
- if (!PlayerData.Instance().IsPracticeMode())
- {
- if (PlayerData.Instance().RTM_UsedCatapultCount > 0)
- {
- string[] possibleSpeeches = { "19727", "19728", "19729" };
- Characters[] speechers = { Characters.Reader, Characters.Sam, Characters.Reader };
- int randomNumber = Random.Range(0, possibleSpeeches.Length);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, speechers[randomNumber], possibleSpeeches[randomNumber]);
- }
- else
- {
- string[] possibleSpeeches = { "19730", "19731" };
- Characters[] speechers = { Characters.Reader, Characters.Sam };
- int randomNumber = Random.Range(0, possibleSpeeches.Length);
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, speechers[randomNumber], possibleSpeeches[randomNumber]);
- }
- }
- }
- else
- {
- if (m_SandwichManager.GetNumberOfDifferendIngredients() == 0)
- {
- if (m_NumItemsUnlocked == 0)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19739");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Reader, "19740");
- }
- else
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19738");
- }
- }
- else
- {
- if (m_ClawClickedCount == 1)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.Sam, "19741");
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19742");
- }
- else if (m_ClawClickedCount == 2)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19743");
- }
- else if (m_ClawClickedCount == 3)
- {
- SetSequence(numberOfSpeeches++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19744");
- }
- }
- }
- StartSequence(numberOfSpeeches);
- }
- //================================================================================
- //
- //================================================================================
- public void PlayCollecItemSpeech()
- {
- if(!PlayerData.Instance().IsPracticeMode())
- {
- int speechCount = 0;
- NewSequence();
- if (!m_Marble.gameObject.activeSelf)
- {
- SetSequence(speechCount++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19732");
- SetSequence(speechCount++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19733");
- SetSequence(speechCount++, EventSequenceItem.EventSequenceType.Callback, EnableMarble);
- }
- else
- {
- SetSequence(speechCount++, EventSequenceItem.EventSequenceType.Speech, Characters.LizardCashier, "19734");
- }
- StartSequence(speechCount);
- }
- }
- //================================================================================
- //
- //================================================================================
- public void GetMarble()
- {
- m_Marble.DoAction();
- }
- } // public class SceneSillySandwichShop : SceneCommon
- } // namespace ReaderRabbit
|