Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        SaveManagerClass saveManager = new SaveManagerClass(recordCount);
        RecordData[] allRecords = saveManager.GetAllRecords();

        if(allRecords[0].Score == -1) //records are not in PlayerPerfs yet. Fill PlayerPerfs from textAsset.
        {
            String[,] parsedGrid = CSVReaderScript.Parse(textAsset.text, ';');
            RecordData[] records = new RecordData[recordCount];

            for (int i = 0; i < recordCount; i++)
            {
                records[i] = new RecordData(int.Parse(parsedGrid[i, 0]), parsedGrid[i, 1]);

                AddTextCell(cellScoreOrigin, gridParent, parsedGrid[i, 0]); //Fill Score UI element
                AddTextCell(cellDateOrigin, gridParent, parsedGrid[i, 1]); //Fill Date UI element

                /*
                GameObject cellScoreClone = GameObject.Instantiate(cellScoreOrigin);    //Fill Score UI element
                cellScoreClone.GetComponent<Text>().text = parsedGrid[i, 0];
                cellScoreClone.transform.SetParent(gridParent, false);
                cellScoreClone.transform.localScale = Vector3.one;

                GameObject cellDateClone = GameObject.Instantiate(cellDateOrigin);  //Fill Date UI element
                cellDateClone.GetComponent<Text>().text = parsedGrid[i, 1];
                cellDateClone.transform.SetParent(gridParent, false);
                cellDateClone.transform.localScale = Vector3.one;
                */
            }

            saveManager.InsertRecordArray(records);
        }
        else
        {
            int lastScore = PlayerPrefs.GetInt("lastScore");    //
            PlayerPrefs.SetInt("lastScore", -1);                //drop value to avoid multisaving

            int currentRecordIndex = saveManager.InsertRecord(lastScore, DateTime.Now);
            RecordData[] records = saveManager.GetAllRecords();

            for (int i = 0; i < recordCount; i++)
            {
                if(i == currentRecordIndex)
                {
                    AddTextCell(cellScoreOrigin, gridParent, records[i].Score.ToString(), true); //Fill Score UI element & highlight
                    AddTextCell(cellDateOrigin, gridParent, records[i].Date, true); //Fill Date UI element & highlight
                }
                else
                {
                    AddTextCell(cellScoreOrigin, gridParent, records[i].Score.ToString()); //Fill Score UI element
                    AddTextCell(cellDateOrigin, gridParent, records[i].Date); //Fill Date UI element
                }
            }
        }
        //PlayerPrefs.DeleteAll();
    }
Ejemplo n.º 2
0
    void Awake()
    {
        GameState = GameStates.Play;
        UITextLife.text = lifeText + startLife;
        currentLife = startLife;
        ClickManager.SphereClickEvent += OnSphereClick;
        GameStateChangedEvent += OnGameStateChanged;
        ClickManager.SphereClickEvent += OnFirstClick;

        saveManager = new SaveManagerClass(topListRecordCount);

        SphereSpawnerScript.Instance.Spawn(dummySpherePrefab, activeSpherePrefab, anchorPoint, width, height, offset);  //initialization

        highlightGroup = SphereSpawnerScript.Instance.GetBiggestGroup();

        highlighted = true;
        HighlightBiggestGroup(highlightGroup, true);
    }