Exemplo n.º 1
0
    void OnContact()
    {
        CompCollider col          = GetComponent <CompCollider>();
        GameObject   collided_obj = col.GetCollidedObject();

        Vector3 point  = col.GetContactPoint();
        Vector3 normal = col.GetContactNormal();

        // DAMAGE ---
        if (collided_obj != null && destroyed == false)
        {
            /* PLAY AUDIO */
            GetComponent <CompAudio>().PlayEvent("TheonImpact");
            //Lock transform to avoid trespassing more than one collider
            rb.LockTransform();

            // Check the specific enemy in front of you and apply dmg or call object OnContact
            EnemiesManager enemy_manager = GetLinkedObject("player_enemies_manager").GetComponent <EnemiesManager>();
            if (enemy_manager.IsEnemy(collided_obj))
            {
                enemy_manager.ApplyDamage(collided_obj, damage, Enemy_BT.ENEMY_GET_DAMAGE_TYPE.ARROW);
                if (arrow_blood_particles != null)
                {
                    arrow_blood_particles.GetComponent <Transform>().SetUpVector(normal);
                    arrow_blood_particles.GetComponent <Transform>().SetPosition(point + normal * 2);

                    CompParticleSystem arrow_particles_script = arrow_blood_particles.GetComponent <CompParticleSystem>();
                    arrow_particles_script.ActivateEmission(true);
                }
            }
            else
            {
                CompCollider obj_col = collided_obj.GetComponent <CompCollider>();
                if (obj_col != null)
                {
                    obj_col.CallOnContact();
                }
                if (arrow_sparks_particles != null)
                {
                    arrow_sparks_particles.GetComponent <Transform>().SetUpVector(normal);
                    arrow_sparks_particles.GetComponent <Transform>().SetPosition(point + normal * 2);

                    CompParticleSystem wall_particles_script = arrow_sparks_particles.GetComponent <CompParticleSystem>();
                    wall_particles_script.ActivateEmission(true);
                }
            }
        }
        if (destroyed == false)
        {
            Destroy(gameObject);
            destroyed = true;
        }
    }
    void OnContact()
    {
        if (collided == false)
        {
            GameObject collided_obj = GetComponent <CompCollider>().GetCollidedObject();

            // DAMAGE ---
            if (collided_obj != null)
            {
                rb = GetComponent <CompRigidBody>();
                //Lock transform to avoid trespassing more than one collider
                rb.LockTransform();

                // Check the specific enemy in front of you and apply dmg or call object OnContact
                EnemiesManager enemy_manager = GetLinkedObject("player_enemies_manager").GetComponent <EnemiesManager>();
                if (enemy_manager.IsEnemy(collided_obj))
                {
                    collided = true;
                    enemy_manager.ApplyDamage(collided_obj, damage, Enemy_BT.ENEMY_GET_DAMAGE_TYPE.FIREBREATH);
                }
            }
        }
    }
Exemplo n.º 3
0
    void OnContact()
    {
        CompCollider col = GetComponent <CompCollider>();

        if (fireball_particles != null)
        {
            Vector3 point  = col.GetContactPoint();
            Vector3 normal = col.GetContactNormal();

            fireball_particles.GetComponent <Transform>().SetUpVector(normal);
            point = point + normal * 4;
            fireball_particles.GetComponent <Transform>().SetPosition(point);

            CompParticleSystem fireball_particles_script = fireball_particles.GetComponent <CompParticleSystem>();
            fireball_particles_script.ActivateEmission(true);

            if (fireball_particles2 != null)
            {
                fireball_particles_script = fireball_particles2.GetComponent <CompParticleSystem>();
                fireball_particles_script.ActivateEmission(true);
            }
            if (fireball_particles3 != null)
            {
                fireball_particles_script = fireball_particles3.GetComponent <CompParticleSystem>();
                fireball_particles_script.ActivateEmission(true);
            }
            if (fireball_particles4 != null)
            {
                fireball_particles_script = fireball_particles4.GetComponent <CompParticleSystem>();
                fireball_particles_script.ActivateEmission(true);
            }
        }

        GameObject collided_obj = GetComponent <CompCollider>().GetCollidedObject();

        GetComponent <CompAudio>().PlayEvent("DaenerysFireballImpact");
        // DAMAGE ---
        if (collided_obj != null)
        {
            // Check the specific enemy in front of you and apply dmg or call object OnContact
            EnemiesManager enemy_manager = GetLinkedObject("player_enemies_manager").GetComponent <EnemiesManager>();
            if (!destroyed)
            {
                if (enemy_manager.IsEnemy(collided_obj))
                {
                    enemy_manager.ApplyDamage(collided_obj, damage, Enemy_BT.ENEMY_GET_DAMAGE_TYPE.FIREBALL);
                }
                else
                {
                    destroyed = true;
                    Debug.Log("Destroy 1", Department.GENERAL);
                    Destroy(gameObject);
                    return;
                }
            }
        }


        if (fireball && destroyed == false)
        {
            col.CollisionActive(false);
            Debug.Log("Destroy 2", Department.GENERAL);
            Destroy(gameObject);
            destroyed = true;
            return;
        }
    }