Пример #1
0
 public override void FromJSON(Tile tile, JSONNode node)
 {
     tile.position.x = node ["x"].AsInt;
     tile.position.y = node ["y"].AsInt;
     tile.text = node ["text"];
     tile.color = Util.Color.HexToColor (node["color"]);
 }
Пример #2
0
 public override void SetText(Tile tile)
 {
     string [] sTreeTexts = {"♠", "♣"};
     string [] sTreeColors = {"437C17", "347C2C", "254117", "387C44", "6CBB3C", "54C571"};
     tile.text = sTreeTexts [Random.Range (0, sTreeTexts.Length)];
     tile.color = Util.Color.HexToColor(sTreeColors[Random.Range (0, sTreeColors.Length)]);
 }
Пример #3
0
        private static Tile CreateTile(string category, string[] columns)
        {
            Tile t = new Tile()
            {
                ID = columns[0],
                Category = category
            };

            string[] images = columns[1].Split('|');
            int anim = 4;
            int i = 0;
            if (int.TryParse(images[0], out anim))
            {
                ++i;
            }

            t.Height = int.Parse(columns[2]);

            List<string> frames = new List<string>();
            for (; i < images.Length; ++i)
            {
                frames.Add("images/tiles/" + images[i]);
            }

            t.ImageFiles = frames.ToArray();
            return t;
        }
        public static void createTile(QuadNode<Tile> node, Utilities.Vec2Int pos)
        {
            if (_defaultFloorTex == null)
                _defaultFloorTex = Resources.Load<Texture2D>("Textures/Game Environment/Tile");

            Tile tile = new Tile(node, null, pos);
            tile.setFloorTexture(_defaultFloorTex);
        }
Пример #5
0
 public override void FromJSON(Tile tile, JSONNode node)
 {
     tile.position.x = node ["x"].AsInt;
     tile.position.y = node ["y"].AsInt;
     tile.text = "E";
     tile.color = Color.green;
     name = node ["name"];
     description = node ["description"];
 }
 public TileSwatch(Tile tile)
 {
     this.Tile = tile;
     InitializeComponent();
     this.image_swatch.Source = tile.Image;
     string label = tile.ImageFiles[0];
     this.text_label.Text = label.Substring("images/tiles/".Length);
     this.MouseLeftButtonDown += new MouseButtonEventHandler(TileSwatch_MouseLeftButtonDown);
 }
Пример #7
0
        public override void SetText(Tile tile)
        {
            int x = tile.position.x;
            int y = tile.position.y;
            int neighborDirection = NONE;
            Tile neighborTile = null;

            neighborTile = Map.Instance.GetTile (x - 1, y);
            if (null != neighborTile && "Wall" == neighborTile.type) {
                neighborDirection |= WEST;
            }
            neighborTile = Map.Instance.GetTile (x + 1, y);
            if (null != neighborTile && "Wall" == neighborTile.type) {
                neighborDirection |= EAST;
            }
            neighborTile = Map.Instance.GetTile (x, y - 1);
            if (null != neighborTile && "Wall" == neighborTile.type) {
                neighborDirection |= NORTH;
            }
            neighborTile = Map.Instance.GetTile (x, y + 1);
            if (null != neighborTile && "Wall" == neighborTile.type) {
                neighborDirection |= SOUTH;
            }

            neighborTile = Map.Instance.GetTile (x - 1, y - 1);
            if ((neighborDirection & (WEST|NORTH)) == (WEST|NORTH) && null != neighborTile && "Wall" == neighborTile.type) {
                throw new System.Exception("can't put the wall at " + tile.position.ToString());
            }
            neighborTile = Map.Instance.GetTile (x + 1, y - 1);
            if ((neighborDirection & (EAST|NORTH)) == (EAST|NORTH) && null != neighborTile && "Wall" == neighborTile.type) {
                throw new System.Exception("can't put the wall at " + tile.position.ToString());
            }
            neighborTile = Map.Instance.GetTile (x + 1, y + 1);
            if ((neighborDirection & (EAST|SOUTH)) == (EAST|SOUTH) && null != neighborTile && "Wall" == neighborTile.type) {
                throw new System.Exception("can't put the wall at " + tile.position.ToString());
            }
            neighborTile = Map.Instance.GetTile (x - 1, y + 1);
            if ((neighborDirection & (WEST|SOUTH)) == (WEST|SOUTH) && null != neighborTile && "Wall" == neighborTile.type) {
                throw new System.Exception("can't put the wall at " + tile.position.ToString());
            }

            if (tile.text != PRESET [neighborDirection]) {
                tile.text = PRESET [neighborDirection];
                if(0 != (WEST&neighborDirection)) {
                    Map.Instance.GetTile (x-1, y).SetText();
                }
                if(0 != (EAST&neighborDirection)) {
                    Map.Instance.GetTile(x+1, y).SetText();
                }
                if(0 != (NORTH&neighborDirection)) {
                    Map.Instance.GetTile(x, y-1).SetText();
                }
                if(0 != (SOUTH&neighborDirection)) {
                    Map.Instance.GetTile(x, y+1).SetText();
                }
            }
        }
