示例#1
0
        /// <summary>
        /// Instantiates an enemy and puts him in the level.
        /// </summary>
        private Tile LoadEnemyTile(int x, int y, string sprite)
        {
            Vector2       position = RectangleExtensions.GetBottomCenter(GetBounds(x, y));
            SpriteEffects effects  = SpriteEffects.None;

            switch (sprite)
            {
            case "koopa":
                enemies.Add(new Koopa(this, position, effects));
                return(new Tile(null, TileCollision.Passable, SpriteEffects.None, false));

            case "goomba":
                enemies.Add(new Goomba(this, position, effects));
                return(new Tile(null, TileCollision.Passable, SpriteEffects.None, false));

            case "red":
                enemies.Add(new Red(this, position, effects));
                return(new Tile(null, TileCollision.Passable, SpriteEffects.None, false));

            case "plant":
                enemies.Add(new PiranhaPlant(this, position, effects, random.Next(5000)));
                return(new Tile(null, TileCollision.Passable, SpriteEffects.None, false));

            case "fish":
                enemies.Add(new Fish(this, position, effects, random.Next(5000)));
                return(new Tile(null, TileCollision.Passable, SpriteEffects.None, false));

            case "fireball":
                enemies.Add(new LavaBall(this, position, effects, random.Next(5000)));
                return(new Tile(null, TileCollision.Passable, SpriteEffects.None, false));

            default:
                return(new Tile(null, TileCollision.Passable, SpriteEffects.None, false));
            }
        }
示例#2
0
        /// <summary>
        /// Instantiates a player, puts him in the level, and remembers where to put him when he is resurrected.
        /// </summary>
        private Tile LoadStartTile(int x, int y)
        {
            if (Player != null)
            {
                throw new NotSupportedException("A level may only have one starting point.");
            }

            start  = RectangleExtensions.GetBottomCenter(GetBounds(x, y));
            player = new Player(this, start);

            return(new Tile(null, TileCollision.Passable, SpriteEffects.None, false));
        }
示例#3
0
        private Tile LoadAnimationTile(int x, int y, string spriteSet)
        {
            Vector2         position  = RectangleExtensions.GetBottomCenter(GetBounds(x, y));
            Texture2D       t         = (Content.Load <Texture2D>("Sprites/Animations/" + spriteSet));
            Animation       animation = new Animation(t, .45f, true, t.Width / Tile.Width);
            AnimationPlayer sprite    = new AnimationPlayer();

            animations.Add(animation);
            locations.Add(position);
            sprites.Add(sprite);

            return(new Tile(null, TileCollision.Passable, SpriteEffects.None, false));
        }