Ejemplo n.º 1
0
 protected override void OnResumeDisplay()
 {
     foreach (Layer layer in Layers)
     {
         if (layer.IsTileLayer)
         {
             for (int i = 0; i < layer.Data.Length; i++)
             {
                 TileSprite t = layer[i];
                 if (t.IsCollidable)
                 {
                     Hitbox.AddCollidable(t);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public TileSprite(int ID, TileSet parent, Layer parentLayer, int data_index, TiledWorld world)
        {
            this.World       = world;
            this.ID          = ID;
            this.TileSet     = parent;
            this.ParentLayer = parentLayer;

            Width  = TileSet.TileWidth;
            Height = TileSet.TileHeight;

            X = data_index % parentLayer.Width;
            Y = data_index / parentLayer.Width;

            X *= TileSet.TileWidth;
            Y *= TileSet.TileHeight;

            Layer = 1f / ParentLayer.LayerNumber;

            IsStatic = !(parent.TileProperties.ContainsKey(ID) && parent.TileProperties[ID].ContainsKey("static") && parent.TileProperties[ID]["static"].ToLower() == "true");

            _setTexCoords();

            Texture = TileSet.TileTexture;

            if (IsCollidable)
            {
                Hitbox = new Hitbox("Space", new List <Vector2>
                {
                    new Vector2(0, 0),
                    new Vector2(Width, 0),
                    new Vector2(Width, Height),
                    new Vector2(0, Height)
                });
                Hitbox.AddCollidable(this);
            }
        }