Пример #8
0
 public override JSONNode ToJSON(Tile tile)
 {
     JSONNode node = new JSONClass ();
     node ["x"].AsInt = tile.position.x;
     node ["y"].AsInt = tile.position.y;
     node ["type"] = GetType ();
     node ["name"] = name;
     node ["description"] = description;
     return node;
 }
Пример #9
0
 public override JSONNode ToJSON(Tile tile)
 {
     JSONNode node = new JSONClass ();
     node ["x"].AsInt = tile.position.x;
     node ["y"].AsInt = tile.position.y;
     node ["type"] = GetType ();
     node ["text"] = tile.text;
     node ["color"] = Util.Color.ColorToHex(tile.color);
     return node;
 }
Пример #10
0
        // Creates a static wall if and only if at least one side of the tile set (2x2)
        public static void createEdgeWall(Tile tile, Vec2Int pos)
        {
            if (tile == null)
                return;

            Vec2Int basePos = pos;
            if (basePos.x % 2 != 0)
            {
                tile = tile.getSide(SIDE_4.LEFT);

                if (tile == null)
                    return;
            }

            if (basePos.y % 2 != 0)
            {
                tile = tile.getSide(SIDE_4.BOTTOM);

                if (tile == null)
                    return;
            }

            Map map = Map.Get();

            // If any of the sides are null, consider the tile to be a boundary.
            if (tile.getSide(SIDE_4.LEFT) == null)
            {
                PlaceableStaticWall.createStaticWall(map.toTilePos(tile.position()));
                return;
            }
            else if (tile.getSide(SIDE_4.BOTTOM) == null)
            {
                PlaceableStaticWall.createStaticWall(map.toTilePos(tile.position()));
                return;
            }

            Tile it = tile.getSide(SIDE_4.TOP);
            if (it != null && it.getSide(SIDE_4.TOP) == null)
            {
                PlaceableStaticWall.createStaticWall(map.toTilePos(tile.position()));
                return;
            }

            it = tile.getSide(SIDE_4.RIGHT);
            if (it != null && it.getSide(SIDE_4.RIGHT) == null)
            {
                PlaceableStaticWall.createStaticWall(map.toTilePos(tile.position()));
                return;
            }
        }
Пример #11
0
        public Map(int sizeX, int sizeY, string tileset)
        {
            _dummy = new IGORR.Server.Logic.DummyMap();
            tileSet = ContentInterface.LoadTexture(tileset);
            font = ContentInterface.LoadFont("font");
            tileSetName = tileset;

            _layers = new Tile[3][,]; //0=background, 1=collisionlayer, 2=foreground
            for (int x = 0; x < 3; x++)
            {
                _layers[x] = new Tile[sizeX, sizeY];
            }
            _spawns = new SpawnPoint[sizeX, sizeY];
            for (int x = 0; x < sizeX; x++)
            {
                for (int y = 0; y < sizeY; y++)
                {
                    _layers[0][x, y] = new Tile(tileSet, new Rectangle(tileSize * x, tileSize * y, tileSize, tileSize), new Rectangle(0, 0, tileSize, tileSize));
                }
            }
        }
Пример #12
0
 public ImageBrush getTileBrush(Tile t)
 {
     //Tile t = baseTileSet.getTileAt(index & 15, (index >> 4) & 15);
     //if (t == null) return null;
     ImageBrush b = new ImageBrush(baseImage.Source);
     b.ViewboxUnits = BrushMappingMode.Absolute;
     b.Viewbox = new Rect(64 * t.LeftX, 64 * t.TopY, 64 * (t.RightX - t.LeftX + 1), 64 * (t.BottomY - t.TopY + 1));
     return b;
 }
Пример #13
0
 public TileSelectedArgs(Tile tile)
 {
     t = tile;
 }
Пример #14
0
        protected override void attach(Tile[] tiles)
        {
            PlaceableStaticWall sw1 = tiles[0].getObject() as PlaceableStaticWall;
            PlaceableStaticWall sw2 = null;

            for (int i = 1; i < tiles.Length; i++)
            {
                sw2 = tiles[i].getObject() as PlaceableStaticWall;
                if (!sw1.bottomLeft.position().Equals(sw2.bottomLeft.position()))
                    break;
            }

            sw1.remove();
            GameObject.Destroy(sw1.gameObject);

            sw2.remove();
            GameObject.Destroy(sw2.gameObject);

            base.attach(tiles);
        }
