Ejemplo n.º 1
0
    // Will trigger the effects in the AIBehaviour Script
    private void UseEffect(AIBehaviour ai, ElementEffect effect)
    {
        if (effect == null)
        {
            return;
        }

        if (effect.willDamage)
        {
            ai.Damage(effect.damage);
        }

        if (effect.willPush)
        {
            Vector3 offset = transform.position - ai.transform.position;
            ai.Push(Mathf.Sign(offset.x), effect.pushForce);
        }

        if (effect.willFreeze)
        {
            ai.Freeze(effect.activeTime);
        }

        if (effect.willStun)
        {
            ai.Stun(effect.activeTime);
        }
    }
Ejemplo n.º 2
0
 void HandleHit(RaycastHit h)
 {
     if (h.transform.tag == "Enemy")
     {
         AIBehaviour ab = h.transform.gameObject.GetComponent <AIBehaviour>();
         ab.Damage(7);
         ab.ToggleGotHit();
     }
 }
Ejemplo n.º 3
0
    void OnParticleCollision(GameObject other)
    {
        if (canHit)
        {
            Rigidbody r = other.GetComponent <Rigidbody>();
            if (r)
            {
                PlayerBehaviour     pB = r.GetComponent <PlayerBehaviour>();
                AIBehaviour         aB = r.GetComponent <AIBehaviour>();
                BossBehaviour       bB = r.GetComponent <BossBehaviour>();
                GiantLaserBehaviour gB = r.GetComponent <GiantLaserBehaviour>();
                if (pB)
                {
                    if (!pB.invinsible & !playerImune)
                    {
                        pB.Damage(damageDealt);
                    }
                }
                if (!enemyImune)
                {
                    if (aB)
                    {
                        aB.Damage(damageDealt);

                        aB.ToggleGotHit();
                    }

                    if (bB)
                    {
                        bB.Damage(damageDealt);
                    }
                    if (gB)
                    {
                        gB.Damage(damageDealt);
                    }
                }
                //Vector3 direction = other.transform.position - transform.position;
                //direction = direction.normalized;
                //r.AddForce(direction * 5);
                //Destroy(gameObject);
                canHit = false;
                StartCoroutine(SetCanHitTrue());
            }
        }
    }
Ejemplo n.º 4
0
    void OnCollisionEnter()
    {
        if (!collided)
        {
            if (audioS)
            {
                audioS.PlayOneShot(collideAudio);
            }

            //get all the colliders inside the radius
            Collider[] collider = Physics.OverlapSphere(transform.position, explosionRadius);
            for (int i = 0; i < collider.Length; i++)
            {
                //
                Rigidbody r = collider[i].GetComponent <Rigidbody>();
                if (r)
                {
                    PlayerBehaviour     pB = r.GetComponent <PlayerBehaviour>();
                    AIBehaviour         aB = r.GetComponent <AIBehaviour>();
                    BossBehaviour       bB = r.GetComponent <BossBehaviour>();
                    GiantLaserBehaviour gB = r.GetComponent <GiantLaserBehaviour>();

                    Vector3 closetPoint = collider[i].ClosestPointOnBounds(transform.position);
                    float   damageDealt = damage - Vector3.Distance(transform.position, closetPoint) * (damage / explosionRadius);
                    if (pB)
                    {
                        if (!pB.invinsible & !playerImune)
                        {
                            if (damageDealt > 0)
                            {
                                pB.Damage(damageDealt);
                                if (!pB.ragdollh.ragdolled)
                                {
                                    pB.playerAnimator.SetTrigger("GotHit");
                                    if (explosionForce > 10)
                                    {
                                        pB.ToggleRagdoll();
                                        if (!pB.dead)
                                        {
                                            pB.StandUpAfter(2f);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (!enemyImune)
                    {
                        if (aB)
                        {
                            if (damageDealt > 0)
                            {
                                aB.Damage(damageDealt);

                                aB.ToggleGotHit();
                            }
                        }

                        if (bB)
                        {
                            if (damageDealt > 0)
                            {
                                bB.Damage(damageDealt);
                            }
                        }
                        if (gB)
                        {
                            if (damageDealt > 0)
                            {
                                gB.Damage(damageDealt);
                            }
                        }
                    }
                    r.AddExplosionForce(explosionForce, transform.position, explosionRadius);
                }
            }
            if (particle)
            {
                Instantiate(particle, transform.position, Quaternion.identity);
            }
            if (trail)
            {
                trail.transform.parent = null;
            }
            collided = true;
            gameObject.GetComponentInChildren <Renderer>().enabled = false;
            try
            {
                gameObject.GetComponentInChildren <ParticleSystem>().Stop();
            }
            catch
            {
                ;
            }
            if (audioS)
            {
                audioS.PlayOneShot(collideAudio);
            }
            StartCoroutine(DestroyThis(1f));
        }
    }