예제 #1
0
 public NodeEntity(int depth, Entity entity, bool hasMoved = true, bool isKillLikely = false, bool isExplosion = false, bool isBulletKill = false)
 {
     Depth = depth;
     Entity = entity;
     HasMoved = hasMoved;
     IsKillLikely = isKillLikely;
     IsExplosion = isExplosion;
     IsBulletKill = isBulletKill;
 }
예제 #2
0
 public void RemoveEntity(Entity entity)
 {
     EntitiesKilled.Add(entity);
 }
예제 #3
0
        public void AddEntity(Entity entity)
        {
            if (EntitiesUnclassified.ContainsKey(entity.Id)) return;

            EntitiesAdded.Add(entity);
        }
예제 #4
0
        private void RemoveEntityFromDictionary(Dictionary<int, Dictionary<EntityType, List<Entity>>> dictionary,
            Entity entity)
        {
            if (!dictionary.ContainsKey(entity.PlayerNumber))
            {
                return;
            }

            if (!dictionary[entity.PlayerNumber].ContainsKey(entity.Type))
            {
                return;
            }

            dictionary[entity.PlayerNumber][entity.Type].Remove(entity);
        }
예제 #5
0
        private void AddEntityToDictionary(Entity entity)
        {
            if (!Entities.ContainsKey(entity.PlayerNumber))
            {
                Entities.Add(entity.PlayerNumber, new Dictionary<EntityType, List<Entity>>());
            }

            if (!Entities[entity.PlayerNumber].ContainsKey(entity.Type))
            {
                Entities[entity.PlayerNumber].Add(entity.Type, new List<Entity>());
            }

            Entities[entity.PlayerNumber][entity.Type].Add(entity);
        }
예제 #6
0
파일: Map.cs 프로젝트: rm2k/space-invaders
        public void AddEntity(Entity entity)
        {
            TraverseMap(MapAction.Check, entity, entity.X, entity.Y);
            TraverseMap(MapAction.Add, entity, entity.X, entity.Y);

            UpdateManager.AddEntity(entity);
        }
예제 #7
0
파일: Map.cs 프로젝트: rm2k/space-invaders
 private void TraverseMap(MapAction action, Entity entity, int targetX, int targetY)
 {
     CheckBounds(targetX, targetY);
     CheckBounds(targetX + entity.Width - 1, targetY + entity.Height - 1);
     List<Entity> collisions = new List<Entity>();
     for (var x = targetX; x < targetX + entity.Width; x++)
     {
         for (var y = targetY; y < targetY + entity.Height; y++)
         {
             switch (action)
             {
                 case MapAction.Check:
                     var mapEntity = GetEntity(x, y);
                     if (mapEntity != null)
                     {
                         //store all collisions and then decide what to do with them
                         collisions.Add(mapEntity);
                     }
                     break;
                 case MapAction.Add:
                     Rows[y][x] = entity;
                     break;
                 case MapAction.Remove:
                     if (Rows[y][x] == entity)
                     {
                         Rows[y][x] = null;
                     }
                     break;
             }
         }
     }
     if (collisions.Count > 0)
     {
         throw new CollisionException { Entities = collisions, Entity = collisions[0] };
     }
 }
예제 #8
0
파일: Map.cs 프로젝트: rm2k/space-invaders
        public void RemoveEntity(Entity entity)
        {
            UpdateManager.RemoveEntity(entity);

            entity.Alive = false;
            TraverseMap(MapAction.Remove, entity, entity.X, entity.Y);
        }
예제 #9
0
파일: Map.cs 프로젝트: rm2k/space-invaders
 public void MoveEntity(Entity entity, int x, int y)
 {
     TraverseMap(MapAction.Remove, entity, entity.X, entity.Y);
     try
     {
         TraverseMap(MapAction.Check, entity, x, y);
         TraverseMap(MapAction.Add, entity, x, y);
         entity.X = x;
         entity.Y = y;
     }
     catch (MoveNotOnMapException)
     {
         AddEntity(entity);
         throw;
     }
     catch (CollisionException)
     {
         //AddEntity(entity);
         throw;
     }
 }
예제 #10
0
파일: Map.cs 프로젝트: rm2k/space-invaders
 public void ClearEntity(Entity entity)
 {
     TraverseMap(MapAction.Remove, entity, entity.X, entity.Y);
 }