Exemple #1
0
        public void call_petmon(int mid, long fintm)
        {
            // 创建出战战斗宠物

            if (this.gmap == null)
            {
                return;
            }

            //相同 战宠   已招则取消召唤
            if (petmon_inst != null && petmon_inst.get_pack_data().mid == mid)
            {
                release_petmon();
                return;
            }

            release_petmon(false, false);

            map_mon_conf monconf = new map_mon_conf() { mid = mid, x = 0, y = 0, r_x = 8, r_y = 8, spwan_time = 0 };
            petmon_inst = this.gmap.new_pet_mon(this, monconf);
            if (null == petmon_inst)
            {
                return;
            }

            this.pet_mon.mid = mid;
            this.pet_mon.fintm = fintm;

            IMapUnit mondata = petmon_inst.get_pack_data();

            mondata.follow = new follow()
            {
                start_tm = Utility.time(),
                tar_iid = pinfo.iid,
                trace_tm_left = 0,
                frang = 78400,
                trang = 8100,
                do_ai = true
            };//280*280
        }
Exemple #2
0
    public IBaseUnit new_pet_mon(IBaseUnit ply, map_mon_conf monconf)
    {
        // 分配战斗宠物实例
        IBaseUnit mon = null;
        IMapUnit mondata = null;

        List<IBaseUnit> list = null;
        this.petmon_cache.TryGetValue(monconf.mid, out list);

        if (list == null || list.Count <= 0)
        {
            mon = this.create_monster_byconf(monconf);
            if (mon == null)
            {
                Utility.trace_err("Err: in map [" + this.mapid + "] add_pet_mon mid [" + monconf.mid + "] create error!\n");
                return mon;
            }

            mon.gmap = this;

            mondata = mon.get_pack_data();
            this.map_mons[mondata.iid] = mon;
            this.map_sprites[mondata.iid] = mon;

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

        IMapUnit pl = ply.get_pack_data();
        var ply_grid = this.get_grid_by_pt(pl.x, pl.y);
        mondata.org_init_x = (int)ply_grid.x;
        mondata.org_init_y = (int)ply_grid.y;
        mon.owner_ply = ply;
        mondata.owner_cid = pl.cid;
        mon.respawn(100, false);

        //var dest_pos = line_find_canwalk_grid(ply_grid.x, ply_grid.y, 3, 9);
        //mon._move_to(dest_pos.x, dest_pos.y);

        return mon;
    }
Exemple #3
0
    public game_err_code add_monster_to_map(map_mon_conf amconf)
    {
        var m = this.create_monster_byconf(amconf);
        if (m == null)
        {
            //Utility.trace_err("Err: in map [" + mapid +"] add_monster_to_map mid ["+amconf.mid+"] create error!\n");
            return game_err_code.PARAMETER_ERR;
        }

        if (amconf.sideid > 0)
        {
            m.get_pack_data().lvlsideid = amconf.sideid;
        }

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

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

        if (!this.map_mon_bymid.ContainsKey(mondata.mid))

        {
            this.map_mon_bymid[mondata.mid] = new List<IBaseUnit>() { m };
        }
        else
        {
            this.map_mon_bymid[mondata.mid].push(m);
        }

        return game_err_code.RES_OK;
    }
Exemple #4
0
    public IBaseUnit create_monster_byconf(map_mon_conf conf)
    {
        monsterconf mon_conf = Utility.get_monster_conf(conf.mid);
        if (null == mon_conf)
            throw new Exception("monsterconf not found for mid:" + conf.mid);

        Monster mon = new Monster(mon_conf);

        mon.set_location(conf.x, conf.y);
        mon.set_origin_location(conf.r_x, conf.r_y);
        mon.set_lvlside(conf.sideid);
        if (conf.spwan_time > 0)
            mon.set_conf_respawn_tm(conf.spwan_time);

        return mon;
    }