Exemplo n.º 1
0
        public void Update(GameTime gameTime, OverworldSprite player)
        {
            if(state == "Solid")
            {
                Rectangle tileRect = new Rectangle((int)Position.X + 6, (int)Position.Y + 13,
                    sourceRect.Width - 12, sourceRect.Height - 12);
                Rectangle playerRect = new Rectangle((int)player.Image.Position.X,
                    (int)player.Image.Position.Y, player.Image.SourceRect.Width, player.Image.SourceRect.Height);
                //here we implement the collision
                if (playerRect.Intersects(tileRect))
                {
                    if (isShopkeeper)
                    {
                        //TO DO: IMPLEMENTATION
                        //trigger the event/open the trading screen
                    }

                    //if the solid tile and the player's rectancgles collide we tell where to put the player in the next frame
                    if (player.Velocity.X < 0)//moving left
                        player.Image.Position.X = tileRect.Right;
                    else if (player.Velocity.X > 0)
                        player.Image.Position.X = tileRect.Left - player.Image.SourceRect.Width;
                    else if (player.Velocity.Y < 0)
                        player.Image.Position.Y = tileRect.Bottom;
                    else
                        player.Image.Position.Y = tileRect.Top - player.Image.SourceRect.Height;

                    //Stop the player from moving.
                    player.Velocity = Vector2.Zero;
                }
            }
        }
 public SaveGameContent( OverworldSprite playerToSave)
 {
     //this.currentInstanceOfTheCharacter = currentInstanceOfTheCharacter;
     this.PlayerToSave = playerToSave;
     //this.playerSaver = new XmlManager<Player>();
     //this.minionSaver = new XmlManager<Minion>();
 }
 public OverworldSprite Load()
 {
     OverworldSprite playerToBeLoaded = new OverworldSprite();
     XmlManager<OverworldSprite> playerLoader = new XmlManager<OverworldSprite>();
     playerToBeLoaded = playerLoader.Load("Load/Gameplay/SavedGames/Player4.xml");
     //playerToBeLoaded.Image = playerToSave.Image;
     return playerToBeLoaded;
 }
Exemplo n.º 4
0
        public override void LoadContent()
        {
            base.LoadContent();

            //Load the player sprite;
            XmlManager<OverworldSprite> playerLoader = new XmlManager<OverworldSprite>();
            playerSprite = playerLoader.Load("Load/Gameplay/OverworldSprite.xml");
            playerSprite.LoadContent();

            //Load the map.
            XmlManager<Map> mapLoader = new XmlManager<Map>();
            map = mapLoader.Load("Load/Gameplay/Maps/Map1.xml");
            map.LoadContent();

            //Start the bgm.
            backgroundMusic = content.Load<Song>("Music/mainSong");
            BackgroundMusicPlayer.Play(backgroundMusic);
            nextBattle = (float) Constants.Random.Next(3, 5);
        }
Exemplo n.º 5
0
 public void Update(GameTime gameTime, OverworldSprite player)
 {
     foreach (Layer l in Layer)
         l.Update(gameTime, player);
 }
Exemplo n.º 6
0
        public void Update(GameTime gameTime, OverworldSprite player)
        {
            foreach (Tile tile in underlayTiles)
                tile.Update(gameTime, player);

            foreach (Tile tile in overlayTiles)
                tile.Update(gameTime, player);
        }