void OnTriggerEnter(Collider other)
 {
     //if the object is not already in the list
     if (!TriggerList.Contains(other))
     {
         if (enemy_strike)
         {
             if (other.tag == "Player")
             {
                 if (FL.ReturnIsEnemyCustomPlayer(ETM.Return_FactionEnum(), ETM.Return_customReputation()))
                 {
                     TriggerList.Add(other);
                 }
             }
             else if (other.tag == "BasicEnemy")
             {
                 if (FL.ReturnIsEnemy(ETM.Return_FactionEnum(), other.gameObject.GetComponentInParent <EnemyTemplateMaster>().Return_FactionEnum()))
                 {
                     TriggerList.Add(other);
                 }
             }
         }
         if (!enemy_strike && other.gameObject.tag == "BasicEnemy")
         {
             TriggerList.Add(other);
         }
     }
 }
 void OnTriggerStay(Collider other) //Uses physics time //TODO CHANGE TO SUPPORT
 {
     if (deal_damage)
     {
         if (enemy_strike)
         {
             if (other.tag == "Player")
             {
                 if (FL.ReturnIsEnemyCustomPlayer(ETM.Return_FactionEnum(), ETM.Return_customReputation()))
                 {
                     other.gameObject.GetComponent <Health>().take_damage(damage * 4 * Time.fixedDeltaTime, DT: DamageType.Piercing, isDoT: true);
                 }
             }
             else if (other.tag == "BasicEnemy")
             {
                 if (FL.ReturnIsEnemy(ETM.Return_FactionEnum(), other.gameObject.GetComponentInParent <EnemyTemplateMaster>().Return_FactionEnum()))
                 {
                     other.gameObject.GetComponent <Health>().take_damage(damage * 4 * Time.fixedDeltaTime, DT: DamageType.Piercing, isDoT: true);
                 }
             }
         }
         if (!enemy_strike && other.gameObject.tag == "BasicEnemy")
         {
             other.gameObject.GetComponent <Health>().take_damage(damage * 4 * Time.fixedDeltaTime, true, DT: DamageType.Piercing, isDoT: true);
         }
     }
 }
    public void OnTriggerEnter(Collider other)
    {
        if (!disabled) //Prevents projectile from damaging more than 1 object
        {
            if (other.gameObject.layer == LayerMask.NameToLayer("Terrain") || other.gameObject.layer == LayerMask.NameToLayer("Obstacles") || other.gameObject.layer == LayerMask.NameToLayer("SmallObstacles"))
            {
                Destroy(gameObject);
            }

            if (Player_Fired)
            {
                if (other.tag == "BasicEnemy")
                {
                    DealDamage(other, true);
                }
            }
            else
            {
                if (other.tag == "Player" && FL.ReturnIsEnemyCustomPlayer(FacEnum, PlayerRepModifier))
                {
                    DealDamage(other, false);
                }

                if (other.tag == "BasicEnemy" && FL.ReturnIsEnemy(FacEnum, other.GetComponentInParent <EnemyTemplateMaster>().Return_FactionEnum()))
                {
                    DealDamage(other, false);
                }
            }
        }
    }
Пример #4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         if (FL.ReturnIsEnemyCustomPlayer(ETM.Return_FactionEnum(), ETM.Return_customReputation()))
         {
             TargetsInMeleeRange.Add(other.transform);
         }
     }
     else if (other.tag == "BasicEnemy")
     {
         if (FL.ReturnIsEnemy(ETM.Return_FactionEnum(), other.gameObject.GetComponentInParent <EnemyTemplateMaster>().Return_FactionEnum()))
         {
             TargetsInMeleeRange.Add(other.transform);
         }
     }
 }
    protected bool clean_LoS(bool Forward_Required = false) //Has direct Line of Sight to the player
    {
        int layerMask = (LayerMask.GetMask("Projectile") | LayerMask.GetMask("Default") | LayerMask.GetMask("InteractiveThing") | LayerMask.GetMask("Ignore Raycast"));

        layerMask = ~layerMask; //ignore these

        Vector3    target_dir = ETM.Return_Current_Target().position - transform.position;
        RaycastHit hit;

        if (Forward_Required)
        {
            float target_angle  = Mathf.Atan2(target_dir.x, target_dir.z) * Mathf.Rad2Deg;
            float forward_angle = Mathf.Atan2(transform.forward.x, transform.forward.z) * Mathf.Rad2Deg;
            float diff_angle    = Mathf.Abs(Mathf.DeltaAngle(target_angle, forward_angle));

            if (diff_angle > 10)
            {
                return(false);
            }
        }

        Vector3 Modified_Start = new Vector3(transform.position.x, transform.position.y + RayCastheight, transform.position.z);

        Debug.DrawRay(Modified_Start, target_dir * 10f, Color.red);
        if (Physics.Raycast(Modified_Start, target_dir, out hit, MaxEnemyRange, layerMask))
        {
            if (hit.collider.tag == "Player")
            {
                if (FL.ReturnIsEnemyCustomPlayer(ETM.Return_FactionEnum(), ETM.Return_customReputation()))
                {
                    return(true);
                }
            }
            else if (hit.collider.tag == "BasicEnemy")
            {
                if (FL.ReturnIsEnemy(ETM.Return_FactionEnum(), hit.collider.gameObject.GetComponentInParent <EnemyTemplateMaster>().Return_FactionEnum()))
                {
                    return(true);
                }
            }
            else
            {
                //Debug.Log((hit.collider.name, hit.collider.tag, hit.collider.gameObject.layer));
            }
        }
        return(false);
    }
Пример #6
0
 private void OnTriggerEnter(Collider other)
 {
     if (!AIenabled)
     {
         if (other.tag == "Player")
         {
             if (facLogic.ReturnIsEnemyCustomPlayer(factionEnum, customReputation))
             {
                 Current_Target = other.transform;
                 EnableAI(true);
             }
         }
         else if (other.tag == "BasicEnemy")
         {
             if (facLogic.ReturnIsEnemy(factionEnum, other.GetComponentInParent <EnemyTemplateMaster>().Return_FactionEnum()))
             {
                 Current_Target = other.transform;
                 EnableAI(true);
             }
         }
     }
 }