Ejemplo n.º 1
0
    private void Awake()
    {
        _animator = GetComponent <Animator>();


        if (!_animator)
        {
            Debug.LogError("Failed to get Animator on " + gameObject.name.ToString() + " creating one now");
            _animator = gameObject.AddComponent <Animator>();
        }

        _sphereHandler = GetComponent <SphereHandler>();

        if (!_sphereHandler)
        {
            Debug.LogError("Failed to get SphereHandler on " + gameObject.name.ToString() + " creating one now");
            _sphereHandler = gameObject.AddComponent <SphereHandler>();
        }

        _rb = GetComponent <Rigidbody>();

        if (!_rb)
        {
            Debug.LogError("Failed to get Rigidbody on " + gameObject.name.ToString() + " creating one now");
            _rb = gameObject.AddComponent <Rigidbody>();
        }


        _animClips = _animator.runtimeAnimatorController.animationClips;

        _isDeadHash = Animator.StringToHash("IsDead");

        _sphereHandler.OnPickupDieEvent += HandleDeathAnim;
    }
Ejemplo n.º 2
0
    private IEnumerator EmitSpheres()
    {
        while (_gameController.IsRunning)
        {
            yield return(_emitterDelay);

            if (_gameController.IsRunning)
            {
                SphereHandler sphere = Instantiate(
                    _sphere, Vector3.up, Quaternion.identity)
                                       .GetComponent <SphereHandler>();

                yield return(null);

                sphere.SetDirection();
            }
        }
    }