Localizer_SillySandwichShop.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.IO;
  4. public class Localizer_SillySandwichShop : MonoBehaviour
  5. {
  6. int lang;
  7. string imageIndex = "Resources/Resources_EN";
  8. bool languageFilled = false;
  9. int idiomSystemCoin = 0;
  10. public GameObject ingredientsGameObject = null;
  11. public ReaderRabbit.CoinManager coinManagerScript;
  12. private ArrayList listOfProducts = new ArrayList();
  13. private void Awake()
  14. {
  15. CheckLanguageCamp();
  16. AlterMonetarySystem();
  17. FillArrayOfGameItens();
  18. ChangeProductsTextName();
  19. }
  20. void CheckLanguageCamp()
  21. {
  22. lang = PlayerPrefs.GetInt("language");
  23. if (lang == 0)
  24. {
  25. //Danish
  26. imageIndex = "Resources_DA";
  27. idiomSystemCoin = 1;
  28. }
  29. else if (lang == 1)
  30. {
  31. //English
  32. imageIndex = "Resources_EN";
  33. idiomSystemCoin = 0;
  34. }
  35. else if (lang == 2)
  36. {
  37. //Nordic
  38. imageIndex = "Resources_NO";
  39. idiomSystemCoin = 1;
  40. }
  41. else if (lang == 3)
  42. {
  43. //Spanish
  44. imageIndex = "Resources_SP";
  45. idiomSystemCoin = 0;
  46. }
  47. else if (lang == 4)
  48. {
  49. //Swedish
  50. imageIndex = "Resources_SW";
  51. idiomSystemCoin = 1;
  52. }
  53. languageFilled = true;
  54. }
  55. void FillArrayOfGameItens()
  56. {
  57. TextAsset itemsNames = Resources.Load<TextAsset>(imageIndex + "/SillySandwichShop/19200");
  58. // If speech text file is not found, look inside chester.
  59. //string text = File.ReadAllText(path);
  60. char[] separators = { '\r', '\n' };
  61. string[] words = itemsNames.text.Split(separators);
  62. foreach (string word in words)
  63. {
  64. if (word != "")
  65. {
  66. listOfProducts.Add(word);
  67. }
  68. }
  69. }
  70. void ChangeProductsTextName()
  71. {
  72. int index = 0;
  73. ingredientsGameObject = GameObject.Find("Ingredients");
  74. foreach (Transform product in ingredientsGameObject.transform)
  75. {
  76. foreach (Transform child in product.transform)
  77. {
  78. if (child.name == "Name")
  79. {
  80. TextMesh childTextMesh = child.GetComponent<TextMesh>();
  81. childTextMesh.text = listOfProducts[index].ToString();
  82. index++;
  83. Debug.Log(childTextMesh.text);
  84. }
  85. }
  86. }
  87. }
  88. void AlterMonetarySystem()
  89. {
  90. coinManagerScript = GameObject.Find("CoinsManager").GetComponent<ReaderRabbit.CoinManager>();
  91. foreach (ReaderRabbit.Coin coin in coinManagerScript.m_TwentyFiveCentsCoins)
  92. {
  93. coin.systemOfCoin = idiomSystemCoin;
  94. }
  95. foreach (ReaderRabbit.Coin coin in coinManagerScript.m_TenCentsCoins)
  96. {
  97. coin.systemOfCoin = idiomSystemCoin;
  98. }
  99. foreach (ReaderRabbit.Coin coin in coinManagerScript.m_FiveCentsCoins)
  100. {
  101. coin.systemOfCoin = idiomSystemCoin;
  102. }
  103. foreach (ReaderRabbit.Coin coin in coinManagerScript.m_OneCentCoins)
  104. {
  105. coin.systemOfCoin = idiomSystemCoin;
  106. }
  107. foreach (ReaderRabbit.Coin coin in coinManagerScript.m_TwentyFiveCentsUsedCoins)
  108. {
  109. coin.systemOfCoin = idiomSystemCoin;
  110. }
  111. foreach (ReaderRabbit.Coin coin in coinManagerScript.m_TenCentsUsedCoins)
  112. {
  113. coin.systemOfCoin = idiomSystemCoin;
  114. }
  115. foreach (ReaderRabbit.Coin coin in coinManagerScript.m_FiveCentsUsedCoins)
  116. {
  117. coin.systemOfCoin = idiomSystemCoin;
  118. }
  119. foreach (ReaderRabbit.Coin coin in coinManagerScript.m_OneCentUsedCoins)
  120. {
  121. coin.systemOfCoin = idiomSystemCoin;
  122. }
  123. }
  124. }