コード例 #1
0
ファイル: Map.cs プロジェクト: MyEyes/Igorr
        public void LoadNew(string file)
        {
            BinaryReader reader = new BinaryReader(File.OpenRead("Content\\map\\"+file + ".map"));
            int sizeX = reader.ReadInt32();
            int sizeY = reader.ReadInt32();
            tileSet = ContentInterface.LoadTexture(reader.ReadString());
            /*
            int tpCount = reader.ReadInt32();
            for (int x = 0; x < tpCount; x++)
            {
                reader.ReadInt32();
                reader.ReadInt32();
                reader.ReadInt32();
            }
             */
            _layers = new Tile[3][,];
            int tilesPerLine = tileSet.Width / tileSize;
            for (int layer = 0; layer < 3; layer++)
            {
                int count = 0;
                _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)
                            {
                                int line = tileID / tilesPerLine;
                                _layers[layer][x, y] = new Tile(new Rectangle(tileSampleSize * (tileID% tilesPerLine), line * tileSampleSize, tileSampleSize, tileSampleSize), new Rectangle(x * tileSize, y * tileSize, tileSize, tileSize), tileSet, layer == 1);
                                count++;
                            }
                            else
                                _layers[layer][x, y] = null;
                    }
                Console.WriteLine(count.ToString() + " tiles in layer " + layer.ToString());
            }
            _events = new EventObject[sizeX, sizeY];
            reader.Close();

            CalculateLevelGeometry();
        }
コード例 #2
0
ファイル: EventObject.cs プロジェクト: MyEyes/Igorr
 public void SetParent(Tile obj)
 {
 }
コード例 #3
0
ファイル: Map.cs プロジェクト: MyEyes/Igorr
 public void ChangeTile(int x, int y, int layer, int tileID)
 {
     _sem.WaitOne();
     if (isValid(x, y) && layer >= 0 && layer < 3 && tileID >= 0)
     {
         if (_layers[layer][x, y] != null)
             _layers[layer][x, y].SetTile(tileID);
         else
             _layers[layer][x, y] = new Tile(new Rectangle(tileID * tileSize, 0, tileSize, tileSize), new Rectangle(x * tileSize, y * tileSize, tileSize, tileSize), tileSet, layer == 1);
     }
     else if (isValid(x, y) && layer >= 0 && layer < 3)
         _layers[layer][x, y] = null;
     _sem.Release();
 }