Exemplo n.º 1
0
    /// <summary>
    /// Initialize Script
    /// </summary>
    public virtual void Init(EnemyManager _enemyMng)
    {
        graphics      = GetComponentInChildren <EnemyGraphicController>();
        enemyMng      = _enemyMng;
        startPosition = transform.position;
        startRotation = transform.rotation;

        ResetLife();
        ResetStunHit();
        ResetPosition();
        SetCanStun(true);

        // Initialize Enemy State Machine
        enemySM = GetComponent <EnemySMController>();
        if (enemySM != null)
        {
            enemySM.Init(this);
        }

        toleranceCtrl = GetComponent <EnemyToleranceController>();
        if (toleranceCtrl != null)
        {
            toleranceCtrl.Init();
        }

        collisionCtrl = GetComponent <EnemyCollisionController>();
        if (collisionCtrl != null)
        {
            collisionCtrl.Init();
        }

        movementCtrl = GetComponent <EnemyMovementController>();
        if (movementCtrl != null)
        {
            movementCtrl.Init(collisionCtrl);
        }

        animCtrl = GetComponentInChildren <EnemyAnimationController>();
        if (animCtrl != null)
        {
            animCtrl.Init(this);
        }

        commandsSpriteCtrl = GetComponentInChildren <EnemySpriteController>();
        if (commandsSpriteCtrl != null)
        {
            commandsSpriteCtrl.Init(this);
        }

        vfxCtrl = GetComponentInChildren <EnemyVFXController>();
        if (vfxCtrl != null)
        {
            vfxCtrl.Init(this);
        }

        sfxCtrl = GetComponentInChildren <EnemySoundController>();
        if (sfxCtrl != null)
        {
            sfxCtrl.Setup(this);
            sfxCtrl.Init();
        }

        viewCtrl = GetComponent <EnemyViewController>();
        if (viewCtrl != null)
        {
            viewCtrl.Init();
        }

        CalculatePathLenght();
    }