using System;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
///
/// This component is responsible for setting the background and text according
/// to a virus which is set through the SetVirus
method
///
[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 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);
}
}