예제 #1
0
    public void ChangeMode(bool fromButton)
    {
        inCreator = !inCreator;

        levelObjects.SetActive(!inCreator);
        levelCanvas.SetActive(!inCreator);
        levelButtons.SetActive(!inCreator);

        creatorObjects.SetActive(inCreator);
        creatorCanvas.SetActive(inCreator);

        board.SetModifiable(inCreator);

        if (!inCreator)
        {
            completed    = false;
            initialState = board.GetBoardState();
            cameraFit.SetViewPort(levelViewport);

            changeModeButton.GetComponent <Image>().sprite = changeToEditModeSprite;
            board.SetFocusPointOffset(new Vector3((board.GetColumns() - 2) / 2.0f + 0.5f, 0.0f, (board.GetRows() - 2) / 2.0f + 0.5f));
            cameraFit.FitBoard(board.GetRows(), board.GetColumns());

            string boardState = board.GetBoardStateAsFormatedString();

            if (fromButton)
            {
                TrackerAsset.Instance.setVar("mode", "test");
                TrackerAsset.Instance.setVar("board", boardState != boardString ? boardState : "unchanged");
            }
            boardString = boardState;
        }
        else
        {
            cameraOrbit.ResetInmediate();
            cameraZoom.ResetInmediate();
            cameraFit.SetViewPort(creatorViewPort);
            changeModeButton.GetComponent <Image>().sprite = changeToPlayModeSprite;
            boardCreator.FitBoard();

            if (fromButton)
            {
                TrackerAsset.Instance.setVar("mode", "edition");
            }
        }

        if (fromButton)
        {
            TrackerAsset.Instance.GameObject.Interacted("editor_mode_change_button");
        }

        if (inCreator)
        {
            TrackerAsset.Instance.Accessible.Accessed("editor");
        }
        else
        {
            TrackerAsset.Instance.Accessible.Accessed("tester");
        }
    }
예제 #2
0
    private void Initialize()
    {
        if (currentLevel == null)
        {
            Debug.LogError("Cannot initialize Level. CurrentLevel is null");
            return;
        }

        // Maybe do more stuff
        ActivateLevelBlocks(currentLevel.activeBlocks, currentLevel.allActive);
        LoadInitialBlocks(currentLevel.initialState);

        string     boardJson = currentLevel.levelBoard != null ? currentLevel.levelBoard.text : currentLevel.auxLevelBoard;
        BoardState state     = BoardState.FromJson(boardJson);

        boardManager.LoadBoard(state, buildLimits);
        cameraFit.FitBoard(boardManager.GetRows(), boardManager.GetColumns());

        BlocklyUI.WorkspaceView.InitIDs();
    }
예제 #3
0
 public void FitBoard()
 {
     board.SetFocusPointOffset(new Vector3((board.GetColumns() - 2) / 2.0f + 0.5f, 0.0f, ((board.GetRows() - 2) / 2.0f + 0.5f) - 1));
     cameraFit.FitBoard(board.GetRows() + 1 + elementSelection.GetRows(), Mathf.Max(board.GetColumns(), elementSelection.GetColumns()));
 }