Пример #1
0
    public void LoadGame()
    {
        if (File.Exists(Application.persistentDataPath + "/gamesave.save"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/gamesave.save", FileMode.Open);
            Save            save = (Save)bf.Deserialize(file);
            file.Close();

            CreateCubeInCell Create = gridScript.CreateBlockInCell;
            save.SetGridState(Create);

            gridScript.LaunchSavedStartFigure(new Vector3(save.figurePosition.x, save.figurePosition.y), save.figureIndex, save.rotationCount, save.nextFigureIndex);

            gridScript.figureFallDelay = save.figureFallDelay;
            gridScript.figureFallDelayDecreaseCurrentTime = save.figureFallDelayDecreaseCurrentTime;

            scoreText.text = save.score.ToString();
            score          = save.score;
            scoreForTween  = score;
        }
        else
        {
            gridScript.LaunchStartFigure();
        }
    }
Пример #2
0
 public void SetGridState(CreateCubeInCell Create)
 {
     for (int x = 0; x < cells.GetLength(0); x++)
     {
         for (int y = 0; y < cells.GetLength(1); y++)
         {
             CellInfo cellInfo = cells[x, y];
             if (!cellInfo.isFree)
             {
                 Create(new Vector2(x, y), cellInfo.cubeIndex);
             }
         }
     }
 }