Ejemplo n.º 1
0
 public override HexagonBaseState EnemyStay(EnemyBaseAIBehaviour enemy)
 {
     if (subState == SubState.EXPLODING)
     {
         enemy.InstantKill();
     }
     return(null);
 }
    public virtual void InitialSetup(GameObject e)
    {
        entityGO = e;
        entity   = entityGO.GetComponent <EnemyBaseAIBehaviour>();
        agent    = entityGO.GetComponent <UnityEngine.AI.NavMeshAgent>();
        animator = entityGO.GetComponent <Animator>();

        ResetValues();
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Enemy")
        {
            EnemyBaseAIBehaviour enemy = other.GetComponent <EnemyBaseAIBehaviour>();

            //Mosquito has the collider in a children object so we need to search for script in parent
            if (enemy == null)
            {
                enemy = other.GetComponentInParent <EnemyBaseAIBehaviour>();
            }

            if (enemy != null)
            {
                bb.enemiesInRange.Add(enemy);
            }
        }
        else if (other.tag == "Shot")
        {
            EnemyShotControllerBase shot = other.GetComponent <EnemyShotControllerBase>();

            if (shot != null)
            {
                bb.shotsInRange.Add(shot);
            }
        }
        else if (other.tag == "WormHead")
        {
            WormAIBehaviour worm = other.GetComponent <WormAIBehaviour>();

            if (worm != null)
            {
                bb.worm = worm;
                worm.SpecialAttackInRange();
            }
        }
        else if (other.tag == "Vortex")
        {
            VortexController vortex = other.GetComponent <VortexController>();

            if (vortex != null)
            {
                bb.vortexInRange.Add(vortex);
            }
        }
        else if (other.tag == "Turret")
        {
            TurretAIBehaviour turret = other.GetComponent <TurretAIBehaviour>();

            if (turret != null)
            {
                bb.turretsInRange.Add(turret);
            }
        }
    }
Ejemplo n.º 4
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Enemy")
        {
            EnemyBaseAIBehaviour enemy = other.GetComponent <EnemyBaseAIBehaviour>();

            //Mosquito has the collider in a children object so we need to search for script in parent
            if (enemy == null)
            {
                enemy = other.GetComponentInParent <EnemyBaseAIBehaviour>();
            }

            if (enemy != null)
            {
                controller.EnemyInRange(enemy);
            }
        }
    }
Ejemplo n.º 5
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "Player1" || other.tag == "Player2")
     {
         PlayerController player = other.GetComponent <PlayerController>();
         ChangeStateIfNotNull(currentState.PlayerStay(player));
     }
     else if (other.tag == "EnemyHexagonBodyProbe")
     {
         EnemyBaseAIBehaviour enemy = other.GetComponentInParent <EnemyBaseAIBehaviour>();
         ChangeStateIfNotNull(currentState.EnemyStay(enemy));
     }
     else if (other.tag == "WormHead" || other.tag == "WormBody" || other.tag == "WormTail")
     {
         isWormTouchingHexagon = true;
         if (other.tag == "WormHead")
         {
             ChangeStateIfNotNull(currentState.WormHeadStay(other.transform));
         }
     }
 }
