123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Collections;
- /// <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;
- public Transform TrParent;
- public Color ColorText;
- }
- [ExecuteInEditMode]
- public class VirusInfoScreen : MonoBehaviour
- {
- public static VirusInfoScreen Instance;
- public UITexture background;
- public UILabel label;
- public UILabel Name;
- public Texture2D[] textures;
- public UILabel man;
- public UILabel woman;
- private int curVirese;
- public float scaleY;
- public List<VirusDescription> ListDescription;
- //private EnemyType _enemy;
- void Start()
- {
- Instance = this;
- }
- private void ResetInfo()
- {
- foreach(var item in ListDescription)
- {
- if(item.TrParent!=null)
- {
- item.TrParent.gameObject.SetActive(false);
- }
- }
- }
- public void NextPage()
- {
-
- curVirese++;
- if(curVirese>textures.Length)
- {
- curVirese = 0;
- }
- ResetInfo();
- Texture2D texture = ListDescription[curVirese].Textures;
- background.mainTexture = texture;
- background.transform.localScale = new Vector3(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height), Screen.height * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height), background.transform.localScale.z);
- 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;
- }
- ResetInfo();
- Texture2D texture = ListDescription[curVirese-1].Textures;
- background.mainTexture = texture;
- background.transform.localScale = new Vector3(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height), Screen.height * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height), background.transform.localScale.z);
- //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;
- if(virus == EnemyType.herpes)
- {
- label.color = Color.white;
- }
- else
- {
- label.color = Color.yellow;
- }
- ResetInfo();
- curVirese = (int) virus;
- Texture2D texture = ListDescription[(int)virus].Textures;
- background.mainTexture = texture;
- background.transform.localScale = new Vector3(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height), Screen.height * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height), background.transform.localScale.z);
- 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.lineWidth = 760;
- label.text = Localization.instance.Get(ListDescription[(int)virus].Description);
- Name.text = Localization.instance.Get(ListDescription[(int)virus].Name);
- ListDescription[(int)virus].TrParent.gameObject.SetActive(true);
- //Debug.Log(Screen.height + " " + Screen.dpi);
- }
- void Update()
- {
- background.transform.localScale = new Vector3(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height), Screen.height * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height), background.transform.localScale.z);
- }
- }
|