public override void CheckAndApplyCollision(PhysicalBody unit, TimeSpan time) { if (!_firing || !unit.Collides) return; //don't check collisions if not firing float fireAngle = XnaHelper.RadiansFromVector(_fireDirection); if (XnaHelper.RectangleIntersectsArc(unit.HitRect, _owner.Center, _range, fireAngle, _hitArc)) { _tempVector = unit.Center - _owner.Center; _tempVector.Normalize(); unit.ApplyImpact(_force * _tempVector, 1); unit.ApplyDamage(_damage); } }
public void CheckAndApplyCollision(PhysicalBody u, TimeSpan time) { if (!u.Collides) return; switch (_state) { case State.Dormant: break; case State.Moving: if (u.HitRect.Intersects(_hitRect)) { if (_penetration != -1) { _penetration -= 1; if (_penetration <= 0) _state = State.JustHit; } u.ApplyImpact(_velocity, _mass); } _proximityEffect.TryApply(_position, u, time); break; case State.JustHit: break; case State.ApplyContactEffect: _contactEffect.TryApply(_position, u, time); break; case State.ReachedDestination: _destinationEffect.TryApply(_position, u, time); break; default: break; } }
public void CheckAndApplyCollision(PhysicalBody unit, GameTime gameTime) { switch (_state) { case State.Dormant: break; case State.Appearing: case State.Scanning: unit.ApplyGravity(_gravity, gameTime); break; case State.Charging: unit.ApplyGravity(_gravity, gameTime); if (willCollide(unit.Top, unit.Bottom, unit.Left, unit.Right, gameTime.ElapsedGameTime)) { unit.ApplyImpact(_velocity, IMPACT_IMPULSE); unit.ApplyDamage(IMPACT_DAMAGE); break; } break; } }