|
|
@@ -5,6 +5,8 @@ using UnityEngine;
|
|
|
public class CharacterColliders : MonoBehaviour
|
|
|
{
|
|
|
public Character owner;
|
|
|
+ public GameObject smoke;
|
|
|
+ public float hitRate = 1;
|
|
|
|
|
|
private void Awake()
|
|
|
{
|
|
|
@@ -27,6 +29,34 @@ public class CharacterColliders : MonoBehaviour
|
|
|
|
|
|
public void Attack2ShootEvent(int shootId)
|
|
|
{
|
|
|
+ if (smoke != null && smoke.activeSelf)
|
|
|
+ {
|
|
|
+ Vector3 pos1 = smoke.transform.position;
|
|
|
+ Vector3 pos2 = transform.position;
|
|
|
+ CapsuleCollider collider = smoke.GetComponent<CapsuleCollider>();
|
|
|
+ if (Vector3.Distance(new Vector3(pos1.x,pos1.y,0),new Vector3(pos2.x,pos2.y,0))
|
|
|
+ <collider.radius)
|
|
|
+ {
|
|
|
+ if (Random.Range(0f, 1f) < hitRate)
|
|
|
+ {
|
|
|
+ if (owner == null)
|
|
|
+ {
|
|
|
+ owner = GetComponentInParent<Character>();
|
|
|
+ }
|
|
|
+ owner.AttackShootEvent(2, shootId);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GameObject miss = Instantiate(smoke.GetComponent<SmokeDestroy>().MissUI);
|
|
|
+ miss.transform.position = transform.position + Vector3.up * 0.5f;
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if (owner == null)
|
|
|
{
|
|
|
owner = GetComponentInParent<Character>();
|