123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using UnityEngine;
- using System.Collections;
- using System.IO;
- public class Localizer_SillySandwichShop : MonoBehaviour
- {
- int lang;
- string imageIndex = "Resources/Resources_EN";
- bool languageFilled = false;
- int idiomSystemCoin = 0;
- public GameObject ingredientsGameObject = null;
- public ReaderRabbit.CoinManager coinManagerScript;
- private ArrayList listOfProducts = new ArrayList();
- private void Awake()
- {
- CheckLanguageCamp();
- AlterMonetarySystem();
- FillArrayOfGameItens();
- ChangeProductsTextName();
- }
- void CheckLanguageCamp()
- {
- lang = PlayerPrefs.GetInt("language");
- if (lang == 0)
- {
- //Danish
- imageIndex = "Resources_DA";
- idiomSystemCoin = 1;
- }
- else if (lang == 1)
- {
- //English
- imageIndex = "Resources_EN";
- idiomSystemCoin = 0;
- }
- else if (lang == 2)
- {
- //Nordic
- imageIndex = "Resources_NO";
- idiomSystemCoin = 1;
- }
- else if (lang == 3)
- {
- //Spanish
- imageIndex = "Resources_SP";
- idiomSystemCoin = 0;
- }
- else if (lang == 4)
- {
- //Swedish
- imageIndex = "Resources_SW";
- idiomSystemCoin = 1;
- }
- languageFilled = true;
- }
- void FillArrayOfGameItens()
- {
-
- TextAsset itemsNames = Resources.Load<TextAsset>(imageIndex + "/SillySandwichShop/19200");
- // If speech text file is not found, look inside chester.
-
- //string text = File.ReadAllText(path);
- char[] separators = { '\r', '\n' };
- string[] words = itemsNames.text.Split(separators);
- foreach (string word in words)
- {
- if (word != "")
- {
- listOfProducts.Add(word);
- }
- }
-
- }
- void ChangeProductsTextName()
- {
- int index = 0;
- ingredientsGameObject = GameObject.Find("Ingredients");
- foreach (Transform product in ingredientsGameObject.transform)
- {
- foreach (Transform child in product.transform)
- {
- if (child.name == "Name")
- {
- TextMesh childTextMesh = child.GetComponent<TextMesh>();
- childTextMesh.text = listOfProducts[index].ToString();
- index++;
- Debug.Log(childTextMesh.text);
- }
- }
- }
- }
- void AlterMonetarySystem()
- {
- coinManagerScript = GameObject.Find("CoinsManager").GetComponent<ReaderRabbit.CoinManager>();
- foreach (ReaderRabbit.Coin coin in coinManagerScript.m_TwentyFiveCentsCoins)
- {
- coin.systemOfCoin = idiomSystemCoin;
- }
- foreach (ReaderRabbit.Coin coin in coinManagerScript.m_TenCentsCoins)
- {
- coin.systemOfCoin = idiomSystemCoin;
- }
- foreach (ReaderRabbit.Coin coin in coinManagerScript.m_FiveCentsCoins)
- {
- coin.systemOfCoin = idiomSystemCoin;
- }
- foreach (ReaderRabbit.Coin coin in coinManagerScript.m_OneCentCoins)
- {
- coin.systemOfCoin = idiomSystemCoin;
- }
- foreach (ReaderRabbit.Coin coin in coinManagerScript.m_TwentyFiveCentsUsedCoins)
- {
- coin.systemOfCoin = idiomSystemCoin;
- }
- foreach (ReaderRabbit.Coin coin in coinManagerScript.m_TenCentsUsedCoins)
- {
- coin.systemOfCoin = idiomSystemCoin;
- }
- foreach (ReaderRabbit.Coin coin in coinManagerScript.m_FiveCentsUsedCoins)
- {
- coin.systemOfCoin = idiomSystemCoin;
- }
- foreach (ReaderRabbit.Coin coin in coinManagerScript.m_OneCentUsedCoins)
- {
- coin.systemOfCoin = idiomSystemCoin;
- }
- }
- }
|