Esempio n. 1
0
    private void Start()
    {
        Application.targetFrameRate    = 60;
        Input.simulateMouseWithTouches = true;

        //this.ingameUI.FadeIn();

        this.cubeHighlighter = GameObject.Instantiate(this.HighlightCubePrefab);
        this.cubeHighlighter.gameObject.SetActive(false);

        //Hide the undo button until we start adding rotations.
        //Delete this if we end up serializing performed rotations at some point
        ingameUI.HideUndoButton();

        System.TimeSpan accumulatedTime = System.TimeSpan.Zero;

        this.orbitingCamera.SetCameraPosition(cameraStartingPosition.x, cameraStartingPosition.y, cameraStartingPosition.z);

        switch (PerSessionData.newGameMode)
        {
        case PerSessionData.GameModes.Resume:
            Debug.Log("Loading cube from playerprefs");
            SaveGameSystem.LoadGameState(
                out SaveGameSystem.SerializableCubeData cubeData,
                out accumulatedTime
                );
            this.magicCube = MagicCube.CreateFromSerializedData(cubeData, 1, this.IndividualCubePrefab);
            this.inputManager.allowRotations = true;
            break;

        case PerSessionData.GameModes.NewGame:
            Debug.Log("Creating a new game");
            this.magicCube = MagicCube.CreateFromNewGame(PerSessionData.CubeSize, 1, this.IndividualCubePrefab);
            StartCoroutine(this.ScrambleCube());
            break;
        }

        this.currentGameTimer = new GameTimer(accumulatedTime);
        RefreshUITimeCounter  = StartCoroutine(TimerTick());
    }