public Collider(MissleMover missleMover, WallStore store) { _missleMover = missleMover; _store = store; _wasBrokenIntoPieces = new List<Missle>(); AddMissleMoverSubscriptions(); }
public SpellsGame(ValidatePosition validater) { SpellsContainer = new SpellsContainer(); _missleMover = new MissleMover(validater); WallStore = new WallStore(); _collider = new Collider(_missleMover, WallStore); SpellsContainer.SpellCasted += (s, e) => _missleMover.AddMissle(e.Missle); }
private void CheckForCollision(WallStore store) { var map = new Dictionary<Vector2D, Missle>(); foreach (var missle in _missles.ToList()) { if (RemoveIfDestroyed(missle)) continue; var position = missle.Position; if (store.ExistsWallAt(position)) MisslesCollided?.Invoke(missle, store.GetWallAt(position), new EventArgs()); if (RemoveIfDestroyed(missle)) continue; if (map.ContainsKey(position)) { var nextMissle = map[position]; if (!nextMissle.IsDestroyed) MisslesCollided?.Invoke(missle, nextMissle, new EventArgs()); } else map[position] = missle; } }
public void Move(WallStore store) { MoveMissles(); CheckForCollision(store); }