class Player{
	
	private var name:String;
	private var score:int;
	private var level:int;
	private var state:String;
	private var balls = new Hashtable();
	
	private var metalBrick:Rigidbody;
	private var woodBrick:Rigidbody;
	private var rubberBrick:Rigidbody;
	private var iceBrick:Rigidbody;
	
	private var leftMost:float;
	private var rightMost:float;
	private var topMost:float;
	private var bottomMost:float;
	
	private var loadData = new Array();
	
	function Player(n:String, s:String)
	{
		name = n;
		score = 0;
		level = 1;
		state = s;		
	}
	
	function getName(){
		return name;
	}
	
	function getScore(){
		return score;
	}
	
	function setScore(amount:int){
		score = amount;
	}
	
	function getLevel(){
		return level;
	}
	
	function setLevel(amount:int){
		level = amount;
	}
	
	function getState(){
		return state;
	}
	
	function setState(s:String){
		state = s;
	}
	
	function incrementLevel(){
		level++;
	}
	
	function incrementScore(){
		score++;
	}
	
	function getBalls(){
		return balls;
	}
	
	function addBalls(gameObject:GameObject){
		if(!balls.ContainsKey(gameObject))
			balls.Add(gameObject, gameObject);		
	}
	
	function removeBall(gameObject:GameObject){
		balls.Remove(gameObject);
	}
	
	function holdData(object){
		loadData = object;
	}
	
	function getData(){
		return loadData;
	}
	
	function loadLevel(object, rubberBrick:Rigidbody, iceBrick:Rigidbody, woodBrick:Rigidbody, metalBrick:Rigidbody, ball:Rigidbody, cylinder:Rigidbody, childCylinder:GameObject[]){
		var childCylinderCount = 0;
		var totalBricks = 0;
		for(var g in object){
			switch (g[1]){
				case 'rubberBrick':
					totalBricks++;
					UnityEngine.Object.Instantiate(rubberBrick, Vector3(parseFloat(g[2].ToString()), parseFloat(g[3].ToString()), 0), Quaternion.identity);
					break;
				case 'iceBrick':
					totalBricks++;
					UnityEngine.Object.Instantiate(iceBrick, Vector3(parseFloat(g[2].ToString()), parseFloat(g[3].ToString()), 0), Quaternion.identity);
					break;
				case 'woodBrick':
					totalBricks++;
					UnityEngine.Object.Instantiate(woodBrick, Vector3(parseFloat(g[2].ToString()), parseFloat(g[3].ToString()), 0), Quaternion.identity);
					break;
				case 'metalBrick':
					totalBricks++;
					UnityEngine.Object.Instantiate(metalBrick, Vector3(parseFloat(g[2].ToString()), parseFloat(g[3].ToString()), 0), Quaternion.identity);
					break;
				case 'ball':
					var ballg:Rigidbody;
					ballg = UnityEngine.Object.Instantiate(ball, Vector3(parseFloat(g[2].ToString()), parseFloat(g[3].ToString()), 0), Quaternion.identity);
					
					addBalls(ballg.gameObject);
					break;
				case 'cylinder':
					cylinder.gameObject.transform.position.x = parseFloat(g[2].ToString());
					cylinder.gameObject.transform.position.y = parseFloat(g[3].ToString()); 
					break;
				case 'childCylinder':	
					childCylinder[childCylinderCount].gameObject.transform.position.Set(parseFloat(g[2].ToString()), parseFloat(g[3].ToString()),0);
					childCylinderCount++;
					break;
				
			}		
		}
		
		return totalBricks;
		
	}
	
}