Exemplo n.º 1
0
	public void RenderInventory()
	{
		// TODO, optimize this so it's not re-rendering every time.
		//itemPanels_.transform.DetachChildren ();
		
		foreach (Transform child in itemPanels_.transform) {
			GameObject.Destroy (child.gameObject);
		}

		string shipName = "";
		if (GameEventManager.Instance != null) {
			shipName = GameEventManager.Instance.GetName ("shipname");
		}

		if (shipName == "") {
			title_.text = "Ship's Manifest";
		} else {
			title_.text = GameEventManager.Instance.GetName ("shipname") + "'s Manifest";
		}

		Dictionary<string, Item> inventory = ItemManager.Instance.Inventory;

		Item item;
		string amountString;
		string produceString;

		foreach(KeyValuePair<string, Item> entry in inventory)
		{
			amountString = "";
			produceString = "";
			item = entry.Value;
			if(!ItemManager.Instance.IsItemHidden(entry.Key)){

				ItemPanelUI itemPanel = GameObject.Instantiate<ItemPanelUI> (itemPanelPrefab_, itemPanels_.transform);
				itemPanel.name.text = entry.Key;


				amountString = "" + item.Amount;
				if (item.Cap.Defined) {
					amountString += " / " + item.Cap.Value;
				}
				itemPanel.amount.text = amountString;

				if (item.ProducePer.Defined && item.TurnsToProduce.Defined) {
					produceString = item.ProducePer.Value + " every\n";
					if (item.TurnsToProduce.Value == 1) {
						produceString += "turn";
					} else {
						produceString += item.TurnsToProduce + "turns";
					}
				}
				itemPanel.production.text = produceString;
			}
		}
	}
Exemplo n.º 2
0
	private void Awake()
	{
		title_.text = "";
		itemPanelPrefab_ = Resources.Load<ItemPanelUI> ("Prefabs/ItemPanel");
	}