// Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        //deactivate this button when exported to platforms
        if (!Application.isEditor)
        {
            LevelEditorBtn.gameObject.SetActive(false);
        }

        levelCount = Resources.LoadAll("Levels").Length - 1;

        editorManager = EditorManager.Instance;
        boardManager  = editorManager.GetBoardManager();

        pieceBoard = boardManager.pieceBoard;

        SetDefaultStart();

        LevelEditorBtn.onClick.AddListener(delegate() { ChangeEditorState(); });
        mixBoardBtn.onClick.AddListener(delegate() { CreateRandomLevel(); });
        executeSolutionBtn.onClick.AddListener(delegate() { ExecuteSolutionFunc(); });
        saveLevelBtn.onClick.AddListener(delegate() { SaveLevel(); });
        loadLevelBtn.onClick.AddListener(delegate() { LoadLevelFunc(); });
        stopSolution.onClick.AddListener(delegate() { StopSolution(); });
    }
Exemple #2
0
    // Use this for initialization
    protected virtual void Start()
    {
        gameManager  = EditorManager.Instance;
        position     = transform.localPosition;
        boardManager = gameManager.GetBoardManager();

        boardManager.SetElementOnBoard((int)Position.x, (int)position.y, this);
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (editorManager.GetGameState() == EditorManager.GameState.Editor)
            {
                lvlEditorManager.EditOrPlacePiece(ConvertScreenToWorldPosition(Input.mousePosition));
            }
        }

        if (editorManager.GetGameState() == EditorManager.GameState.InGame)
        {
            if (Input.GetKeyDown(KeyCode.S))
            {
                moveDirection = MoveDirection.down;
                StartCoroutine(editorManager.GetBoardManager().MovePieces(moveDirection));
            }

            else if (Input.GetKeyDown(KeyCode.W))
            {
                moveDirection = MoveDirection.Up;
                StartCoroutine(editorManager.GetBoardManager().MovePieces(moveDirection));
            }

            else if (Input.GetKeyDown(KeyCode.A))
            {
                moveDirection = MoveDirection.left;
                StartCoroutine(editorManager.GetBoardManager().MovePieces(moveDirection));
            }

            else if (Input.GetKeyDown(KeyCode.D))
            {
                moveDirection = MoveDirection.right;
                StartCoroutine(editorManager.GetBoardManager().MovePieces(moveDirection));
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     editorManager    = EditorManager.Instance;
     boardManager     = editorManager.GetBoardManager();
     lvlEditorManager = editorManager.GetLevelEditorManager();
 }