예제 #1
0
파일: Grd.cs 프로젝트: lizhongwow/SceneTest
        public const string file_folder = "";// @"D:\PrimaryServer\whserver\\";

        public Grd(map_conf map)
        {
            this.width = map.width;
            this.height = map.height;

            FileStream fs = new FileStream(file_folder + map.map_grd.file, FileMode.Open);
            StreamReader sr = new StreamReader(fs);
            var ba = sr.ReadToEnd().ToCharArray();

            length = ba.Length / 2;
            grd_ary = new Point2D[length];

            List<Point2D> walkables = new List<Point2D>();

            for (int i = 0; i < length; i++)
            {
                short ba1 = (short)(((short)ba[i * 2]) << 8);
                short ba2 = (short)ba[i * 2 + 1];
                //short g_walkable = (short)(((short)ba[i * 2]) << 8 + ba[i * 2 + 1]);
                int g_walkable = ba1 + ba2;
                Point2D grid = new Point2D(i / this.width, i % this.width);
                grid.walkable = g_walkable;
                grid.distance = int.MaxValue;
                grid.index = i;
                grd_ary[i] = grid;

                if (g_walkable == 0)
                    walkables.Add(grid);
            }

            walkable_grd = walkables.ToArray();

            sr.Close();
            fs.Close();
        }
예제 #2
0
    public grid_map(int mapid)
    {
        map_conf = Utility.get_map_conf(mapid);

        this.grd = new Grd(map_conf);

        this.mapid = mapid;
        this.map_mons = new Dictionary<int, IBaseUnit>();
        this.map_mon_bymid = new Dictionary<int, List<IBaseUnit>>();
        this.map_sprites = new Dictionary<int, IBaseUnit>();
        this.map_players = new Dictionary<int, IBaseUnit>();
        this.map_players_bysid = new Dictionary<int, IBaseUnit>();
        this.map_players_bycid = new Dictionary<int, IBaseUnit>();
        this.pk_seting = this.get_map_pkseting();

        this.immrespawn = map_conf.immrespawn == 1;

        this.map_dpitms = new Dictionary<int, map_item>();

        this.last_check_tm = 0;
        this.map_skills = new Dictionary<int, SkillData>();

        var monster_count = this.get_monster_desc_count();
        this.petmon_cache = new Dictionary<int, List<IBaseUnit>>();

        //this.tmtriggers = { };
        //this.areatriggers = { };

        //this.useitmtriggers = { };
        //this.mistriggers = { };
        //this.othertriggers = { };
        this.callmon_added = new Dictionary<int, int>();

        //this.add_npcs = [];
        this.add_links = new List<link_conf>();
        //this.mapstats = [];
        this.paths = new Dictionary<int, List<Point2D>>();
        //this.team_drop_itm = {};

        //this.temp_sid_ary = int_ary.create_int_ary();





        var i = 0;
        for (; i < monster_count; ++i)
        {
            int mid = this.map_conf.map_mon[i].mid;
            var mon_conf = Utility.get_monster_conf(mid);
            if (null == mon_conf)
                throw new Exception("monsterconf not found for mid:" + mid);

            var m = new Monster(mon_conf);

            m.gmap = this;
            m.on_pos_change(m.mondata.x, m.mondata.y);
            IMapUnit mon = m.get_pack_data();

            this.map_mons[mon.iid] = m;
            this.map_sprites[mon.iid] = m;

            List<IBaseUnit> mons = null;
            if (this.map_mon_bymid.TryGetValue(mon.mid, out mons))
            {
                mons.Add(m);
            }
            else
            {
                mons = new List<IBaseUnit>();
                mons.Add(m);
                this.map_mon_bymid[mon.mid] = mons;
            }
        }
    }