public override bool shoot(SingleUnityLayer BulletLayer) { if (base.shoot(BulletLayer)) { var hits = Physics2D.OverlapCircleAll(transform.position, reach); var info = new System.Object[] { bullet_damage, new Vector2(), null }; foreach (var hit in hits) { if (hit.gameObject.CompareTag(transform.parent.gameObject.tag)) { continue; } var dir = (Vector2)(Quaternion.AngleAxis(transform.rotation.eulerAngles.z, Vector3.forward) * Vector2.right); var normal = (hit.transform.position - transform.position).normalized; var angle = Vector3.Angle(dir, normal); if (angle < swing_angle) { hit.SendMessage("apply_directed_damage", info, SendMessageOptions.DontRequireReceiver); } } f = 0.0f; } //StartCoroutine("rotate_animation"); return(ammo != 0); }
public void Init(float rate, bool enable, int layer, GameObject listener = null) { raycastRate = rate; lastRate = rate; this.enableRaycast = enable; lastEnable = enable; this.layer = new SingleUnityLayer(); this.listener = listener; this.layer.Set(layer); }
public override bool shoot(SingleUnityLayer BulletLayer) { if (base.shoot(BulletLayer)) { GameObject go = GameObject.Instantiate <GameObject> (bullet.gameObject); go.layer = BulletLayer.LayerIndex; go.transform.position = transform.position; var bul = go.GetComponent <Bullet> (); bul.damage = bullet_damage; bul.speed = bullet_speed; bul.dir = Quaternion.AngleAxis(transform.rotation.eulerAngles.z, Vector3.forward) * Vector2.right; } return(ammo > 0); }
public virtual bool shoot(SingleUnityLayer BulletLayer) { if (last_shoot + bullet_firerate < Time.time && (ammo > 0 || ammo_max <= 0)) { last_shoot = Time.time; ammo--; if (ammo == 0) { reload_time = Time.time + reload_speed; } return(true); } reload(); return(false); }
public override bool shoot(SingleUnityLayer BulletLayer) { if (base.shoot(BulletLayer)) { var dir = (Vector2)(Quaternion.AngleAxis(transform.rotation.eulerAngles.z, Vector3.forward) * Vector2.right); var hits = Physics2D.RaycastAll(transform.position, dir, float.MaxValue, mask); var line_render = GetComponent <LineRenderer> (); //line_render.SetVertexCount (2); line_render.SetPosition(0, transform.position); line_render.SetPosition(1, transform.position + (Vector3)dir * 100000); RaycastHit2D min_dist_hit = new RaycastHit2D(); float min_dist = float.MaxValue; var info = new System.Object[] { bullet_damage, dir, null }; foreach (var hit in hits) { if (hit.collider.gameObject.CompareTag(transform.parent.tag)) { continue; } if (hit.collider.gameObject.CompareTag("Envoy")) { if (hit.distance < min_dist) { min_dist_hit = hit; min_dist = hit.distance; } } hit.collider.gameObject.SendMessage("apply_directed_damage", info, SendMessageOptions.DontRequireReceiver); hit.collider.SendMessageUpwards("danger", (Vector3)hit.point, SendMessageOptions.DontRequireReceiver); } if (min_dist_hit) { line_render.SetPosition(1, min_dist_hit.point); } StartCoroutine("fade"); } return(ammo > 0); }
public override bool shoot(SingleUnityLayer BulletLayer) { if (base.shoot(BulletLayer)) { for (int i = 0; i < pallets; ++i) { GameObject go = GameObject.Instantiate <GameObject> (bullet.gameObject); go.layer = BulletLayer.LayerIndex; go.transform.position = transform.position; var bul = go.GetComponent <Bullet> (); bul.damage = bullet_damage; bul.speed = bullet_speed; var variation = Random.insideUnitCircle * spreat_size; bul.dir = (Vector2)(Quaternion.AngleAxis(transform.rotation.eulerAngles.z, Vector3.forward) * Vector2.right) + variation; } } return(ammo > 0); }