#pragma strict
import System.Collections.Generic;
var lineInputPrefab : GameObject;
var parentObject : GameObject;
public enum ResourceType
{
coal = 0,
oil = 1,
wood = 2,
gold = 3,
wine = 4
}
static public var resourceDictionary
= new Dictionary
.<ResourceType,
int>();
function Start ()
{
var parentObject = GameObject.FindWithTag("resList").transform;
resourceDictionary[ResourceType.coal] = 100;
resourceDictionary[ResourceType.wood] = 200;
resourceDictionary[ResourceType.wine] = 50;
resourceDictionary[ResourceType.oil] = 465;
resourceDictionary[ResourceType.gold] = 10;
for(var value in resourceDictionary)
{
print(value);
}
}
function PopulateList ()
{
//This is currently instantiating a number of lines equal to the size of the Dictionary
for(var value in resourceDictionary)
{
Instantiate(lineInputPrefab, transform.position, transform.rotation);
print("list successfully populated");
}
var newInput = GameObject.FindGameObjectsWithTag("resInput");
//This is moving the newly created objects ("lines") to be parented under the PlayerResourceTable object.
for (var value : GameObject in newInput)
{
value.transform.parent = parentObject.transform;
var x = 0;
value.SendMessage("AddValues", resourceDictionary[x++]);
}
//This SndMsgUpWards is just re-positioning the newly created objects so that they line up.
parentObject.SendMessageUpwards("RefreshList");
}