Exemplo n.º 1
0
 /// <summary>
 /// Constructor for Exit class
 /// </summary>
 /// <param name="from">Coordinates of teleporter in entrance room</param>
 /// <param name="fromRoom">Filename of entrance room</param>
 /// <param name="to">Coordinates of teleporter in exit room</param>
 /// <param name="toRoom">Filename of exit room</param>
 public Exit(Coords from, string fromRoom, Backend.Coords to = null, string toRoom = "")
 {
     _from = from;
     _fromRoom = fromRoom;
     _toRoom = toRoom;
     _to = to;
 }
Exemplo n.º 2
0
 /// <summary>
 /// The constructor for the TeleportTile.
 /// Setting default values.
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="nextXml"></param>
 /// <param name="pos"></param>
 /// <param name="isTeleport"></param>
 /// <param name="isHidden"></param>
 /// <param name="isEnabled"></param>
 /// <param name="isUp"></param>
 public TeleportTile(object parent, string nextXml, Backend.Coords pos, bool isTeleport = false, bool isHidden = false, bool isEnabled = true, bool isUp = false)
     : base(parent)
 {
     _nextRoom = nextXml;
     _nextPlayerPos = pos;
     _teleport = isTeleport;
     _hidden = isHidden;
     _enabled = isEnabled;
     _down = !isUp;
 }
