void Start()
    {
        _rigidBody = GetComponent <Rigidbody>();
        _shotSound = GetComponent <AudioSource>();
        boundries  = new Boundries();

        var gameObjectNoShootText = GameObject.FindWithTag("NoShootsText");

        if (gameObjectNoShootText == null)
        {
            Debug.Log("Cannot find 'shoots ' gameObject");
        }
        else
        {
            _nrOfShootsText = gameObjectNoShootText.GetComponent <Text>();
        }


        var gameController = GameObject.FindWithTag("GameController");

        if (gameController == null)
        {
            Debug.Log("Cannot find 'GameController' gameObject");
        }
        else
        {
            _gameController = gameController.GetComponent <GameController>();
            _shootArea      = _gameController.ShootArea;
        }
    }
Esempio n. 2
0
    private void Awake()
    {
        _spaceshipController = gameObject.GetComponent <SpaceshipController>();

        var cameraGameObject = GameObject.FindWithTag("MainCamera");

        if (cameraGameObject == null)
        {
            Debug.Log("Cannot find 'MainCamera' gameObject");
        }
        else
        {
            _camera = cameraGameObject.GetComponent <Camera>();
        }

        var gameController = GameObject.FindWithTag("GameController");

        if (gameController == null)
        {
            Debug.Log("Cannot find 'GameController' gameObject");
        }
        else
        {
            _gameController = gameController.GetComponent <GameController>();
            _shootArea      = _gameController.ShootArea;
        }
    }