Пример #15
0
        protected override void Awake()
        {
            base.Awake();

            _area = new bool[4, 2];
            _area[0, 0] = true;
            _area[0, 1] = true;
            _area[1, 0] = true;
            _area[1, 1] = true;
            _area[2, 0] = true;
            _area[2, 1] = true;
            _area[3, 0] = true;
            _area[3, 1] = true;

            mIsActive = true;

            mFrontSide = frontSide.GetComponent<PlaceableDoorSide>();
            mBackSide = backSide.GetComponent<PlaceableDoorSide>();

            mAttached = new Tile[8];
            for (int i = 0; i < mAttached.Length; i++)
                mAttached[i] = null;

            _angle = 0.0f;

            _prefab = prefab();
        }
Пример #16
0
        public Tile[,] getArea(Tile baseTile, Vec2Int size)
        {
            if (size.x < 0 || size.y < 0)
                return null;

            Tile[,] area = new Tile[size.x, size.y];

            Vec2Int basePos = baseTile.position();
            Vec2Int offset = new Vec2Int(0, 0);
            for (int i = 0; i < size.x; i++)
            {
                offset.x = i;
                for (int j = 0; j < size.y; j++)
                {
                    offset.y = j;
                    area[i, j] = getExistingTile(basePos + offset);
                }
            }

            return area;
        }
Пример #17
0
 public TileSet( Tile[ ] p_blocks )
 {
     m_blocks = p_blocks;
 }
Пример #18
0
        private void ResizeTileArray()
        {
            var size = GridWidth * GridHeight;

            if(size > 0)
            {
                var temp = new Tile[GridWidth * GridHeight];

                if(Tiles != null)
                    Tiles.CopyTo(temp, 0);
                Tiles = temp;
            }
        }
Пример #19
0
 public override void FromJSON(Tile tile, JSONNode node)
 {
 }
Пример #20
0
        public Map(string fileName)
        {
            _dummy = new IGORR.Server.Logic.DummyMap();
            font = ContentInterface.LoadFont("font");
            _fileName = fileName;
            BinaryReader reader = new BinaryReader(File.OpenRead(_fileName));
            int sizeX = reader.ReadInt32();
            int sizeY = reader.ReadInt32();
            tileSetName = reader.ReadString();
            tileSet = ContentInterface.LoadTexture(tileSetName);
            /*
            int tpCount = reader.ReadInt32();
            for (int x = 0; x < tpCount; x++)
            {
            TeleportPoint point = new TeleportPoint();
            point.mapID = reader.ReadInt32();
            point.X = reader.ReadInt32();
            point.Y = reader.ReadInt32();
            _teleportPoints.Add(point);
            }
             */
            _layers = new Tile[3][,];
            for (int layer = 0; layer < 3; layer++)
            {
                _layers[layer] = new Tile[sizeX, sizeY];
                for (int x = 0; x < sizeX; x++)
                    for (int y = 0; y < sizeY; y++)
                    {
                        int tileID=reader.ReadInt32();
                        if (tileID >= 0 && tileID * tileSize < tileSet.Width)
                            _layers[layer][x, y] = new Tile(tileSet, new Rectangle(x * tileSize, y * tileSize, tileSize, tileSize), new Rectangle(tileID * tileSize, 0, tileSize, tileSize));
                        else
                            _layers[layer][x, y] = null;
                    }
            }
            _spawns = new SpawnPoint[sizeX, sizeY];
            try
            {
                for (int x = 0; x < sizeX; x++)
                    for (int y = 0; y < sizeY; y++)
                    {
                        int objectID = reader.ReadInt32();
                        if (objectID >= 0)
                        {
                            _spawns[x, y] = new SpawnPoint();
                            _spawns[x, y].objectID = objectID;
                            _spawns[x, y].X = x;
                            _spawns[x, y].Y = y;
                            if (objectID > 0)
                            {
                                ObjectControl ctrl =ModuleManager.GetControl(objectID, reader);
                                if (ctrl != null)
                                    _spawns[x, y].bytes = ctrl.GetObjectBytes();
                                //ModuleManager.SpawnByIdServer(_dummy, objectID, 0, Point.Zero, reader);
                            }

                        }
                        else
                            _spawns[x, y] = null;
                    }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Error loading objects in the map, you can still continue though");
            }
            reader.Close();
            _teleportPoints.Clear();
        }
