예제 #1
0
        public void RemoveEntities()
        {
            foreach (Entity entity in EntitiesToRemove)
            {
                Vector2 gridPos = entity.GetPositionOnGrid();
                EntityGrid[(int)gridPos.Y, (int)gridPos.X] = null;

                Entities.Remove(entity.Guid);
                if (BackgroundEntities.ContainsKey(entity.Guid))
                {
                    BackgroundEntities.Remove(entity.Guid);
                }

                if (ForegroundEntities.ContainsKey(entity.Guid))
                {
                    ForegroundEntities.Remove(entity.Guid);
                }
            }

            EntitiesToRemove.Clear();
            MovedPawns.Clear();
        }
예제 #2
0
        public void AddEntity(Entity entity)
        {
            entity.Map = this;
            Entities.Add(entity.Guid, entity);
            if (entity.Type == EntityType.Car || entity.Type == EntityType.Pickup || entity.Type == EntityType.Ingredient || entity.Type == EntityType.Obstacle)
            {
                ForegroundEntities.Add(entity.Guid, entity);
            }
            else
            {
                BackgroundEntities.Add(entity.Guid, entity);
            }

            Vector2 gridPos    = entity.GetPositionOnGrid();
            Entity  tempEntity = EntityGrid[(int)gridPos.Y, (int)gridPos.X];

            if (tempEntity != null && (tempEntity.IsBlocking || tempEntity is Pickup))
            {
                Debug.WriteLine(" *** MAP Entity Collision! - Entity Already exists at Column:{1},  Row:{0} {2}", (int)gridPos.Y, (int)gridPos.X, tempEntity.Type.ToString());
            }
            EntityGrid[(int)gridPos.Y, (int)gridPos.X] = entity;

            entity.OnAddedToMap();
        }