示例#1
0
文件: Collider.cs 项目: kostya9/OP
 public Collider(MissleMover missleMover,
     WallStore store)
 {
     _missleMover = missleMover;
     _store = store;
     _wasBrokenIntoPieces = new List<Missle>();
     AddMissleMoverSubscriptions();
 }
示例#2
0
文件: SpellsGame.cs 项目: kostya9/OP
        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);
        }
示例#3
0
文件: MissleMover.cs 项目: kostya9/OP
        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;
            }
        }
示例#4
0
文件: MissleMover.cs 项目: kostya9/OP
 public void Move(WallStore store)
 {
     MoveMissles();
     CheckForCollision(store);
 }