作者laechan (小太保)
看板mud_sanc
标题[wizs] 关於地图产生器
时间Mon Aug 9 13:28:43 2010
belldandy 离开前写了这个东西的原案。
大抵上同一个区域的定义是「同一个目录」,这样就可以用
get_dir 来叫出一个有限制范围的 mixed rooms,令 rooms
是全域变数。
接着假定一个全域 mapping 为 area_map,以及一个处理房
间的函数 check_room ...
主函数()
{
string here_base_name,paths,files,room_file;
int i,j;
// 读出所在地的 base_name
here_base_name=base_name(environment(this_player()));
paths=get_path(here_base_name); // 读出目录
files=get_file(here_base_name); // 读出档名 (这两个函数是假定的)
rooms=get_dir(paths);
j=sizeof(rooms);
for(i=0;i<j;i++)
{
files=rooms[i];
if(strsrch(files,".c")>0)
{
files=substr(files,".c","");
rooms[i]=paths+files;
}
}
files=get_file(here_base_name); // 读出档名 get_path 跟 get_file 都是假定函数
check_room(paths,files,0,0);
}
check_room(string paths,string files,int a,int b)
{
mixed exits;
object room;
string room_file,tmp;
if(!catch(room=find_object_or_load(paths+files)))
{
room_file=base_name(room);
if(member_array(room_file,keys(area_map))==-1)
{
if(room->query("exits"))
{
exits=keys((mapping)room->query("exits"));
// 处理该房间的 area_map;
area_map[room_file]=process_area_map(exits,a,b);
foreach(tmp in exits)
{
if(member_array(room->query("exits/"+tmp),rooms)!=-1)
{
switch(tmp)
{
if(!area_map[tmp])
check_room(paths,get_file(tmp),a,b,
}
}
}
}
}
}
modify_area_map();
}
我想这个应该是可行的,下午我会在我自己的电脑写写看,
它的核心有四个..
一、递回写法
二、area_map 的资料格式
三、process_area_map 函数
四、modify_area_map 函数
不过依照 gps 的情况来看,这个程式我应该不会放在圣殿,
而是会放在我的电脑里。若程式写好了,我会贴出其执行结
果,当做建构论文模型前的 coding 暖身。
Laechan
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.117.3.82
1F:推 Layase1 :那麽快附身就结束了阿= = 08/09 13:57
2F:推 hmml :所以是QUAD! 08/09 19:51