void InitRed(){
		currentTeam = Char_AttributeScript.Teams.RED;
		//this.GetComponent<MeshRenderer>().materials[0].color =  Color.red;
		for (int i = 0; i < partsToColour.Length; i++){
			partsToColour[i].GetComponent<MeshRenderer>().materials[0].color = Color.red;
		}
	}
	public void InitRed(){
		currentTeam = Char_AttributeScript.Teams.RED;
		this.GetComponent<MeshRenderer>().materials[0].color =  Color.red;
		newLinkPart1.materials[0].color =  Color.red;
		newLinkPart2.materials[0].color =  Color.red;
		redBeam.Play(true);
	}
	public void SetTeam(Char_AttributeScript.Teams newTeam){
		currentTeam = newTeam;
		if (currentTeam == Char_AttributeScript.Teams.BLUE)
			InitBlue();
		else if (currentTeam == Char_AttributeScript.Teams.RED)
			InitRed();
	}
	public void InitBlue(){
		currentTeam = Char_AttributeScript.Teams.BLUE;
		this.GetComponent<MeshRenderer>().materials[0].color =  Color.blue;
		newLinkPart1.materials[0].color =  Color.blue;
		newLinkPart2.materials[0].color =  Color.blue;
		blueBeam.Play(true);
	}
	// Use this for initialization
	void Start () {
		localPlayerTeam = _MainController.playerTeam;
		GameObject.Find("CharacterSelectionGUI").transform.localScale=new Vector3(10,5,5);
		spawnPreviewCamera.gameObject.SetActive(true);
		GameObject.Find("PickATeam").gameObject.SetActive(false);
		SetUpLinkButtons();

		for (int i = 0; i < 4; i++){
			slotTimers[i] = 0;
			slots[i].text = "";
		}

		if (_MainController.gameStats.Equals("ping")){
			internetGame = true;
		} else {
			internetGame = false;
			gameStatsText.text = "IP: " + _MainController.gameStats;
		}
	}
	void InitBlue(){
		currentTeam = Char_AttributeScript.Teams.BLUE;
		this.GetComponent<MeshRenderer>().materials[0].color =  Color.blue;
		for (int i = 0; i < partsToColour.Length; i++){
			partsToColour[i].GetComponent<MeshRenderer>().materials[0].color = Color.blue;
		}
	}
	public void SetTeam(Char_AttributeScript.Teams newTeam){
		currentTeam = newTeam;
		if (currentTeam == Char_AttributeScript.Teams.BLUE)
			InitBlue();
		else if (currentTeam == Char_AttributeScript.Teams.RED)
			InitRed();
		//Invoke("KillSelf",lifeTime);
	}
	public void onBlueTeamButtonPress(){
		localPlayerTeam = Char_AttributeScript.Teams.BLUE;
		GameObject.Find("CharacterSelectionGUI").transform.localScale=new Vector3(10,5,5);
		spawnPreviewCamera.gameObject.SetActive(true);
		GameObject.Find("PickATeam").gameObject.SetActive(false);
		SetUpLinkButtons();
	}
	public LobbyPlayer(bool r, string s, Char_AttributeScript.Teams t){
		ready = r;
		playerName = s;
		team = t;
	}
	[RPC] void RedTeamCapture(){
		currentTeam = Char_AttributeScript.Teams.RED;
		Debug.Log("Red Team Captures Link");
		this.GetComponent<MeshRenderer>().materials[0].color =  Color.red;
		newLinkPart1.materials[0].color =  Color.red;
		newLinkPart2.materials[0].color =  Color.red;
		blueBeam.Stop(true);
		neutralBeam.Stop(true);
		redBeam.Play(true);
		gui.SetUpLinkButtons();
		AudioSource.PlayClipAtPoint (captureSound, transform.position);
		if (ScrollingMessageTimeout < 0){
			gui.AddItemToScrollingList("Red team captures link",Color.red);
			ScrollingMessageTimeout = 1f;
		}

		if (photonView.isMine)
			photonView.RPC("RedTeamCapture", PhotonTargets.OthersBuffered);
	}
	public void InitNeutral(){
		currentTeam = Char_AttributeScript.Teams.NONE;
		this.GetComponent<MeshRenderer>().materials[0].color =  Color.white;
		neutralBeam.Play(true);
	}
	[RPC] void  NeutralTeamCapture(){
		currentTeam = Char_AttributeScript.Teams.NONE;
		Debug.Log("Link has been neutralized");
		this.GetComponent<MeshRenderer>().materials[0].color =  Color.white;
		newLinkPart1.materials[0].color =  Color.white;
		newLinkPart2.materials[0].color =  Color.white;
		neutralBeam.Play(true);
		redBeam.Stop(true);
		blueBeam.Stop(true);
		gui.SetUpLinkButtons();

		if (photonView.isMine)
			photonView.RPC("NeutralTeamCapture", PhotonTargets.OthersBuffered);
	}