Gruppe22.Client.Mainmap._drawWalls C# (CSharp) Method

_drawWalls() private method

Display all walls on the current map
private _drawWalls ( GameTime gametime ) : void
gametime Microsoft.Xna.Framework.GameTime
return void
        private void _drawWalls(GameTime gametime)
        {
            Backend.Coords currentPos = _map.actors[_playerID].tile.coords;

            //            System.Diagnostics.Debug.WriteLine((Math.Max(currentPos.y - _renderScope, 0)) + " " + (Math.Min(currentPos.y + _renderScope, _map.height)));
            //          System.Diagnostics.Debug.WriteLine((Math.Max(currentPos.x - _renderScope, 0)) + " " + (Math.Min(currentPos.x + _renderScope, _map.height)));

            for (int y = (Math.Max(currentPos.y - Math.Max(_map.actors[_playerID].viewRange, _map.light), 0)); y < (Math.Min(currentPos.y + Math.Max(_map.actors[_playerID].viewRange, _map.light) + 1, _map.height)); ++y)
            {
                for (int x = (Math.Min(currentPos.x + Math.Max(_map.actors[_playerID].viewRange, _map.light) + 1, _map.width)); x >= (Math.Max(currentPos.x - Math.Max(_map.actors[_playerID].viewRange, _map.light), 0)); --x)
                {
                    _drawWall(GetWallStyle(x, y), _tileRect(new Vector2(x + 1, y - 1), true), false, ((y == (int)_highlightedTile.y) && (x == (int)_highlightedTile.x)), _map[x, y].wallType);
                    if (((x != 0) && (y != 0) && (x != _map.width - 1) && (y != _map.height - 1)) && (_map[x, y].hasTeleport))
                        if (_map[x, y].teleport.down)
                        {
                            _spriteBatch.Draw(_environment[0][12].animationTexture, new Rectangle(_map2screen(x, y).x, _map2screen(x, y).y - 92, _environment[0][12].animationRect.Width, _environment[0][12].animationRect.Height), _environment[0][12].animationRect, ((y == (int)_highlightedTile.y) && (x == (int)_highlightedTile.x)) ? Color.Red : Color.White);
                        };

                    if ((x != _map.width - 2) && (y != _map.height - 2) && (_map[x + 1, y + 1].hasTeleport))
                        if (!_map[x + 1, y + 1].teleport.down)
                        {
                            _spriteBatch.Draw(_environment[0][14].animationTexture, new Rectangle(_map2screen(x + 1, y + 1).x - 16, _map2screen(x + 1, y + 1).y - 32, _environment[0][14].animationRect.Width, _environment[0][14].animationRect.Height), _environment[0][14].animationRect, ((y == (int)_highlightedTile.y) && (x == (int)_highlightedTile.x)) ? Color.Red : Color.White);
                        }

                    // show special objects
                    Backend.ReservedTile temp = _map[x, y].reserved;
                    if (temp != null)
                    {
                        if (temp.envIndex == -1)
                        {
                            for (int i = 0; i < _environment.Count; ++i)
                            {
                                if (_environment[i].filename == temp.filename) { temp.envIndex = i; break; }
                            }
                            if (temp.envIndex == -1)
                            {
                                TileSet tmp = new TileSet(_content, 96, 96);
                                tmp.Load(temp.filename);
                                _environment.Add(tmp);
                                temp.envIndex = _environment.Count - 1;
                            }
                        }
                        _spriteBatch.Draw(_environment[temp.envIndex][temp.index].animationTexture, new Rectangle(_map2screen(x, y).x - 16, _map2screen(x, y).y - 32, _environment[temp.envIndex][temp.index].animationRect.Width, _environment[temp.envIndex][temp.index].animationRect.Height), _environment[temp.envIndex][temp.index].animationRect, ((y == (int)_highlightedTile.y) && (x == (int)_highlightedTile.x)) ? Color.Red : Color.White);
                        _environment[temp.envIndex][temp.index].NextAnimation();

                    }
                    foreach (ActorView actor in _actors)
                    {
                        if (!actor.invisible)
                        {
                            if ((_map.actors[actor.id].actorType != Backend.ActorType.Player) || (_map.actors[actor.id].online))
                            {
                                Backend.Coords apos = _screen2map((int)actor.position.x, (int)actor.position.y);
                                if (((int)apos.x == x) && ((int)apos.y == y))
                                {
                                    Color tempColor = new Color(((_map.actors[actor.id].tile.coords.y == (int)_highlightedTile.y) && (_map.actors[actor.id].tile.coords.x == (int)_highlightedTile.x) && !(_map.actors[actor.id] is Backend.Player)) ? Color.Red : Color.White, 1.0f);
                                    if ((_map.actors[actor.id].actorType == Backend.ActorType.Player) && (_map.actors[actor.id].id != _playerID))
                                    {
                                        tempColor.A = 80;
                                        tempColor.B = 250;
                                        tempColor.R = 90;
                                        tempColor.G = 90;
                                    }

                                    if (actor.animationTexture != null)
                                        _spriteBatch.Draw(actor.animationTexture, new Vector2((actor.position.x + actor.offsetX), (actor.position.y + actor.offsetY - 32)), actor.animationRect, tempColor);
                                    if (actor.effect != null)
                                    {
                                        actor.effect.position = new Backend.Coords((actor.position.x + actor.offsetX), (actor.position.y + actor.offsetY - 32));
                                        actor.effect.Draw(_spriteBatch, gametime);
                                    }
                                    if (!_map.actors[actor.id].isDead)
                                    {
                                        _spriteBatch.DrawString(_font, _map.actors[actor.id].name, new Vector2((actor.position.x + actor.offsetX + 25), (actor.position.y + actor.offsetY - 25)), Color.Black, 0f, new Vector2(0, 0), 0.5f, SpriteEffects.None, 0f);
                                        _spriteBatch.DrawString(_font, _map.actors[actor.id].name, new Vector2((actor.position.x + actor.offsetX + 24), (actor.position.y + actor.offsetY - 26)), ((_map.actors[actor.id].actorType == Backend.ActorType.Enemy) ? Color.Red : Color.LightGreen), 0f, new Vector2(0, 0), 0.5f, SpriteEffects.None, 0f);

                                        _spriteBatch.Draw(_background, new Rectangle((actor.position.x + actor.offsetX + 25), (actor.position.y + actor.offsetY - 10), actor.animationRect.Width, 5), new Rectangle(39, 6, 1, 1), Color.Black);
                                        _spriteBatch.Draw(_background, new Rectangle((actor.position.x + actor.offsetX + 26), (actor.position.y + actor.offsetY - 9), (_map.actors[actor.id].health * (actor.animationRect.Width - 2)) / _map.actors[actor.id].maxHealth, 3), new Rectangle(39, 6, 1, 1), ((_map.actors[actor.id].actorType == Backend.ActorType.Enemy) ? Color.Red : Color.LightGreen));

                                    }
                                }
                            }
                        }
                    }

                    if (_map[x, y].hasTreasure)
                    {
                        foreach (Backend.Item item in (_map[x, y].items))
                        {
                            if (item.itemType == Backend.ItemType.Potion)
                            {
                                System.Diagnostics.Debug.WriteLine(item.icon.rect.Width);
                            }
                            _spriteBatch.Draw(TextureFromData.Convert(item.icon, _content), new Rectangle(_map2screen(x, y).x + item.icon.offset.x + 32, _map2screen(x, y).y + 16 + item.icon.offset.y,
                                item.icon.rect.Width - item.icon.crop.x, item.icon.rect.Height - item.icon.crop.y), item.icon.rect, ((y == (int)_highlightedTile.y) && (x == (int)_highlightedTile.x)) ? Color.Red : Color.White);
                        }

                    }
                }
            }
        }