Ejemplo n.º 1
0
        public Tilemap(int w, int h, Tilemap ft)
        {
            cmap = new CityMap(w, h);
            map = new Tile[w, h];
            fog = new Fog(w, h);
            name = ft.name;

            startpos = new Point(ft.startpos.X, ft.startpos.Y);

            for (int i = 0; i < w; i++)
                for (int e = 0; e < h; e++)
                {
                    if (i < ft.NumX && e < ft.NumY)
                    {
                        map[i, e] = ft.get(i, e);
                        fog.set(i, e, ft.Fog.get(i, e));
                        cmap.set(i, e, ft.CityMap.get(i, e));
                    }
                    else if (i < w && e < h)
                    {
                        map[i, e] = new Tile();
                        fog.set(i, e, false);
                    }
                }
        }
Ejemplo n.º 2
0
        public Tilemap(int w, int h)
        {
            cmap = new CityMap(w, h);
            startpos = new Point();
            map=new Tile[w,h];
            fog = new Fog(w, h);

            for(int i=0; i<w; i++)
                for (int e = 0; e < h; e++)
                {
                    map[i, e] = new Tile(Tile.TileType.PLAIN);
                }
        }
Ejemplo n.º 3
0
        public Tilemap()
        {
            int w = 30;
            int h = 20;

            map = new Tile[w, h];

            Random r = new Random();

            Tilemap g = new Tilemap("green");
            Tilemap b = new Tilemap("blue");

            for (int e = 0; e < h; e++)
                for (int i = 0; i < w; i++)
                {
                    map[i, e] = new Tile((Tile.TileType)r.Next(6));

                    if (map[i, e].Type == Tile.TileType.FOREST)
                        map[i, e].Region = g;
                    else if (map[i, e].Type == Tile.TileType.WATER)
                        map[i, e].Region = b;
                }
        }
Ejemplo n.º 4
0
        public void load(String path)
        {
            name = Path.GetFileNameWithoutExtension(path);

            if (!VersionSys.match(path, vi))
                throw new Exception("File is not a Forgotten Schism Map file v1.0");

            FileStream fin = new FileStream(path, FileMode.Open);

            fin.Seek(12, SeekOrigin.Begin);

            startpos.X = fin.ReadByte();
            startpos.Y = fin.ReadByte();

            //map width and height
            int w = fin.ReadByte();
            int h = fin.ReadByte();

            map=new Tile[w,h];
            fog = new Fog(w, h);

            if(cmap==null)
                cmap = new CityMap(w, h);

            cmap.load(Path.ChangeExtension(path, ".citymap"));

            //map data

            int tt;

            for (int e = 0; e < h ; e++)
                for (int i = 0; i < w; i++)
                {
                    tt = fin.ReadByte();

                    fog.set(i, e, Gen.conv((byte)fin.ReadByte()));

                    map[i, e] = new Tile((Tile.TileType)tt);
                }

            fin.Close();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Determin if the Unit can move through a certain type of terrain
        /// </summary>
        /// <param name="type">Type of terrain to test if the Unit can move through</param>
        /// <returns>wether the Unit can move through the terrain or not</returns>
        public bool canMove(Tile.TileType type)
        {
            foreach (Character c in map)
                if (c!=null&&!c.canMove(type))
                    return false;

            return true;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Determin if the Character can move through a certain type of terrain
 /// </summary>
 /// <param name="type">Type of terrain to test if the Character can move through</param>
 /// <returns></returns>
 public bool canMove(Tile.TileType type)
 {
     return !(type == Tile.TileType.MOUNTAIN || type == Tile.TileType.WATER);
 }
Ejemplo n.º 7
0
        public void load(String path)
        {
            path = "./map/" + path;

            if (!VersionSys.match(path, uid, type, ver))
                throw new Exception("File is not a Forgotten Schism Map file v1.0");

            List<String> refls=new List<String>();

            FileStream fin = new FileStream(path, FileMode.Open);

            fin.Seek(12, SeekOrigin.Begin);

            int rn = fin.ReadByte();
            int sl;
            char[] sb;
            int e;

            for (int i = 0; i < rn; i++)
            {
                sl = fin.ReadByte();
                sb=new char[sl];

                for (e = 0; e < sl; e++)
                    sb[e] = (char)fin.ReadByte();

                refls.Add(new String(sb));
            }

            //map width and height
            int w = fin.ReadByte();
            int h = fin.ReadByte();

            map=new Tile[w,h];

            //map data

            int tt;
            Tilemap tm;

            for (e = 0; e < h ; e++)
                for (int i = 0; i < w; i++)
                {
                    tt = fin.ReadByte();
                    rn = fin.ReadByte();

                    if (rn != 0)
                    {
                        tm = new Tilemap(refls[rn-1]);
                    }
                    else
                        tm = null;

                    map[i, e] = new Tile((Tile.TileType)tt, tm);
                }

            fin.Close();
        }