void OnContact()
    {
        Debug.Log("CONTACT", Department.STAGE, Color.RED);
        CompCollider col          = GetComponent <CompCollider>();
        GameObject   collided_obj = col.GetCollidedObject();



        if (collided_obj != null && destroyed == false)
        {
            if (collided_obj.CompareTag("player"))
            {
                CharactersManager cm = collided_obj.GetComponent <CharactersManager>();

                if (cm != null)
                {
                    cm.GetDamageProjectile(damage);
                }
            }

            Debug.Log(collided_obj.GetTag().ToString(), Department.STAGE);
        }
        else
        {
            Debug.Log("Collided obj NULL", Department.STAGE, Color.ORANGE);
        }

        if (!destroyed)
        {
            destroyed = true;
            col.CollisionActive(false);
            audio.PlayEvent("DaenerysFireballImpact");
            Destroy(gameObject);
        }
    }
예제 #2
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;
        }
    }