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); } } }
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); }
private void FixedUpdate() { enemies_nearby = false; int potential_enemies_in_range = TriggerList.Count; //Includes recently dead enemies for (int i = potential_enemies_in_range - 1; i >= 0; i--) { Collider col = TriggerList[i]; if (!col || col.tag != "BasicEnemy") { TriggerList.Remove(col); } else { EnemyTemplateMaster ETM = col.GetComponentInParent <EnemyTemplateMaster>(); if (FL.ReturnIsEnemyCustomPlayer(ETM.Return_FactionEnum(), ETM.Return_customReputation())) { enemies_nearby = true; } } } }