Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        SetStartPosition();
        this._player = GameObject.Find("Player").GetComponent <Player>();
        LogHelper.CheckForNull(_player, nameof(_player));

        this._isDestroyedHash = Animator.StringToHash("IsDestroyed");
        this._animator        = GetComponent <Animator>();
        LogHelper.CheckForNull(_animator, nameof(_animator));

        this._boxCollider = GetComponent <BoxCollider2D>();
        LogHelper.CheckForNull(_boxCollider, nameof(_boxCollider));

        this._audioManager = GameObject.Find("Audio_Manager").GetComponent <AudioManager>();
        LogHelper.CheckForNull(_audioManager, nameof(_audioManager));

        this._spriteRender = GetComponent <SpriteRenderer>();

        _nextFire = Time.time + UnityEngine.Random.Range(0.5f, 3f);

        if (_shieldsChildComponent != null)
        {
            _hasShields = UnityEngine.Random.Range(0f, 100f) > 100f - _percentageChanceOfShields;
            if (_hasShields)
            {
                _shields = _shieldsChildComponent.GetComponent <Shields>();
                _shields.Initialize(2);
                ActivateShields(true);
            }
        }

        if (_proximityChildComponent != null)
        {
            _proximityChildComponent.Initialize(OnProximityDetected);
            _proximityChildComponent.enabled = true;

            _isAggressive = UnityEngine.Random.Range(0f, 100f) > 100f - _percentageChanceOfAggressive;
        }

        _canDodgeShots = UnityEngine.Random.Range(0f, 100f) > 100f - _percentageChanceOfDodgingShots;
    }