public void LoadContent(Microsoft.Xna.Framework.Content.ContentManager content)
        {
            _map = content.Load <TiledMap>("maps/map2");

            var trees = _map.GetObjectGroup("Trees").Objects;

            Collisions = trees.GetRectangles().ToArray();
        }
Exemple #2
0
        public TiledObjectCollisionSystem(IPossibleMovements possibleMovements, TiledMap map, Point tileSize, string objectLayer) : base(possibleMovements)
        {
            var teleporters = map.GetObjectGroup(objectLayer);

            _spatialHash = new SpatialHashCollisionSystem <TiledObject>(possibleMovements);
            foreach (var teleporter in teleporters.Objects)
            {
                var point = teleporter.Position.ToPoint() / tileSize;
                _spatialHash.AddNode(point, teleporter);
            }
        }
        public void LoadEntities()
        {
            var entityObjects = Map.GetObjectGroup("Entity-Layer");

            if (entityObjects != null)
            {
                foreach (var entityObject in entityObjects.Objects)
                {
                    var position = entityObject.Position / _tileSize;
                    var entity   = _entityManager.Import(entityObject.Name);
                    entity.Position = position;
                    AddEntity(entity);
                }
            }
        }
Exemple #4
0
 public TiledObjectGroup GetObjectGroup(string name)
 {
     return(_tiledMap.GetObjectGroup(name));
 }