Example #1
0
 private void Awake()
 {
     IsDead     = false;
     _rigidbody = GetComponent <Rigidbody>();
     firstFriendlyFollowDistance = friendlyFollowDistance * 2f;
     enemyAnimator = GetComponent <EnemyAnimatorController>();
 }
Example #2
0
 protected virtual void Awake()
 {
     Motor        = GetComponent <EnemyMovementMotor>();
     Animator     = GetComponent <EnemyAnimatorController>();
     AiController = GetComponentInChildren <BehaviourController>();
     SoundBank    = GetComponentInChildren <EnemySoundBank>();
 }
Example #3
0
    void Update()
    {
        timer += Time.deltaTime;
        // If the enemy can attack, the player is in range and the enemy still has health, execute attack.
        if (timer >= timeBetweenAttacks && playerInRange && GetComponent <EnemyHealth>().currentHealth > 0)
        {
            // If there is a sound associated, play it
            if (attackSound != null)
            {
                SfxScript.playSound(attackSound);
            }

            // If there is an animation associated, play it
            if (anim != null)
            {
                EnemyAnimatorController.ExecuteAnimation(anim, "Attack");
            }
            else
            {
                // Exclusive animation for the spider model
                attackAnimation();
            }
            Attack(player);
        }
    }
Example #4
0
    private void LoadModelInContainer(GameObject modelPrefab)
    {
        var model = Instantiate(modelPrefab, modelContainer);

        animator = model.AddComponent <EnemyAnimatorController>();
        animator.OnDmgAnimationComplete += Animator_OnDmgAnimationComplete;
        animator.OnAtkAnimationComplete += Animator_OnAtkAnimationComplete;
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (!enemyAnimatorController)
        {
            enemyAnimatorController = animator.gameObject.GetComponent <EnemyAnimatorController>();
        }

        enemyAnimatorController.DispatchDmgAnimationCompleteEvent();
    }
Example #6
0
 public void Construct(EnemyBehavior behevior, EnemyHealth health, EnemyAnimatorController animatorController, EnemyMover enemyMover, EnemyDistanceSkills distanceSkills, Shooter shooter)
 {
     _behevior           = behevior;
     _health             = health;
     _animatorController = animatorController;
     _enemyMover         = enemyMover;
     _distanceSkills     = distanceSkills;
     _shooter            = shooter;
 }
Example #7
0
 private void Start()
 {
     //Setta le regole di gravità e trova il Controller2D
     controller = GetComponent <EnemyController2D>();
     enemyAnimationController   = GetComponent <EnemyAnimatorController>();
     originalGravity            = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
     maxJumpVelocity            = Mathf.Abs(originalGravity) * timeToJumpApex;
     minJumpVelocity            = Mathf.Sqrt(2 * Mathf.Abs(originalGravity) * minJumpHeight);
     contactFilter.useLayerMask = true;
     contactFilter.layerMask    = contactMask;
     contactFilter.useTriggers  = true;
 }
    void Awake()
    {
        _motor    = transform.parent.GetComponent <EnemyMovementMotor>();
        _animator = transform.parent.GetComponent <EnemyAnimatorController>();
        _health   = transform.parent.GetComponent <EnemyHealth>();

        _soundBank  = transform.parent.GetComponentInChildren <EnemySoundBank>();
        _pathFinder = transform.parent.GetComponentInChildren <PathFinder>();

        _patrolAi  = GetComponent <PatrolBehaviour>();
        _pursueAi  = GetComponent <PursueBehaviour>();
        _exploreAi = GetComponent <ExploreBehaviour>();
    }
    void Awake()
    {
        animtor = GetComponent<Animator>();
        navAgent = GetComponent<NavMeshAgent>();
        opticSphereCol = GetComponent<SphereCollider>();
        playerGameObject = GameObject.FindGameObjectWithTag(DoneTags.player);
        animatorController = GameObject.Find(PathHelper.gameManagerPath).GetComponent<EnemyAnimatorController>();
        gameManager = GameObject.Find(PathHelper.gameManagerPath).GetComponent<GameManager>();
        enemyStatus = gameObject.transform.FindChild(GameObjectNameHelper.robotGuardName).GetComponent<EnemyStatus>();

        animtor.SetLayerWeight(1, 1f);
        animtor.SetLayerWeight(2, 1f);
    }
Example #10
0
 // Update is called once per frame
 void Update()
 {
     timer += Time.deltaTime;
     // Shoots after a certain time between attacks
     if (timer >= timeBetweenAttacks && shouldShoot)
     {
         timer = 0f;
         if (anim != null)
         {
             EnemyAnimatorController.ExecuteAnimation(anim, "Cast");
         }
         Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
     }
 }
Example #11
0
    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;
        if (timer >= timeBetweenAttacks && shoot)
        {
            timer = 0f;

            // Cast animations if they exist
            if (anim != null)
            {
                EnemyAnimatorController.ExecuteAnimation(anim, "Cast");
            }
            // Instaniate the four shots
            Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
            Instantiate(shot, shotSpawn1.position, shotSpawn1.rotation);
            Instantiate(shot, shotSpawn2.position, shotSpawn2.rotation);
            Instantiate(shot, shotSpawn3.position, shotSpawn3.rotation);
        }
    }
Example #12
0
 protected void Awake()
 {
     this.animController = GetComponent <EnemyAnimatorController>();
     this.audioSource    = GetComponent <AudioSource>();
 }
Example #13
0
 void Awake()
 {
     navAgent = GetComponent<NavMeshAgent>();
     animator = GetComponent<Animator>();
     eac = GameObject.Find("GameMaster").GetComponent<EnemyAnimatorController>();
 }
Example #14
0
    public void TakeDamage(int amount)
    {
        // Reduce current health by the amount of damage taken.
        currentHealth -= amount;

        // Trigger hurt sound if it exists
        if (hurtSound != null)
        {
            SfxScript.playSound(hurtSound);
        }

        // Trigger hurt animation if it exists
        if (anim != null)
        {
            EnemyAnimatorController.ExecuteAnimation(anim, "Hit");
        }

        // Trigger flash if it exists
        EnemyFlash flash = this.gameObject.GetComponent <EnemyFlash>();

        if (flash != null)
        {
            StartCoroutine(flash.Flash());
        }

        // If the current health is less than or equal to zero
        if (currentHealth <= 0)
        {
            if (isDead == false)
            {
                isDead = true;
                Debug.Log("Enemy Destroyed!");
                if (this.tag == "Enemy" || this.tag == "Boss")
                {
                    // Increment score when destroyed.
                    Debug.Log("INCREMEMNTING!");

                    // Increment the score
                    TEMPScoreScript.Instance.IncrementScore(scoreAwarded);
                }

                // Play death sound if it exists
                if (deathSound != null)
                {
                    SfxScript.playSound(deathSound);
                }

                // Play death animation if it exists
                if (anim != null)
                {
                    EnemyAnimatorController.ExecuteAnimation(anim, "Die");
                }

                // Play spider aninimation exclusively
                SpiderAnimation temp = GetComponent <SpiderAnimation>();
                if (temp != null)
                {
                    Debug.Log("THIS IS A SPIDER!");
                    temp.spiderKilled();
                }
                else
                {
                    Destroy(gameObject, 1f);
                }
            }
        }
    }
Example #15
0
 private void Awake()
 {
     navMeshAgent            = GetComponent <NavMeshAgent>();
     navMeshAgent.speed      = fieldStorageSO.fieldController.ConcreteGameField.enemySpeed;
     enemyAnimatorController = GetComponent <EnemyAnimatorController>();
 }