private static TiledObjectGroup ReadObjectGroup(ContentReader reader, TiledMap tiledMap)
        {
            var groupName = reader.ReadString();
            var visible   = reader.ReadBoolean();
            var opacity   = reader.ReadSingle();
            var count     = reader.ReadInt32();
            var objects   = new TiledObject[count];

            for (var i = 0; i < count; i++)
            {
                var objectType = (TiledObjectType)reader.ReadInt32();
                var id         = reader.ReadInt32();
                var gid        = reader.ReadInt32();
                var x          = reader.ReadSingle();
                var y          = reader.ReadSingle();
                var width      = reader.ReadSingle();
                var height     = reader.ReadSingle();
                var rotation   = reader.ReadSingle();
                var name       = reader.ReadString();
                var type       = reader.ReadString();
                var isVisible  = reader.ReadBoolean();

                objects[i] = new TiledObject(objectType, id, gid >= 0 ? gid : (int?)null, x, y, width, height)
                {
                    IsVisible = isVisible,
                    Opacity   = opacity,
                    Rotation  = rotation,
                    Name      = name,
                    Type      = type
                };

                if (objectType == TiledObjectType.Polyline || objectType == TiledObjectType.Polygon)
                {
                    var pointsCount = reader.ReadInt32();

                    for (var j = 0; j < pointsCount; j++)
                    {
                        objects[i].Points.Add(reader.ReadVector2());
                    }
                }

                ReadCustomProperties(reader, objects[i].Properties);
            }

            return(tiledMap.CreateObjectGroup(groupName, objects, visible));
        }
 private void CreateShop(TiledObject shopObj, int x, int y)
 {
     var shopType = shopObj.Properties["Type"];
     if (shopType == null) return;
     var shopTexture = ImageManager.loadMisc("Panel" + shopType);
     var type = GameShopType.None;
     switch (shopType)
     {
         case "Ammo":
             type = GameShopType.Ammo;
             break;
         case "Hearts":
             type = GameShopType.Hearts;
             break;
         case "Lives":
             type = GameShopType.Lives;
             break;
     }
     var arrowsTexture = ImageManager.loadSystem("ShopUpButton");
     var shop = new GameShop(type, shopTexture, arrowsTexture, new Vector2(x, y));
     _shops.Add(shop);
 }
        public void CreateEnemy(TiledObject enemyObj, int x, int y)
        {
            var enemyName = "";
            if (enemyObj.Properties.ContainsKey("type"))
            {
                enemyName = enemyObj.Properties["type"];
            }
            else if (enemyObj.Properties.ContainsKey("Type"))
            {
                enemyName = enemyObj.Properties["Type"];
            }
            else
            {
                return;
            }
            var texture = ImageManager.loadCharacter(enemyName);
            var newEnemy = (Enemy)Activator.CreateInstance(Type.GetType("Super_Pete_The_Pirate.Characters." + enemyName), texture);
            newEnemy.Position = new Vector2(x, y - 32);
            if (enemyObj.Properties.ContainsKey("FlipHorizontally"))
                newEnemy.CharacterSprite.Effect = enemyObj.Properties["FlipHorizontally"] == "true" ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
            if (enemyName == "Parrot")
            {
                var width = enemyObj.Properties.ContainsKey("FlyWidth") ? int.Parse(enemyObj.Properties["FlyWidth"]) : 224;
                ((Parrot)newEnemy).SetFlyWidth(width);
                var rangeDec = newEnemy.CharacterSprite.Effect.HasFlag(SpriteEffects.FlipHorizontally) ? width : 0;
                ((Parrot)newEnemy).SetFlyRange((int)newEnemy.Position.X - rangeDec, (int)newEnemy.Position.Y);
            }

            if (enemyName == "Mole") ((Mole)newEnemy).SetHolePoint((int)newEnemy.Position.X, y);

            _enemies.Add(newEnemy);
        }