VirusInfoScreen.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Collections;
  5. using UnityEngine.UI;
  6. using TMPro;
  7. using ICTS.Localization;
  8. /// <summary>
  9. /// This component is responsible for setting the background and text according
  10. /// to a virus which is set through the <code>SetVirus</code> method
  11. /// </summary>
  12. [Serializable]
  13. public class VirusDescription
  14. {
  15. public string Name;
  16. public Texture2D Textures;
  17. public string Description;
  18. }
  19. [ExecuteInEditMode]
  20. public class VirusInfoScreen : MonoBehaviour
  21. {
  22. public static VirusInfoScreen Instance;
  23. public RawImage background;
  24. public TextMeshProUGUI label;
  25. public TextMeshProUGUI Name;
  26. public Texture2D[] textures;
  27. public TextMeshProUGUI man;
  28. public TextMeshProUGUI woman;
  29. private int curVirese;
  30. public float scaleY;
  31. public List<VirusDescription> ListDescription;
  32. //private EnemyType _enemy;
  33. void Start()
  34. {
  35. Instance = this;
  36. }
  37. public void NextPage()
  38. {
  39. curVirese++;
  40. if(curVirese>textures.Length)
  41. {
  42. curVirese = 0;
  43. }
  44. Texture2D texture = ListDescription[curVirese].Textures;
  45. background.texture = texture;
  46. Debug.Log(Screen.height +" " + Screen.dpi);
  47. label.text = Localization.instance.Get(ListDescription[curVirese].Description);
  48. Name.text = Localization.instance.Get(ListDescription[curVirese].Name);
  49. }
  50. public void BackPage()
  51. {
  52. curVirese--;
  53. if (curVirese < 0)
  54. {
  55. curVirese = ListDescription.Count;
  56. }
  57. Texture2D texture = ListDescription[curVirese-1].Textures;
  58. background.texture = texture;
  59. //Debug.Log(Screen.height + " " + Screen.dpi);
  60. label.text = Localization.instance.Get(ListDescription[curVirese - 1].Description);
  61. Name.text = Localization.instance.Get(ListDescription[curVirese - 1].Name);
  62. }
  63. public void SetVirus(EnemyType virus)
  64. {
  65. //_enemy = virus;
  66. curVirese = (int) virus;
  67. Texture2D texture = ListDescription[(int)virus].Textures;
  68. background.texture = texture;
  69. AVDebug.Assert(virus.ToString() == texture.name, "The textures in the info screen need to be in the same order as in the VirusType enum. Also name needs to be exact for this assert to stop annoying you :). Found "+texture.name+" but virus is "+virus.ToString());
  70. label.text = Localization.instance.Get(ListDescription[(int)virus].Description);
  71. Name.text = Localization.instance.Get(ListDescription[(int)virus].Name);
  72. //Debug.Log(Screen.height + " " + Screen.dpi);
  73. }
  74. void Update()
  75. {
  76. //background.transform.localScale = new Vector3(Screen.width, Screen.height, background.transform.localScale.z);
  77. }
  78. }