Esempio n. 1
0
        void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    ModBrickInstance brick = hit.transform.gameObject.GetComponent <ModBrickInstance>();
                    if (brick != null && brick.Selectable)
                    {
                        SwitchBrick(brick);
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.N) && (_currentBrick == null || _currentBrick.Placed))
            {
                _currentBrick = Instantiate(_modBrickPrefab, new Vector3(0, ModBrickMetrics.FullHeight, 0), Quaternion.identity);
                _currentBrick.SetMaterial(_selectedMaterial);
            }
            if (_currentBrick != null)
            {
                HandleBrickMovement();
            }
            GetXAxis();
        }
Esempio n. 2
0
 private void PlaceBrick()
 {
     if (_currentBrick.Place())
     {
         _currentBrick.SetMaterial(_brickMaterial);
         _currentBrick = null;
     }
 }
Esempio n. 3
0
 private void SwitchBrick(ModBrickInstance newBrick)
 {
     if (_currentBrick != null)
     {
         _currentBrick.SetMaterial(_brickMaterial);
     }
     _currentBrick = newBrick;
     _currentBrick.SetMaterial(_selectedMaterial);
 }