using UnityEngine;
using System.Collections;

public class itemSpawner : MonoBehaviour {
	public GameObject items;
	public float itemSize = 1.44f;
	public GameObject[] itemLocations;
	public GameObject itemPrefab;
	public int percentChance;
	
	
	// Use this for initialization
	void Start () {
		for (int i = 0; i < itemLocations.Length; i++) {
			var randomPercent = Random.Range(0,101);
			if (randomPercent <= percentChance && itemLocations[i] != null && itemPrefab != null) {
				GameObject newItem = (GameObject) Instantiate(itemPrefab);
				newItem.transform.RotateAround(transform.position,Vector3.forward,Random.Range(0,361));
				newItem.transform.position = new Vector3(itemLocations[i].transform.position.x, itemLocations[i].transform.position.y, 0);//startPos + 
				newItem.transform.parent = items.transform;
				//newTile.transform.rotation = Quaternion.identity;
			}
		}
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}
