public virtual void Draw(SpriteBatch spriteBatch)
        {
            var position = ManagerCamera.WorldToScreenPosition(Position);

            if (_texture != null && ManagerCamera.InScreenCheck(Position))
            {
                spriteBatch.Draw(_texture, new Rectangle((int)position.X, (int)position.Y, Width, Height),
                                 new Rectangle(TileFrames[_animationIndex].TextureXPos * (Width + 1) + 1,
                                               TileFrames[_animationIndex].TextureYPos * (Height + 1) + 1,
                                               Width, Height), Color.White);
            }
        }
示例#2
0
        public void Draw(SpriteBatch spriteBatch)
        {
            //spriteBatch.Draw(_texture, new Rectangle((int) _managerCamera.WorldToScreenPosition(Position).X,(int) _managerCamera.WorldToScreenPosition(Position).Y,
            //    16,16),Color.White);

            foreach (var tilePoint in _mainForm.TilePoints)
            {
                var realX    = XTile + (_mainForm.TilePoints[0].X - tilePoint.X) * -1;
                var realY    = YTile + (_mainForm.TilePoints[0].Y - tilePoint.Y) * -1;
                var position = new Vector2(realX * 16, realY * 16);
                spriteBatch.Draw(_texture, new Rectangle((int)_managerCamera.WorldToScreenPosition(position).X, (int)_managerCamera.WorldToScreenPosition(position).Y,
                                                         16, 16), Color.White);
            }
        }
        public void Draw(SpriteBatch spriteBatch)
        {
            if (_texture == null)
            {
                return;
            }

            var position = ManagerCamera.WorldToScreenPosition(Position);

            if (ManagerCamera.InScreenCheck(Position))
            {
                spriteBatch.Draw(_texture, new Rectangle((int)position.X, (int)position.Y, Width, Height),
                                 new Rectangle(0, 0, Width, Height), Color.White);
            }
        }
示例#4
0
        private PlayerAndConnection CreatePlayer(NetIncomingMessage inc, List <PlayerAndConnection> players, ManagerCamera managerCamera)
        {
            var random = new Random();
            var player = new Player
            {
                Username = inc.ReadString(),
                Position = new Position {
                    XPosition = random.Next(0, 750), YPosition = random.Next(0, 420)
                }
            };
            var playerVectorPosition = new Vector2(player.Position.XPosition, player.Position.YPosition);
            var screenPosition       = managerCamera.WorldToScreenPosition(playerVectorPosition);

            player.Position.ScreenXPosition = (int)screenPosition.X;
            player.Position.ScreenYPosition = (int)screenPosition.Y;
            player.Position.Visible         = managerCamera.InScreenCheck(playerVectorPosition);
            var playerAndConnection = new PlayerAndConnection(player, inc.SenderConnection);

            players.Add(playerAndConnection);
            return(playerAndConnection);
        }
示例#5
0
 public bool GetPosition(Vector2 position, out Vector2 newPosition)
 {
     newPosition = _managerCamera.WorldToScreenPosition(position);
     return(_managerCamera.InScreenCheck(position));
 }