﻿using UnityEngine;
using System.Collections;

public class Score : MonoBehaviour {
	
	public int players;
	public int scorePlayer1, scorePlayer2, scorePlayer3, scorePlayer4;
	public int scoreGame;
	public int typeGame;
	public GUIText text;

	
	public void setScore( string obj ) {

		if (obj == "Player1") {
			scorePlayer1++;
			Debug.Log("Player1" + scorePlayer1);
		}
		if (obj == "Player2") {
			scorePlayer2++;
			Debug.Log("Player2" + scorePlayer2);
		}
		if (obj == "Player3") {
			scorePlayer3++;
			Debug.Log("Player3" + scorePlayer3);
		}
		if (obj == "Player4") {
			scorePlayer4++;
			Debug.Log("Player4" + scorePlayer4);
		}

		if (scorePlayer1 == (typeGame / 2 + 1))
		{
			Debug.Log("Player 1 won! Score = " + scorePlayer1);
		}

		if (scorePlayer2 == (typeGame / 2 + 1))
		{
			Debug.Log("Player 2 won! Score = " + scorePlayer2);
		}

		if (scorePlayer3 == (typeGame / 2 + 1))
		{
			Debug.Log("Player 3 won! Score = " + scorePlayer3);
		}

		if (scorePlayer4 == (typeGame / 2 + 1))
		{
			Debug.Log("Player 4 won! Score = " + scorePlayer4);
		}

	}

	public void setTypeGame ( int p_typeGame){
		typeGame = p_typeGame;

	}

	private void resetScore(){
		scoreGame = 0;
		scorePlayer1 = 0;
		scorePlayer2 = 0;
		scorePlayer3 = 0;
		scorePlayer4 = 0;
	}

	public void startScore( int p_players, int p_typeGame){
		players = p_players;
		typeGame = p_typeGame;

	}

	/**
	
	public void saveScore() {
		PlayerPrefs.SetInt ("Score", score);
		
		if ( PlayerPrefs.GetInt("BestScore") < score ) {
			PlayerPrefs.SetInt("BestScore", score );
		}
	}
	**/
	
	// Use this for initialization
	void Start () {
		scoreGame = 0;
		scorePlayer1 = 0;
		scorePlayer2 = 0;
		scorePlayer3 = 0;
		scorePlayer4 = 0;
		
	}
	
}