Beispiel #1
0
        public void ChangeTile(int layer, Vector2 position, int tileID)
        {
            int posX = (int)(position.X / tileSize);
            int posY = (int)(position.Y / tileSize);
            if (isValid(posX, posY) && layer >= 0 && layer < 3)
            {
                if ((_layers[layer][posX, posY] == null && tileID < 0) || (_layers[layer][posX, posY] != null && tileID == _layers[layer][posX, posY].TileID))
                    return;
                Tile newTile = new Tile(this, new Rectangle(tileID * tileSize, 0, tileSize, tileSize), new Rectangle(posX * tileSize, posY * tileSize, tileSize, tileSize), layer == 1);
                if (tileID == -1)
                    _layers[layer][posX, posY] = null;
                else
                    _layers[layer][posX, posY] = newTile;

                IGORR.Protocol.Messages.ChangeTileMessage ctm = (IGORR.Protocol.Messages.ChangeTileMessage)ObjectManager.Server.ProtocolHelper.NewMessage(IGORR.Protocol.MessageTypes.ChangeTile);
                ctm.tileID = tileID;
                ctm.x = posX;
                ctm.y = posY;
                ctm.layer = layer;
                ctm.Encode();
                manager.Server.SendAllMapReliable(this, ctm, true);

                TileModification tmod = new TileModification();
                tmod.layer=layer;
                tmod.Position=new Point(posX,posY);
                tmod.TileID=tileID;
                for (int x = 0; x < _tileMods.Count; x++)
                    if (_tileMods[x].Position == tmod.Position && _tileMods[x].layer == tmod.layer)
                    {
                        _tileMods[x].TileID = tileID;
                        return;
                    }
                _tileMods.Add(tmod);
            }
        }
Beispiel #2
0
        public void ChangeTile(int layer, Vector2 position, int tileID)
        {
            int posX = (int)(position.X / tileSize);
            int posY = (int)(position.Y / tileSize);
            if (isValid(posX, posY) && layer >= 0 && layer < 3)
            {
                Tile newTile = new Tile(this, new Rectangle(tileID * tileSize, 0, tileSize, tileSize), new Rectangle(posX * tileSize, posY * tileSize, tileSize, tileSize), layer == 1);
                if (tileID == -1)
                    _layers[layer][posX, posY] = null;
                else
                    _layers[layer][posX, posY] = newTile;

                TileModification tmod = new TileModification();
                tmod.layer=layer;
                tmod.Position=new Point(posX,posY);
                tmod.TileID=tileID;
                for (int x = 0; x < _tileMods.Count; x++)
                    if (_tileMods[x].Position == tmod.Position && _tileMods[x].layer == tmod.layer)
                    {
                        _tileMods[x].TileID = tileID;
                        return;
                    }
                _tileMods.Add(tmod);
            }
        }