ChangeStrings.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Text;
  5. public class ChangeStrings {
  6. private static List<string> oldValues = new List<string> { "%NPC_Name%", "%Player_Name%" , "<Gig_Timer>" , "[he/she]" , "[him/her]", "[Boy/girl]", "[boy/girl]", "[Queen/King]", "[his/her]", "[guy/girl]", "[He/she]" };
  7. public static string ChangeText(string _text)
  8. {
  9. string newValues = null;
  10. string text = _text;
  11. if (_text.Contains(oldValues[0]))
  12. {
  13. newValues = GameGlobal.Instance.CurrentNpc;
  14. text = text.Replace(oldValues[0], newValues);
  15. Debug.Log("Text 1 " + text);
  16. }
  17. if(_text.Contains(oldValues[1]))
  18. {
  19. newValues = GameGlobal.Instance.PlayerName;
  20. text = text.Replace(oldValues[1], newValues);
  21. }
  22. //[Gig_Timer]
  23. if (_text.Contains(oldValues[2]))
  24. {
  25. newValues = GameGlobal.Instance.GetGigTimer;
  26. text = text.Replace(oldValues[2], newValues);
  27. }
  28. if (_text.Contains(oldValues[3]))
  29. {
  30. newValues = GameGlobal.Instance.PlayerGender.ToLower();
  31. text = text.Replace(oldValues[3], newValues);
  32. }
  33. if(_text.Contains(oldValues[4]))
  34. {
  35. newValues = GameGlobal.Instance.PlayerGender;
  36. if (newValues == "She")
  37. newValues = "her";
  38. else
  39. newValues = "him";
  40. text = text.Replace(oldValues[4], newValues);
  41. }
  42. //[Boy/girls]
  43. if (_text.Contains(oldValues[5]) || _text.Contains(oldValues[6]))
  44. {
  45. newValues = GameGlobal.Instance.PlayerSex;
  46. if (newValues == "Male")
  47. newValues = "Boy";
  48. else
  49. newValues = "Girl";
  50. text = text.Replace(oldValues[5], newValues);
  51. text = text.Replace(oldValues[6], newValues);
  52. }
  53. if (_text.Contains(oldValues[6]))
  54. {
  55. newValues = GameGlobal.Instance.PlayerSex;
  56. if (newValues == "Male")
  57. newValues = "boy";
  58. else
  59. newValues = "girl";
  60. text = text.Replace(oldValues[5], newValues);
  61. text = text.Replace(oldValues[6], newValues);
  62. }
  63. if (_text.Contains(oldValues[7]))
  64. {
  65. newValues = GameGlobal.Instance.PlayerSex;
  66. if (newValues == "Male")
  67. newValues = "King";
  68. else
  69. newValues = "Queen";
  70. text = text.Replace(oldValues[7], newValues);
  71. }
  72. if (_text.Contains(oldValues[8]))
  73. {
  74. newValues = GameGlobal.Instance.PlayerGender;
  75. if (newValues == "She")
  76. newValues = "her";
  77. else
  78. newValues = "his";
  79. text = text.Replace(oldValues[8], newValues);
  80. }
  81. if (_text.Contains(oldValues[9]))
  82. {
  83. newValues = GameGlobal.Instance.PlayerSex;
  84. if (newValues == "Male")
  85. newValues = "guy";
  86. else
  87. newValues = "girl";
  88. text = text.Replace(oldValues[9], newValues);
  89. }
  90. if (_text.Contains(oldValues[10]))
  91. {
  92. newValues = GameGlobal.Instance.PlayerSex;
  93. if (newValues == "Male")
  94. newValues = "He";
  95. else
  96. newValues = "She";
  97. text = text.Replace(oldValues[10], newValues);
  98. }
  99. return text;
  100. }
  101. public static string ChangeText(string _text, string _oldValue, string _newValue)
  102. {
  103. return _text.Replace(_oldValue, _newValue);
  104. }
  105. public static bool WordsBannedFilter(string _text)
  106. {
  107. List<string> wordsBanned = WordsBanned.Instance.GetWordsBanned;
  108. string textw = _text.ToLower();
  109. for (int i = 0; i < wordsBanned.Count; i++)
  110. {
  111. if (textw.Contains(wordsBanned[i].ToLower()))
  112. {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. }