private void OnTriggerEnter(Collider other)
    {
        if (((1 << other.gameObject.layer) & m_LayerMask) != 0) //if the collided gameobject is on the layer provided
        {
            AITakeDamageInterface enemy = other.transform.root.GetComponent <AITakeDamageInterface>();

            if (enemy != null) //if the collided gameobject has a health component
            {
                if (PhotonNetwork.isMasterClient)
                {
                    enemy.TakeDamage(m_ProjectileOwner, m_Damage, null, AIUtilits.GetCritMultiplier(other.gameObject));
                }
            }
        }
    }
Beispiel #2
0
    private void OnTriggerEnter(Collider other)
    {
        //if the overpen shot hits an enemy
        if (other.gameObject.tag == "Enemy")
        {
            //deal damage to the enemy that collided with it
            AI collidedAI = other.gameObject.transform.root.GetComponent <AI>();

            if (!m_AttackedAI.Contains(collidedAI))
            {
                collidedAI.TakeDamage(m_ProjectileOwner, Damage, null, AIUtilits.GetCritMultiplier(other.gameObject));
                m_AttackedAI.Add(collidedAI);
            }
        }
        else
        {
            gameObject.SetActive(false);
            m_AttackedAI.Clear();
        }
    }
Beispiel #3
0
    private void OnCollisionEnter(Collision collision)
    {
        if (!m_CanCollide)
        {
            return;
        }
        SoundManager.GetInstance().photonView.RPC("PlaySFXNetworked", PhotonTargets.All, "GrenadeExplosion", transform.position);
        //instantiate explosion render
        GameObject      explosionRenderer = (GameObject)(Instantiate(Resources.Load("Effects/ExplosionRenderer"), gameObject.transform.position, Quaternion.identity));
        ExplosionEffect explosionEffect   = explosionRenderer.GetComponent <ExplosionEffect>();

        explosionEffect.ActivateExplosion(Radius);

        m_CanCollide = false;
        gameObject.SetActive(false); //return object to pool

        Collider[] colliders;        //stores all colliders that were hit
        m_EnemiesHit.Clear();

        colliders = Physics.OverlapSphere(gameObject.transform.position, Radius, m_LayerMask);

        //if we collided with any objects of our specific target layer mask then they take damage
        for (int i = 0; i < colliders.Length; i++)
        {
            AITakeDamageInterface enemy = colliders[i].transform.root.GetComponent <AITakeDamageInterface>();

            if (enemy != null && !m_EnemiesHit.Contains(enemy)) //if the collided object has a health component
            {
                m_EnemiesHit.Add(enemy);

                if (PhotonNetwork.isMasterClient)
                {
                    enemy.TakeDamage(m_ProjectileOwner, m_Damage, null, AIUtilits.GetCritMultiplier(colliders[i].gameObject));
                }
            }
        }
    }
    protected void HandleHitLogic(RaycastHit hit, int targetMask, int damage, int owner, float range, Vector3 gunLocation, bool enemyShot = false)
    {
        if (((1 << hit.collider.gameObject.layer) & targetMask) != 0) //if the raycast hit an object on the specific layer
        {
            AITakeDamageInterface enemy = null;
            Player p = null;

            if (enemyShot)
            {
                p = hit.collider.transform.root.GetComponent <Player>();
            }
            else
            {
                enemy = hit.collider.transform.root.GetComponent <AITakeDamageInterface>();
            }

            if (enemy != null) //if the raycasted object has a health component
            {
                if (PhotonNetwork.isMasterClient)
                {
                    //Get the distance from the hit and the gun
                    float distance    = Vector3.Distance(hit.point, gunLocation);
                    int   FinalDamage = MathFunc.CalculateDamageDropoff(damage, distance, range);

                    enemy.TakeDamage(owner, FinalDamage, null, AIUtilits.GetCritMultiplier(hit.collider.gameObject));
                }
            }
            else if (p != null)
            {
                if (p.photonView.isMine)
                {
                    p.TakeDamage(damage, Vector3.zero, null);
                }
            }
        }
    }
 public void OnTriggerEnter(Collider other)
 {
     //If the thing collided with is tagged as a player get the health Component
     if (other.gameObject.tag == "Enemy")
     {
         //Get the health component and deal the damage if a component is found
         AITakeDamageInterface enemy = other.transform.root.GetComponent <AITakeDamageInterface>();
         if (PhotonNetwork.isMasterClient)
         {
             for (int i = 0; i < playerRef.NumOfAttacks; i++)
             {
                 enemy.TakeDamage(playerRef.PlayerNumber, (playerRef.BoostedMeleeDamage + 2) * playerRef.NumOfAttacks, null, AIUtilits.GetCritMultiplier(other.gameObject));
             }
         }
     }
 }
Beispiel #6
0
    private void OnTriggerEnter(Collider other)
    {
        if (photonView.isMine)
        {
            if (m_RootObjectsHit.Contains(other.transform.root))
            {
                return;
            }

            if (other.gameObject.tag == "Enemy" && OwningObject != ObjectTags.Enemy)
            {
                AI aiTakeDamage = other.transform.root.GetComponent <AI>();
                aiTakeDamage.photonView.RPC("TakeDamage", PhotonTargets.MasterClient, m_ReferenceID, m_Damage, m_ElementDamage, AIUtilits.GetCritMultiplier(other.gameObject));

                //add the root transform to the list in order to make sure that this object cannot be spammed with damage
                m_RootObjectsHit.Add(other.transform.root);
            }
        }
    }
Beispiel #7
0
    private void OnCollisionEnter(Collision collision)
    {
        if (m_LerpingToEnemy && collision.gameObject.tag != "Enemy")
        {
            return;
        }

        m_LerpingToEnemy = false;

        if (collision.gameObject.tag == "Enemy" && m_NumberOfEnemyBounces < 2)
        {
            AITakeDamageInterface enemy = collision.transform.root.GetComponent <AITakeDamageInterface>();

            if (enemy != null)
            {
                if (m_LastHitEnemy != enemy)
                {
                    m_LastHitEnemy = enemy;

                    if (PhotonNetwork.isMasterClient)
                    {
                        enemy.TakeDamage(m_ProjectileOwner, Mathf.RoundToInt(m_Damage * m_DamageMultiplier), m_StatusEffects, AIUtilits.GetCritMultiplier(collision.gameObject));
                    }
                }
                else
                {
                    //rigidbody.velocity = Vector3.zero;
                    //rigidbody.AddForce(-collision.contacts[0].normal * ShotSpeed, ForceMode.VelocityChange);
                    //return;
                }
            }

            m_NumberOfEnemyBounces++;

            if (m_NumberOfEnemyBounces < 2)
            {
                BounceTomahawk(collision);
            }
            else
            {
                ReturnToPlayer();
            }
        }
        else if (collision.gameObject.tag != "Enemy" && m_NumberOfSurfaceBounces < 2)
        {
            m_NumberOfSurfaceBounces++;
            SoundManager.GetInstance().photonView.RPC("PlaySFXNetworked", PhotonTargets.All, "TomahawkImpact", collision.gameObject.transform.position);

            if (m_NumberOfSurfaceBounces < 2)
            {
                BounceTomahawk(collision);
            }
            else
            {
                ReturnToPlayer();
            }
        }
    }