Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        relativeControls = GameManager.Instance.getCurrentDifficulty() == GameManager.Difficulty.HARD;


        //Reset camera to same position and orientation as this block
        Camera.main.transform.position = new Vector3(transform.position.x, transform.position.y, -10);
        Camera.main.transform.rotation = Quaternion.identity;

        playAreaManager = (PlayAreaManager)FindObjectOfType <PlayAreaManager>();

        // If not valid when spawned, then Game Over
        if (!playAreaManager.isValidGridPos(this))
        {
            Destroy(gameObject);
            playAreaManager.GameOver();
        }

        // Find the direction labels on screen
        upLabel    = GameObject.FindGameObjectWithTag("upLabel").GetComponent <Text>();
        rightLabel = GameObject.FindGameObjectWithTag("rightLabel").GetComponent <Text>();
        downLabel  = GameObject.FindGameObjectWithTag("downLabel").GetComponent <Text>();
        leftLabel  = GameObject.FindGameObjectWithTag("leftLabel").GetComponent <Text>();

        updateDirectionLabels();
    }
Exemplo n.º 2
0
    private void MoveLeft()
    {
        transform.position += new Vector3(-1, 0, 0);

        if (playAreaManager.isValidGridPos(this))
        {
            Camera.main.transform.position += new Vector3(-1, 0, 0);
        }
        else
        {
            transform.position -= new Vector3(-1, 0, 0);
        }
    }