123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- using TMPro;
- using ICTS.Localization;
- /// <summary>
- /// This component is responsible for setting the background and text according
- /// to a virus which is set through the <code>SetVirus</code> method
- /// </summary>
- [Serializable]
- public class VirusDescription
- {
- public string Name;
- public Texture2D Textures;
- public string Description;
- }
- [ExecuteInEditMode]
- public class VirusInfoScreen : MonoBehaviour
- {
- public static VirusInfoScreen Instance;
- public RawImage background;
- public TextMeshProUGUI label;
- public TextMeshProUGUI Name;
- public Texture2D[] textures;
- public TextMeshProUGUI man;
- public TextMeshProUGUI woman;
- private int curVirese;
- public float scaleY;
- public List<VirusDescription> ListDescription;
- //private EnemyType _enemy;
- void Start()
- {
- Instance = this;
- }
- public void NextPage()
- {
-
- curVirese++;
- if(curVirese>textures.Length)
- {
- curVirese = 0;
- }
- Texture2D texture = ListDescription[curVirese].Textures;
- background.texture = texture;
- Debug.Log(Screen.height +" " + Screen.dpi);
- label.text = Localization.instance.Get(ListDescription[curVirese].Description);
- Name.text = Localization.instance.Get(ListDescription[curVirese].Name);
- }
- public void BackPage()
- {
- curVirese--;
- if (curVirese < 0)
- {
- curVirese = ListDescription.Count;
- }
- Texture2D texture = ListDescription[curVirese-1].Textures;
- background.texture = texture;
- //Debug.Log(Screen.height + " " + Screen.dpi);
- label.text = Localization.instance.Get(ListDescription[curVirese - 1].Description);
- Name.text = Localization.instance.Get(ListDescription[curVirese - 1].Name);
- }
- public void SetVirus(EnemyType virus)
- {
- //_enemy = virus;
- curVirese = (int) virus;
- Texture2D texture = ListDescription[(int)virus].Textures;
- background.texture = texture;
- 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());
- label.text = Localization.instance.Get(ListDescription[(int)virus].Description);
- Name.text = Localization.instance.Get(ListDescription[(int)virus].Name);
- //Debug.Log(Screen.height + " " + Screen.dpi);
- }
- void Update()
- {
- //background.transform.localScale = new Vector3(Screen.width, Screen.height, background.transform.localScale.z);
- }
- }
|