Ejemplo n.º 6
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player1" || other.tag == "Player2")
        {
            PlayerController player = other.GetComponent <PlayerController>();
            PlayerTouched(player, transform.position);
        }
        else if (other.tag == "EnemyHexagonBodyProbe")
        {
            EnemyBaseAIBehaviour enemy = other.GetComponent <EnemyBaseAIBehaviour>();

            if (enemy == null)
            {
                enemy = other.GetComponentInParent <EnemyBaseAIBehaviour>();
            }

            if (enemy != null)
            {
                enemy.InstantKill();
            }
        }
    }
 public override HexagonBaseState EnemyStay(EnemyBaseAIBehaviour enemy)
 {
     enemy.InstantKill();
     return(null);
 }
    void OnCollisionEnter(Collision collision)
    {
        //Stop shot
        rigidBody.velocity = Vector3.zero;
        projectileParticle.SetActive(false);

        impactParticle.GetComponent <AudioSource>().clip = wrongImpact;

        if (collision.collider.tag == "Enemy")
        {
            EnemyBaseAIBehaviour enemy = collision.collider.GetComponent <EnemyBaseAIBehaviour>();
            if (enemy == null)
            {
                enemy = collision.collider.GetComponentInParent <EnemyBaseAIBehaviour>();
            }

            if (enemy != null)
            {
                if (enemy.color == color)
                {
                    impactParticle.GetComponent <AudioSource>().clip = goodImpact;
                }

                enemy.ImpactedByShot(color, damage, transform.forward * forceMultiplier, player);
            }
        }
        else if (collision.collider.tag == "Vortex")
        {
            VortexController vortex = collision.collider.GetComponent <VortexController>();
            if (vortex != null)
            {
                vortex.ImpactedByShot(color, damage, player);
                if (vortex.Active)
                {
                    impactParticle.GetComponent <AudioSource>().clip = goodImpact;
                }
                else
                {
                    impactParticle.GetComponent <AudioSource>().clip = wrongImpact;
                }
            }
        }
        else if (collision.collider.tag == "Barrel")
        {
            CapacitorImpacted barrel = collision.collider.GetComponent <CapacitorImpacted>();
            if (barrel != null)
            {
                barrel.controller.ImpactedByShot(color, player);
            }

            impactParticle.GetComponent <AudioSource>().clip = goodImpact;
        }
        else if (collision.collider.tag == "WormBody")
        {
            WormBodySegmentController worm = collision.collider.GetComponent <WormBodySegmentController>();
            if (worm != null)
            {
                if (worm.Color == color)
                {
                    impactParticle.GetComponent <AudioSource>().clip = goodImpact;
                }

                worm.ImpactedByShot(color, damage, player);
            }
        }
        else if (collision.collider.tag == "WormHead")
        {
            WormAIBehaviour worm = collision.collider.GetComponent <WormAIBehaviour>();
            if (worm != null)
            {
                worm.ImpactedByShot(color, damage, player);
            }

            impactParticle.GetComponent <AudioSource>().clip = goodImpact;
        }
        else if (collision.collider.tag == "Hexagon")
        {
            HexagonController hexagon = collision.collider.GetComponentInParent <HexagonController>();
            if (hexagon != null)
            {
                hexagon.ImpactedByShot(player);
                if (hexagon.HasActiveTurret())
                {
                    impactParticle.GetComponent <AudioSource>().clip = goodImpact;
                }
                else
                {
                    impactParticle.GetComponent <AudioSource>().clip = wrongImpact;
                }
            }
        }

        if (collision.contacts.Length > 0)
        {
            impactParticle.transform.rotation = Quaternion.FromToRotation(Vector3.up, collision.contacts[0].normal);
        }
        impactParticle.SetActive(true);

        shotCollider.enabled = false;
        //We let the impactParticle do its job
        StartCoroutine(WaitAndReturnToPool());
    }
Ejemplo n.º 9
0
 public virtual HexagonBaseState EnemyStay(EnemyBaseAIBehaviour enemy)
 {
     return(null);
 }
Ejemplo n.º 10
0
 void Awake()
 {
     agent = GetComponentInParent <EnemyBaseAIBehaviour>();
 }
Ejemplo n.º 11
0
 public void EnemyOutOfRange(EnemyBaseAIBehaviour enemy)
 {
     enemiesInRange.Remove(enemy);
 }
Ejemplo n.º 12
0
 public void EnemyInRange(EnemyBaseAIBehaviour enemy)
 {
     enemiesInRange.Add(enemy);
 }
Ejemplo n.º 13
0
    private IEnumerator SpecialExplosion()
    {
        //Add enemies to sorted list
        foreach (EnemyBaseAIBehaviour enemy in bb.enemiesInRange)
        {
            float distance = Vector3.Distance(enemy.transform.position, currentPos);
            enemies.Add(distance, enemy);
        }

        yield return(new WaitForSeconds(0.1f));


        float damage = bb.player.specialAttackDamage;
        float baseForceMultiplier = bb.player.forceMultiplierAtDistance1;
        float forceAttenuation    = bb.player.forceAttenuationByDistance;
        float elapsedTime         = 0f;
        int   i = 0;

        foreach (EnemyShotControllerBase shot in bb.shotsInRange)
        {
            shot.Impact();
        }

        if (bb.worm != null)
        {
            bb.worm.ImpactedBySpecial(damage, bb.player);
        }

        foreach (VortexController vortex in bb.vortexInRange)
        {
            vortex.ImpactedBySpecial(bb.player);
        }

        foreach (TurretAIBehaviour turret in bb.turretsInRange)
        {
            turret.ImpactedBySpecial(bb.player);
        }

        while (i < enemies.Count)
        {
            float currentDistance = bb.player.specialAttackAffectationRadius / elapsedTime;

            float enemyDistance        = enemies.Keys[i];
            EnemyBaseAIBehaviour enemy = enemies.Values[i];

            while (enemyDistance <= currentDistance && i < enemies.Count)
            {
                Vector3 direction = enemy.transform.position - currentPos;
                if (enemyDistance < 1f)
                {
                    enemyDistance = 1f;
                }
                direction.y = 0;
                direction.Normalize();
                float totalForceMultiplier = baseForceMultiplier / Mathf.Pow(forceAttenuation, enemyDistance - 1);
                direction *= totalForceMultiplier;
                enemy.ImpactedBySpecial(damage, direction, bb.player);

                ++i;
                if (i < enemies.Count)
                {
                    enemyDistance = enemies.Keys[i];
                    enemy         = enemies.Values[i];
                }
            }

            yield return(null);

            elapsedTime += Time.deltaTime;
        }

        bb.specialAttackDetector.SetActive(false);
        enemies.Clear();

        // DamageEnemies();
    }