Exemplo n.º 3
0
 public Projectile(uint id, Backend.IHandleEvent parent, Backend.Coords current, Backend.Direction dir, ProjectileTile tile)
 {
     _dir = dir;
     _id = id;
     _tile = tile;
     _current = Mainmap._map2screen(current);
     _target = Mainmap._map2screen(current);
     //     System.Diagnostics.Debug.WriteLine("Start at" + _current);
     _parent = parent;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Dieser Konstruktor fürgt dem overlay ein WallTile hinzu, falls die Stelle als unpassierbar markiert ist 
 /// </summary>
 /// <param name="parent">Elternobjekt.</param>
 /// <param name="coords">Koordinaten.</param>
 /// <param name="canEnter">Passierbarkeit.</param>
 public FloorTile(object parent, Backend.Coords coords = null, bool canEnter = true)
     : this(parent)
 {
     if (coords != null)
     {
         _coords = coords;
     }
     if (!canEnter)
     {
         Add(new WallTile(this));
     }
 }
Exemplo n.º 5
0
 public TriggerTile(object parent, Backend.Coords affected = null, int countdown = -1, string explanationEnabled = "", string explanationDisabled = "", bool enabled = true, int repeat = -1, bool alwaysShowEnabled = true, bool alwaysShowDisabled = false, string tileImage = "", bool reactToEnemies = false, bool reactToObjects = false, int reactToItem = -1)
     : base(parent)
 {
     _countdown = countdown;
     if (affected != null) _affectedTile = affected; else _affectedTile = new Backend.Coords(-1, -1);
     _explanationDisabled = explanationDisabled;
     _explanationEnabled = explanationEnabled;
     _enabled = enabled;
     _repeat = -1;
     _alwaysShowDisabled = alwaysShowDisabled;
     _alwaysShowEnabled = alwaysShowEnabled;
     _tileimage = tileimage;
     _reactToEnemies = reactToEnemies;
     _reactToObjects = reactToObjects;
     _reactToItem = reactToItem;
 }
Exemplo n.º 6
0
 public MapEffect(TileObject animation, Backend.Coords position, int scale = 3)
 {
     _position = position;
     _animation = animation;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Load a map from a file
        /// </summary>
        /// <param name="filename">The filename to read from</param>
        /// <param name="player">The starting position on the loaded map</param>
        public void ReadXML(XmlReader xmlr, Backend.Coords targetCoords = null, bool resetPlayer = false)
        {
            List<Player> players = new List<Player>();

            // Move all players to the new map
            if (_actors.Count > 0)
            {
                for (int i = 0; i < _actors.Count; ++i)
                {
                    if (_actors[i].tile != null)
                        _actors[i].tile.enabled = false;
                    if (_actors[i] is Player)
                    {
                        players.Add(_actors[i] as Player);
                        players[players.Count - 1].tile = null;
                        break;
                    }
                }
            }
            ClearActors();

            _tiles.Clear();
            _updateTiles.Clear();
            xmlr.MoveToContent();//xml
            _width = int.Parse(xmlr.GetAttribute("width"));
            _height = int.Parse(xmlr.GetAttribute("height"));
            if (xmlr.GetAttribute("name") != null) _name = xmlr.GetAttribute("name");
            if (xmlr.GetAttribute("level") != null) _level = int.Parse(xmlr.GetAttribute("level"));
            if (xmlr.GetAttribute("dungeon") != null) _dungeonname = xmlr.GetAttribute("dungeon");
            if (xmlr.GetAttribute("floor") != null) _floorFile = xmlr.GetAttribute("floor");
            if (xmlr.GetAttribute("wall") != null) _wallFile = xmlr.GetAttribute("wall");
            if (xmlr.GetAttribute("id") != null) _id = Int32.Parse(xmlr.GetAttribute("id"));

            if (xmlr.GetAttribute("light") != null) _light = int.Parse(xmlr.GetAttribute("light"));
            if (xmlr.GetAttribute("music") != null) _music = xmlr.GetAttribute("music");

            xmlr.ReadStartElement("GameMap");//GameMap

            for (int row = 0; row < _height; ++row)
            {
                _tiles.Add(new List<FloorTile>());
                for (int col = 0; col < _width; ++col)
                {
                    _tiles[row].Add(new FloorTile(this, new Backend.Coords(col, row)));
                }
            }

            while ((xmlr.NodeType != XmlNodeType.EndElement) && (xmlr.NodeType != XmlNodeType.None))
            { // Add Tiles and overlay-Tiles
                switch (xmlr.Name)
                {
                    case "Tile":
                        FloorTile tile = _tiles[Int32.Parse(xmlr.GetAttribute("CoordY"))][Int32.Parse(xmlr.GetAttribute("CoordX"))];
                        if (xmlr.GetAttribute("visited") != null)
                        {
                            tile.visible = Boolean.Parse(xmlr.GetAttribute("visited"));
                        }
                        if (!xmlr.IsEmptyElement)
                        {
                            xmlr.Read();

                            while ((xmlr.NodeType != XmlNodeType.EndElement))
                            {
                                switch (xmlr.Name)
                                {
                                    case "WallTile":
                                        WallTile wall = new WallTile(this);
                                        if (xmlr.GetAttribute("Enabled") != null) wall.enabled = Boolean.Parse(xmlr.GetAttribute("Enabled"));
                                        if (xmlr.GetAttribute("Health") != null) wall.health = Int32.Parse(xmlr.GetAttribute("Health"));
                                        if (xmlr.GetAttribute("Type") != null) wall.type = (WallType)Enum.Parse(typeof(WallType), xmlr.GetAttribute("Type").ToString());

                                        if (xmlr.GetAttribute("Illusion") != null) wall.illusion = Boolean.Parse(xmlr.GetAttribute("Illusion"));
                                        if (xmlr.GetAttribute("Illusionvisible") != null) wall.illusionVisible = Boolean.Parse(xmlr.GetAttribute("Illusionvisible"));
                                        tile.Add(wall);
                                        break;
                                    case "ProjectileTile":
                                        {
                                            uint id = 0;
                                            if (xmlr.GetAttribute("id", _id.ToString()) != null) id = UInt32.Parse(xmlr.GetAttribute("id"));
                                            Direction dir = Direction.Up;
                                            if (xmlr.GetAttribute("direction", _id.ToString()) != null) dir = (Direction)Enum.Parse(typeof(Direction), xmlr.GetAttribute("direction").ToString());
                                            ProjectileTile projectile = new ProjectileTile(tile, dir, id);
                                        }
                                        break;
                                    case "ItemTile":
                                        Item item = new Item();
                                        xmlr.Read();
                                        item.Load(xmlr);
                                        ItemTile itemTile = new ItemTile(tile, item);
                                        item.tile = itemTile;
                                        tile.Add(itemTile);
                                        xmlr.Read(); // End Item
                                        break;

                                    case "TargetTile":
                                        tile.Add(new TargetTile(tile));
                                        break;

                                    case "TrapTile":
                                        TrapTile trap = new TrapTile(this, Int32.Parse(xmlr.GetAttribute("damage")));
                                        if (xmlr.GetAttribute("penetrate") != null) trap.penetrate = Int32.Parse(xmlr.GetAttribute("penetrate"));

                                        if (xmlr.GetAttribute("evade") != null) trap.evade = Int32.Parse(xmlr.GetAttribute("evade"));

                                        if (xmlr.GetAttribute("changing") != null)
                                        {
                                            trap.type = trap.type | TrapType.Changing;
                                        }
                                        if (xmlr.GetAttribute("hidden") != null)
                                        {
                                            trap.type = trap.type | TrapType.Hidden;
                                        }
                                        if (xmlr.GetAttribute("onlyonce") != null)
                                        {
                                            trap.type = trap.type | TrapType.OnlyOnce;
                                        }
                                        if (xmlr.GetAttribute("broken") != null)
                                        {
                                            trap.status = TrapState.Destroyed;
                                        }
                                        if (xmlr.GetAttribute("disabled") != null)
                                        {
                                            trap.status = TrapState.Disabled;
                                        }
                                        if (xmlr.GetAttribute("invisible") != null)
                                        {
                                            trap.status = TrapState.NoDisplay;
                                        }
                                        tile.Add(trap);
                                        _updateTiles.Add(tile.coords);
                                        break;
                                    case "ReservedTile":
                                        ReservedTile reserved = new ReservedTile(tile);

                                        if (xmlr.GetAttribute("Enabled") != null)
                                        { reserved.enabled = Boolean.Parse(xmlr.GetAttribute("Enabled")); }

                                        if (xmlr.GetAttribute("CanEnter") != null)
                                        { reserved.canEnter = Boolean.Parse(xmlr.GetAttribute("CanEnter")); }
                                        if (xmlr.GetAttribute("Filename") != null)
                                        { reserved.filename = xmlr.GetAttribute("Filename"); }
                                        if (xmlr.GetAttribute("Index") != null)
                                        { reserved.index = Int32.Parse(xmlr.GetAttribute("Index")); }

                                        tile.Add(reserved);

                                        break;

                                    case "DoorTile":
                                        DoorTile door = new DoorTile(tile);
                                        if (xmlr.GetAttribute("open") != null)
                                        { door.open = Boolean.Parse(xmlr.GetAttribute("open")); }

                                        if (xmlr.GetAttribute("key") != null)
                                        { door.key = int.Parse(xmlr.GetAttribute("key")); }
                                        tile.Add(door);
                                        break;

                                    case "TeleportTile":

                                        TeleportTile transporter = new TeleportTile(tile, xmlr.GetAttribute("nextRoom"), new Backend.Coords(Int32.Parse(xmlr.GetAttribute("nextX")), Int32.Parse(xmlr.GetAttribute("nextY"))));
                                        if (xmlr.GetAttribute("hidden") != null)
                                        { transporter.hidden = Boolean.Parse(xmlr.GetAttribute("hidden")); }
                                        if (xmlr.GetAttribute("enabled") != null)
                                        { transporter.enabled = Boolean.Parse(xmlr.GetAttribute("enabled")); }
                                        if (xmlr.GetAttribute("teleport") != null)
                                        { transporter.teleport = Boolean.Parse(xmlr.GetAttribute("teleport")); }
                                        if (xmlr.GetAttribute("down") != null)
                                        { transporter.down = Boolean.Parse(xmlr.GetAttribute("down")); }

                                        tile.Add(transporter);
                                        break;

                                    case "TriggerTile":
                                        Backend.Coords target = new Backend.Coords(-1, -1);
                                        if (xmlr.GetAttribute("affectX") != null) target.x = Int32.Parse(xmlr.GetAttribute("affectX"));

                                        if (xmlr.GetAttribute("affectY") != null) target.y = Int32.Parse(xmlr.GetAttribute("affectY"));

                                        TriggerTile trigger = new TriggerTile(tile, target);

                                        if (xmlr.GetAttribute("explanation") != null) { trigger.explanationEnabled = xmlr.GetAttribute("explanation"); };
                                        if (xmlr.GetAttribute("explanationdisabled") != null) { trigger.explanationDisabled = xmlr.GetAttribute("explanationdisabled"); };
                                        if (xmlr.GetAttribute("enabled") != null) { trigger.enabled = Boolean.Parse(xmlr.GetAttribute("enabled")); };
                                        if (xmlr.GetAttribute("repeat") != null) { trigger.repeat = Int32.Parse(xmlr.GetAttribute("repeat")); };

                                        if (xmlr.GetAttribute("alwaysShowDisabled") != null) { trigger.alwaysShowDisabled = Boolean.Parse(xmlr.GetAttribute("alwaysShowDisabled")); };
                                        if (xmlr.GetAttribute("alwaysShowEnabled") != null) { trigger.alwaysShowEnabled = Boolean.Parse(xmlr.GetAttribute("alwaysShowEnabled")); };

                                        if (xmlr.GetAttribute("tileimage") != null) { trigger.tileimage = xmlr.GetAttribute("tileimage"); };
                                        if (xmlr.GetAttribute("reactToEnemies") != null) { trigger.reactToEnemies = Boolean.Parse(xmlr.GetAttribute("reactToEnemies")); };
                                        if (xmlr.GetAttribute("reactToObjects") != null) { trigger.reactToObjects = Boolean.Parse(xmlr.GetAttribute("reactToObjects")); };
                                        if (xmlr.GetAttribute("reactToItem") != null)
                                        {
                                            trigger.reactToItem = Int32.Parse(xmlr.GetAttribute("reactToItem"));
                                        }
                                        tile.Add(trigger);
                                        break;
                                    case "CheckpointTile":
                                        int bonusLifes = 0;
                                        bool visited = false;

                                        if (xmlr.GetAttribute("bonuslife") != null)
                                            bonusLifes = Convert.ToInt32(xmlr.GetAttribute("bonuslife"));
                                        if (xmlr.GetAttribute("visited") != null)
                                            visited = Convert.ToBoolean(xmlr.GetAttribute("visited"));
                                        tile.Add(new CheckpointTile(tile, visited, bonusLifes));
                                        break;

                                    case "ActorTile":
                                        Actor actor;
                                        xmlr.Read();
                                        switch (xmlr.Name)
                                        {
                                            case "Enemy":
                                                actor = new Enemy();
                                                actor.Load(xmlr);
                                                break;
                                            case "Player":
                                                actor = new Player();
                                                actor.Load(xmlr);
                                                break;
                                            default:
                                                actor = new NPC();
                                                actor.Load(xmlr);
                                                break;
                                        }
                                        while (actor.id > _actors.Count - 1)
                                        {
                                            _actors.Add(new NPC());
                                            _actors[_actors.Count - 1].id = _actors.Count - 1;
                                        }

                                        if (!(actor is Player))
                                        {
                                            ActorTile tile2 = new ActorTile(tile, actor);
                                            tile2.enabled = (actor.health > 0);
                                            actor.tile = tile2;
                                            tile.Add(tile2);
                                            _actors[actor.id] = actor;
                                            _updateTiles.Add(tile.coords);
                                        }
                                        else
                                        {
                                            if (players.Count > 0)
                                            {
                                                bool found = false;
                                                for (int i = 0; i < players.Count; ++i)
                                                {
                                                    if (players[i].GUID == actor.GUID)
                                                    {
                                                        if (!resetPlayer)
                                                            actor.copyFrom(players[i]);
                                                        players.RemoveAt(i);
                                                        found = true;
                                                        break;
                                                    }
                                                }
                                            }
                                            if (targetCoords == null)
                                            {
                                                targetCoords = tile.coords;
                                            }
                                            if (!resetPlayer)
                                            {

                                                ActorTile actortile = new ActorTile(this[targetCoords], actor);
                                                actor.tile = actortile;
                                                actortile.enabled = (actor.health > 0);
                                                actortile.parent = this[targetCoords];
                                                this[targetCoords].Add(actortile);
                                                _actors[actor.id] = actor;
                                                _updateTiles.Add(targetCoords);
                                                Uncover(actors[actor.id].tile.coords, actors[actor.id].viewRange);
                                            }
                                            else
                                            {
                                                ActorTile actortile = new ActorTile(tile, actor);
                                                actor.tile = actortile;
                                                actortile.enabled = (actor.health > 0);
                                                actortile.parent = tile;
                                                tile.Add(actortile);
                                                _actors[actor.id] = actor;
                                                _updateTiles.Add(tile.coords);
                                                Uncover(actors[actor.id].tile.coords, actors[actor.id].viewRange);
                                            }

                                        }

                                        break;
                                }
                                xmlr.Read();
                            }
                            xmlr.ReadEndElement();
                        }
                        else
                        {
                            xmlr.Read();
                        }
                        break;
                }
            }

            if (targetCoords == null)
            {
                targetCoords = new Coords(1, 1);
            }

            while (players.Count > 0)
            {
                ActorTile actortile = new ActorTile(this[targetCoords], players[0]);
                actortile.enabled = (players[0].health > 0);
                actortile.parent = this[targetCoords];
                this[targetCoords].Add(actortile);
                players[0].tile = actortile;
                _updateTiles.Add(targetCoords);
                bool found = false;
                foreach (Actor a in _actors)
                {
                    if ((a.GUID == players[0].GUID) && (players[0].GUID != ""))
                    {
                        found = true;
                        a.copyFrom(players[0]);
                        a.tile = actortile;
                        break;
                    }
                }
                if (!found)
                {
                    foreach (Actor a in _actors)
                    {
                        if ((a is Player) && (a.GUID == ""))
                        {
                            found = true;
                            a.copyFrom(players[0]);
                            a.GUID = players[0].GUID;
                            a.tile = actortile;
                            break;
                        }
                    }
                }
                if (!found)
                {
                    players[0].id = _actors.Count;
                    _actors.Add(players[0]);
                }

                players.RemoveAt(0);
            }
            foreach (Actor a in _actors)
            {
                if (a.tile == null)
                {
                    ActorTile actortile = new ActorTile(this[targetCoords], a);
                    actortile.enabled = (a.health > 0);
                    actortile.parent = this[targetCoords];
                    this[targetCoords].Add(actortile);
                    a.tile = actortile;
                    a.online = false;
                    _updateTiles.Add(targetCoords);
                }
            }
        }
Exemplo n.º 8
0
 public void moveTo(Backend.Coords coord)
 {
     _target = Mainmap._map2screen(coord);
 }
Exemplo n.º 9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="spritebatch"></param>
 /// <param name="name"></param>
 /// <param name="controllable"></param>
 /// <param name="position"></param>
 /// <param name="sprite"></param>
 public ActorView(Camera camera, Backend.IHandleEvent parent, int id, ContentManager content, Backend.Coords position, Backend.Actor actor, string filename = "", int speed = 5, bool alive = true, int width = 96, int height = 96)
     : base(content, width, height, "")
 {
     _camera = camera;
     _position = position;
     _actor = actor;
     _id = id;
     _speed = speed;
     _target = new Backend.Coords((int)position.x, (int)position.y);
     for (int i = 0; i < (Enum.GetValues(typeof(Backend.Activity)).Length) * 8; ++i)
     {
         _textures.Add(new TileObject(_content, _width, _height));
     }
     if (filename != "")
     {
         Load(filename);
     }
     _parent = parent;
     if (!alive)
     {
         Kill();
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Create the visible version of the game map
        /// </summary>
        /// <param name="graphics">The core graphics device manager</param>
        /// <param name="spriteBatch">A sprite batch used for drawing</param>
        /// <param name="displayArea">The area on wich the map will be placed</param>
        /// <param name="floor">The textures used for the floor</param>
        /// <param name="wall1">A set of tiles for the walls</param>
        /// <param name="wall2">A set of tiles for doors</param>
        /// <param name="map">Internal storage of map data</param>
        public Mainmap(Backend.IHandleEvent parent, SpriteBatch spriteBatch, ContentManager content, Rectangle displayArea, Backend.Map map, bool enabled = true)
            : base(parent, spriteBatch, content, displayArea)
        {
            _font = _content.Load<SpriteFont>("font");
            _map = map;
            _background = _content.Load<Texture2D>("Minimap");
            _circle = _content.Load<Texture2D>("Light2");
            _highlightedTile = new Backend.Coords(-1, -1);
            _tooltip = new TileTooltip(this, _spriteBatch, _content, _displayRect);
            // Load textures to use in environment
            // 1. Walls and floor
            _walls = new WallTiles(_content, 128, 192, "");
            _floors = new WallTiles(_content, 128, 192, "");

            // 2. Environmental objects (floor, items, traps, teleporters, chest...)
            _environment = new List<TileSet>();
            _environment.Add(new TileSet(_content, 128, 192));
            _environment[0].Load("Content\\misc.xml");
            _environment.Add(new TileSet(_content, 64, 48));
            _environment[1].Load("Content\\Arrow.xml");
            _environment.Add(new TileSet(_content, 55, 55));
            _environment[2].Load("Content\\explosion.xml");

            // 3. Moving entities (player, NPCs, enemies)
            _actors = new List<ActorView>();
            _effects = new List<MapEffect>();

            resetActors();
            _floatnumbers = new List<FloatNumber>();
            _projectiles = new List<Projectile>();
            _enabled = enabled;
        }
Exemplo n.º 11
0
 /// <summary>
 /// Highlight tile based on mouse position; note inverted matrix (since map is zoomed / panned)
 /// </summary>
 /// <param name="coords"></param>
 private void _UpdateMouse(Vector2 coords)
 {
     Vector2 realPos = Vector2.Transform(coords, Matrix.Invert(_camera.matrix));
     _highlightedTile = _pos2Tile(realPos);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Method to add the player to a room.
 /// </summary>
 /// <param name="pos">The position at which the player will spawn, (1,1) by default</param>
 public void AddPlayer(Coords pos)
 {
     if (pos == null)
     {
         pos = new Backend.Coords(1, 1);
     }
     Player player = new Player(100, 0, 30);
     ActorTile playerTile = new ActorTile(_tiles[pos.y][pos.x], player);
     player.tile = playerTile;
     _tiles[pos.y][pos.x].Add(playerTile);
     _actors.Add(player);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Method to add a boss enemy to a room.
        /// A boss is more powerful than a normal enemy
        /// and the room gets a special sound if there is a boss in it.
        /// </summary>
        public void AddBoss()
        {
            for (int x = 0; x < _width; ++x)
            {
                for (int y = 0; y < _height; ++y)
                {
                    if ((_tiles[y][x].hasEnemy) || (_tiles[y][x].hasNPC) || (_tiles[y][x].hasTreasure))
                    {
                        ClearTile(x, y);
                    }

                }
            }

            Backend.Coords pos = new Backend.Coords(2 + r.Next(_width - 4), 2 + r.Next(_height - 4));
            for (int x = -1; x < 2; ++x)
            {
                for (int y = -1; y < 2; ++y)
                {
                    ClearTile(pos.x + x, pos.y + y);

                }
            }

            Enemy boss = new Enemy(-1, -1, -1, -1, "", r, 10 + _level);
            if (r.NextDouble() >= 0.5)
            {
                boss.fireDefense = 70;
                boss.fireDamage += r.Next(10);
            }
            else
            {
                boss.iceDefense = 70;
                boss.iceDamage += r.Next(10);
            }
            ActorTile BossTile = new ActorTile(_tiles[pos.y][pos.x], boss);
            boss.tile = BossTile;
            _tiles[pos.y][pos.x].Add(BossTile);
            _actors.Add(boss);
            if (_level == 1) _music = "boss1.wav"; else _music = "boss2.wav";
        }
Exemplo n.º 14
0
        /// <summary>
        /// Find an appropriate place to put an exit on the map
        /// </summary>
        /// <param name="dir">Wall on which exit should be placed</param>
        /// <returns>Coordinates of the exit</returns>
        public Backend.Coords SuggestExit(Direction dir)
        {
            switch (dir)
            {
                case Direction.UpLeft:
                    return new Backend.Coords(0, 0);

                case Direction.UpRight:
                    return new Backend.Coords(_width - 1, 0);

                case Direction.DownLeft:
                    return new Backend.Coords(0, _height - 1);

                case Direction.DownRight:
                    return new Backend.Coords(_width - 1, _height - 1);

                case Direction.Up:
                    {
                        Backend.Coords tmp = new Backend.Coords(1 + r.Next((_width - 1) / 2) * 2, 0);
                        ClearTile(tmp.x, 1);
                        return tmp;
                    }

                case Direction.Down:
                    {
                        Backend.Coords tmp = new Backend.Coords(1 + r.Next((_width - 1) / 2) * 2, _height - 1);
                        ClearTile(tmp.x, tmp.y - 1);
                        return tmp;
                    }

                case Direction.Left:
                    {
                        Backend.Coords tmp = new Backend.Coords(0, 1 + r.Next((_height - 1) / 2) * 2);
                        ClearTile(1, tmp.y);
                        return tmp;
                    }
                case Direction.Right:
                    {
                        Backend.Coords tmp = new Backend.Coords(_width - 1, 1 + r.Next((_height - 1) / 2) * 2);
                        ClearTile(tmp.x - 1, tmp.y);
                        return tmp;
                    }
            }
            return Backend.Coords.Zero;
        }