// Use this for initialization
    void Start()
    {
        Debug.Log("player:: " + PlayerStats.won_index);
        Debug.Log("AI:: " + AIStats.won_index);

        moneyEarned_txt = moneyEarned_object.GetComponent <Text>();

        // initialize variables from the preferences.
        stars_earned = PlayerPrefs.GetInt("stars_num");
        money_earned = PlayerPrefs.GetInt("money_won");
        Debug.Log("win_index:: " + PlayerStats.won_index);



        // load player board winner.
        if (PlayerStats.won_index > -1)
        {
            for (int i = 0; i < 16; i++)
            {
                PlayerStats.boards[PlayerStats.won_index].cards[i] = board.GetChild(0).GetChild(i);
            }

            PlayerStats.LoadBoard(PlayerStats.won_index);
        }
        // load AI board winner.
        else if (AIStats.won_index > -1)
        {
            for (int i = 0; i < 16; i++)
            {
                AIStats.boards[AIStats.won_index].cards[i] = board.GetChild(0).GetChild(i);
            }

            AIStats.LoadBoard();
        }

        // AI won.
        if (AIStats.won_index > -1)
        {
            stars_earned = 0;
            money_earned = Random.Range(5, 10);

            player_won = false;

            if (PlayerStats.coins - money_earned > 0)
            {
                PlayerStats.coins -= money_earned;
            }
            else
            {
                PlayerStats.coins = 0;
            }


            SaveLoadController.SaveStats(PlayerStats.coins, PlayerStats.stars, "player_stats.sav");
        }
        // Player won.
        else if (PlayerStats.won_index > -1)
        {
            player_won = true;

            PlayerStats.coins += money_earned;
            PlayerStats.stars += stars_earned;

            SaveLoadController.SaveStats(PlayerStats.coins, PlayerStats.stars, "player_stats.sav");
        }


        // update user stats (money, exp).
        StartCoroutine(StarAwards(stars_earned));
        StartCoroutine(MoneyAwards(money_earned));

        StartCoroutine(GoToScene(0));
    }