Пример #1
0
        public void AddTile(Tile t, bool animated)
        {
            DrawableTile drawable = null;

            switch (t.Type)
            {
            case TileType.Water3:
                drawable = new DrawableTile(t, Room.Skin, allowEdit)
                {
                    Alpha = showWater ? 1 : 0
                };
                break;

            case TileType.Jumprefresher:
                drawable = new DrawableJumpRefresher(t, Room.Skin, allowEdit);
                break;

            case TileType.Save:
                drawable = new SaveTile(t, Room.Skin, allowEdit);
                break;

            case TileType.BulletBlocker:
                drawable = new DrawableBulletBlocker(t, Room.Skin, showBulletBlocker, allowEdit);
                break;

            case TileType.Cherry:
                drawable = new DrawableCherry(t, Room.Skin, animatedCherry, allowEdit);
                break;

            case TileType.PlayerStart:
                PlayerSpawnPosition = new Vector2(t.PositionX, t.PositionY);

                if (showPlayerSpawn)
                {
                    drawable = new DrawableTile(t, Room.Skin, allowEdit);
                }

                break;

            default:
                drawable = new DrawableTile(t, Room.Skin, allowEdit);
                break;
            }

            if (drawable == null)
            {
                return;
            }

            content.Add(drawable);

            if (!animated)
            {
                return;
            }

            drawable.MainSprite.Scale = Vector2.Zero;
            drawable.MainSprite.ScaleTo(1, 200, Easing.Out);
        }
Пример #2
0
        public static bool IsGroup(DrawableTile tile, TileGroup group)
        {
            var type = tile?.Tile.Type ?? null;

            if (getGroup(type) == group)
            {
                return(true);
            }

            return(false);
        }
Пример #3
0
        public DrawableTile GetFirstTileAt(Vector2 pixelPosition)
        {
            DrawableTile tile = null;

            foreach (var child in content.Children)
            {
                var tilePosition = child.Position;
                var tileSize     = child.Size;

                if (pixelPosition.X >= tilePosition.X && pixelPosition.X < tilePosition.X + tileSize.X)
                {
                    if (pixelPosition.Y >= tilePosition.Y && pixelPosition.Y < tilePosition.Y + tileSize.Y)
                    {
                        tile = child;
                    }
                }
            }

            return(tile);
        }
Пример #4
0
        public DrawableTile GetSolidTileForHorizontalCheck(Vector2 pixelPosition)
        {
            foreach (var child in content.Children)
            {
                var tilePosition = child.Position;
                var tileSize     = child.Size;

                if (pixelPosition.X >= tilePosition.X && pixelPosition.X < tilePosition.X + tileSize.X)
                {
                    if (pixelPosition.Y > tilePosition.Y && pixelPosition.Y < tilePosition.Y + tileSize.Y)
                    {
                        if (DrawableTile.IsGroup(child, TileGroup.Solid))
                        {
                            return(child);
                        }
                    }
                }
            }

            return(null);
        }
Пример #5
0
        public DrawableTile GetTileOfGroupAt(Vector2 pixelPosition, TileGroup group)
        {
            foreach (var child in content.Children)
            {
                var tilePosition = child.Position;
                var tileSize     = child.Size;

                if (pixelPosition.X >= tilePosition.X && pixelPosition.X < tilePosition.X + tileSize.X)
                {
                    if (pixelPosition.Y >= tilePosition.Y && pixelPosition.Y < tilePosition.Y + tileSize.Y)
                    {
                        if (DrawableTile.IsGroup(child, group))
                        {
                            return(child);
                        }
                    }
                }
            }

            return(null);
        }