summaryrefslogtreecommitdiff
path: root/marching/Assets/Scripts/Projectiles/BladeScript.cs
diff options
context:
space:
mode:
Diffstat (limited to 'marching/Assets/Scripts/Projectiles/BladeScript.cs')
-rw-r--r--marching/Assets/Scripts/Projectiles/BladeScript.cs50
1 files changed, 25 insertions, 25 deletions
diff --git a/marching/Assets/Scripts/Projectiles/BladeScript.cs b/marching/Assets/Scripts/Projectiles/BladeScript.cs
index 90cee79..929f574 100644
--- a/marching/Assets/Scripts/Projectiles/BladeScript.cs
+++ b/marching/Assets/Scripts/Projectiles/BladeScript.cs
@@ -11,6 +11,8 @@ public class BladeScript : ProjectileBase
private static List<IQuadTreeObject> collisions = new List<IQuadTreeObject>();
+ private FastCircleCollider collider;
+
private SpriteRenderer sr
{
get
@@ -21,7 +23,9 @@ public class BladeScript : ProjectileBase
public void Start()
{
+ collider = GetComponent<FastCircleCollider>();
Invoke("DestroySelf", life);
+ Attack();
}
void DestroySelf()
@@ -41,38 +45,34 @@ public class BladeScript : ProjectileBase
sr.flipX = flip;
}
- public void FixedUpdate()
+ public void Attack()
{
- Vector3 pos = transform.position;
- if(PhysicsManager.Instance.RetriveColliders(ref collisions, new Vector4(pos.x, pos.y, 4, 4)))
+ Vector3 pos = transform.position;
+ if (PhysicsManager.Instance.RetriveHurtboxes(ref collisions, new Vector4(pos.x, pos.y, 2, 2)))
{
- for(int i =0; i < collisions.Count; i++)
+ for (int i = 0; i < collisions.Count; i++)
{
-
+ var col = collisions[i] as MonoBehaviour;
+ if (col != null)
+ {
+ if (col is FastBoxCollider)
+ {
+ var box = col as FastBoxCollider;
+ if (box != null)
+ {
+ if (PhysicsManager.BoxVsCircle(box.box, collider.circle))
+ {
+ GameObject.Destroy(box.gameObject);
+ }
+ }
+ }
+ }
}
}
}
- private void OnTriggerEnter2D(Collider2D other)
+ public void FixedUpdate()
{
- Debug.Log(other.gameObject.name);
- LayerMask layerMask = LayerMask.GetMask("Hurtbox");
- if ((layerMask & (1 << other.transform.gameObject.layer)) != 0)
- {
- //Debug.Log(other.GetType().Name);
- Rigidbody2D rig = other.transform.parent.GetComponent<Rigidbody2D>();
- if(rig != null)
- {
- Debug.Log("force");
- UnitBase hero = UnitManager.hero;
- Vector2 pos = transform.position;
- Vector2 heroPos = hero.transform.position;
- Vector2 dir = (heroPos - pos).normalized;
-
- rig.AddForce(-dir * 100);
-
- rig.GetComponent<SpiritScript>().Die();
- }
- }
}
+
}