<commit_before>﻿using UnityEngine;
using System.Collections;
using Assets.Scripts.CloudBread;

public class ScoreManagerScript : MonoBehaviour {

    public static int Score { get; set; }

    private bool deadRefreshFlag = true;

	// Use this for initialization
	void Start () {
        (Tens.gameObject as GameObject).SetActive(false);
        (Hundreds.gameObject as GameObject).SetActive(false);
        deadRefreshFlag = true;
    }
	
	// Update is called once per frame
	void Update () {

        if (GameStateManager.GameState == GameState.Playing)
        {
            if (previousScore != Score) //save perf from non needed calculations
            {
                if (Score < 10)
                {
                    //just draw units
                    Units.sprite = numberSprites[Score];
                }
                else if (Score >= 10 && Score < 100)
                {
                    (Tens.gameObject as GameObject).SetActive(true);
                    Tens.sprite = numberSprites[Score / 10];
                    Units.sprite = numberSprites[Score % 10];
                }
                else if (Score >= 100)
                {
                    (Hundreds.gameObject as GameObject).SetActive(true);
                    Hundreds.sprite = numberSprites[Score / 100];
                    int rest = Score % 100;
                    Tens.sprite = numberSprites[rest / 10];
                    Units.sprite = numberSprites[rest % 10];
                }
            }

        }
        else if (GameStateManager.GameState == GameState.Dead)
        {
                
            (Units.gameObject as GameObject).SetActive(false);
            (Tens.gameObject as GameObject).SetActive(false);
            (Hundreds.gameObject as GameObject).SetActive(false);

            setScorewithSpirte(NewScoreUnit, Score);

            int bestScore = 0;

            if (PlayerPrefs.HasKey("bestScore"))
            {
                bestScore = PlayerPrefs.GetInt("bestScore");
            }
            else
            {
                PlayerPrefs.SetInt("bestScore", bestScore);
            }

            if (bestScore >= Score)
            {
                setScorewithSpirte(BestScoreUnit, bestScore);
            }
            else
            {
                PlayerPrefs.SetInt("bestScore", Score);
                setScorewithSpirte(BestScoreUnit, Score);
            }

            if (deadRefreshFlag)
            {
                deadRefreshFlag = false;
                CloudBread cb = new CloudBread();
                cb.CBComUdtMemberGameInfoes(Callback_Success);
            }
        }
        

    }

    public void Callback_Success(string id, WWW www)
    {
        print("[" + id + "] Success");
    }

    private void setScorewithSpirte(SpriteRenderer[] renders, int Score)
    {
        foreach(var render in renders)
        {<commit_msg>add Score Page and Score Script<commit_after>﻿using UnityEngine;
using System.Collections;
using Assets.Scripts.CloudBread;

public class ScoreManagerScript : MonoBehaviour {

    public static int Score { get; set; }

    private bool deadRefreshFlag = true;

	// Use this for initialization
	void Start () {
        (Tens.gameObject as GameObject).SetActive(false);
        (Hundreds.gameObject as GameObject).SetActive(false);
        deadRefreshFlag = true;
    }
	
	// Update is called once per frame
	void Update () {

        if (GameStateManager.GameState == GameState.Playing)
        {
            if (previousScore != Score) //save perf from non needed calculations
            {
                if (Score < 10)
                {
                    //just draw units
                    Units.sprite = numberSprites[Score];
                }
                else if (Score >= 10 && Score < 100)
                {
                    (Tens.gameObject as GameObject).SetActive(true);
                    Tens.sprite = numberSprites[Score / 10];
                    Units.sprite = numberSprites[Score % 10];
                }
                else if (Score >= 100)
                {
                    (Hundreds.gameObject as GameObject).SetActive(true);
                    Hundreds.sprite = numberSprites[Score / 100];
                    int rest = Score % 100;
                    Tens.sprite = numberSprites[rest / 10];
                    Units.sprite = numberSprites[rest % 10];
                }
            }

        }
        else if (GameStateManager.GameState == GameState.Dead)
        {
                
            (Units.gameObject as GameObject).SetActive(false);
            (Tens.gameObject as GameObject).SetActive(false);
            (Hundreds.gameObject as GameObject).SetActive(false);

            setScorewithSpirte(NewScoreUnit, Score);

            int bestScore = 0;

            if (PlayerPrefs.HasKey("bestScore"))
            {
                bestScore = PlayerPrefs.GetInt("bestScore");
            }
            else
            {
                PlayerPrefs.SetInt("bestScore", bestScore);
            }

            if (bestScore >= Score)
            {
                setScorewithSpirte(BestScoreUnit, bestScore);
            }
            else
            {
                PlayerPrefs.SetInt("bestScore", Score);
                setScorewithSpirte(BestScoreUnit, Score);

                if (deadRefreshFlag)
                {
                    deadRefreshFlag = false;
                    CloudBread cb = new CloudBread();
                    cb.CBComUdtMemberGameInfoes(Callback_Success);
                }
            }


        }

    }

    public void Callback_Success(string id, WWW www)
    {
        print("[" + id + "] Success");
        CloudBread cb = new CloudBread();
        cb.CBRank(Callback_CBRank);
    }

    public void Callback_CBRank(string str, WWW www)
    {
        print("CBRank Success");
        print(str);
    }

    private void setScorewithSpirte(SpriteRenderer[] renders, int Score)
    {
        foreach(var render in renders)
        {
{'fraction_non_alphanumeric': 0.08923230309072781, 'fraction_numerical': 0.008308408109006314, 'mean_word_length': 1.427016129032258, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1063641', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1526, 'n_words': 339}