Пример #21
0
 /// <summary>
 /// Sets a tile on the layer at a specific location (x,y)
 /// </summary>
 /// <param name="tile">Input the Tile object to store at that location</param>
 /// <param name="x">Input the x location of the tile</param>
 /// <param name="y">Input the y location of the tile</param>
 public void setTile(Tile tile, int x, int y)
 {
     if(x >= 0 && x < width && y >= 0 && y < height) // Bounds checking
         layer[y, x] = tile;
 }
Пример #22
0
 public void setTile(Vec2Int globalPosition, Tile tile)
 {
     getQuadNode(globalPosition).data(tile);
     tile.position(globalPosition);
 }
Пример #23
0
 public override JSONNode ToJSON(Tile tile)
 {
     return null;
 }
Пример #24
0
 public override void SetText(Tile tile)
 {
     tile.text = "";
     tile.color = Color.white;
 }
Пример #25
0
 public void ChangeTile(int layer, float worldX, float worldY, int tileNum)
 {
     int x = (int)(worldX / tileSize);
     int y = (int)(worldY / tileSize);
     if (isValidOrNull(layer, x, y))
         if (tileNum == -1)
         {
             _layers[layer][x, y] = null;
         }
         else _layers[layer][x, y] = new Tile(tileSet, new Rectangle(tileSize * x, tileSize * y, tileSize, tileSize), new Rectangle(tileNum * tileSize, 0, tileSize, tileSize));
 }
Пример #26
0
 public override void SetText(Tile tile)
 {
     tile.text = "E";
     tile.color = Color.green;
 }
Пример #27
0
        protected Tile[] getTiles()
        {
            int tileCount = 0;
            for (int i = 0; i < _area.GetLength(0); i++)
                for (int j = 0; j < _area.GetLength(1); j++)
                    if (_area[i, j])
                        tileCount++;

            if (tileCount == 0)
                return null;

            Tile[] tiles = new Tile[tileCount];
            int tileCounter = 0;
            processTiles((int x, int y, Utilities.Vec2Int tilePos) =>
            {
                if (_area[x, y])
                    tiles[tileCounter++] = getTile(tilePos);
            });

            return tiles;
        }
Пример #28
0
        /// <summary>
        /// passing in null tileswatch is an eraser
        /// </summary>
        /// <returns>true if a change has occurred and the view ought to be updated</returns>
        public bool ModifyTile(int col, int row, int layer, Tile tileSwatch)
        {
            if (col < 0 || col >= this.Width || row < 0 || row >= this.Height) return false;
            int index = col + row * this.Width;
            List<Tile> tileStack = this.Grid[index];
            List<Tile> spread = new List<Tile>();
            foreach (Tile tile in tileStack)
            {
                if (tile == null)
                {
                    spread.Add(null);
                }
                else
                {
                    spread.Add(tile);
                    for (int i = 1; i < tile.Height; ++i)
                    {
                        spread.Add(null);
                    }
                }
            }

            while (spread.Count <= layer)
            {
                spread.Add(null);
            }

            spread[layer] = tileSwatch;
            List<Tile> output = new List<Tile>();
            for (int i = 0; i < spread.Count; ++i)
            {
                output.Add(spread[i]);
                if (spread[i] != null)
                {
                    i += spread[i].Height - 1;
                }
            }

            if (output.Count != tileStack.Count)
            {
                tileStack.Clear();
                tileStack.AddRange(output);
                return true;
            }
            bool changes = false;
            for (int i = 0; i < output.Count; ++i)
            {
                if (output[i] != tileStack[i])
                {
                    tileStack[i] = output[i];
                    changes = true;
                }
            }

            return changes;
        }
Пример #29
0
        protected virtual void attach(Tile[] tiles)
        {
            mAttached = new Tile[tiles.Length];

            for (int i = 0; i < tiles.Length; i++)
            {
                mAttached[i] = tiles[i];
                mAttached[i].attachObject(this);
            }
        }
Пример #30
0
        /// <summary>
        /// Resize the TileMap to the given dimensions.
        /// If either width or height are set to zero or below, the Tile array is set to null instead.
        /// </summary>
        /// <param name="newWidth">The new width of the TileMap.</param>
        /// <param name="newHeight">The new height of the TileMap.</param>
        public void ResizeTileArray(int newWidth, int newHeight)
        {
            if (newWidth > 0 && newHeight > 0)
            {
                Width = newWidth;
                Height = newHeight;

                var temp = new Tile[Width, Height];

                if (Tiles != null)
                {
                    Array.Copy(Tiles, temp, Math.Min(Tiles.Length, temp.Length));
                }

                Tiles = temp;
            }
            else
            {
                Width = 0;
                Height = 0;
            }
        }