- 为铁球、陶瓷球和木球制作风格化材质,归档 CC0 原始参考 - 更新方形球洞和实心滑槽,统一 90° 弯槽并兼容旧存档 - 用顺流泡沫表示水流方向,为冰块制作三种交错的裂纹 - 同步 Blender 源资产、Godot 加载、工坊和试玩预览
72 lines
4.3 KiB
Python
72 lines
4.3 KiB
Python
"""Author the five teaching maps; only data, never asset geometry or physics."""
|
|
import json
|
|
from collections import Counter
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
ELEVATION = 2.0 # Leave visible open space beneath every route block.
|
|
|
|
|
|
def piece(kind, x, y, z=0, q=0):
|
|
return dict(kind=kind, position=[x, y, z], quarter=q)
|
|
|
|
|
|
def make(index, title, objective, hint, route, editable, goal, stop, defaults=None,
|
|
extra_inventory=None):
|
|
fixed, solution, entities = [], [], []
|
|
for i, item in enumerate(route):
|
|
item = dict(item, id=f"route_{i}")
|
|
if i in editable:
|
|
item['id'] = f"built_{len(solution)}"
|
|
solution.append(item)
|
|
else:
|
|
fixed.append(item)
|
|
entities += [dict(id='goal', kind='goal_hole', position=goal, quarter=0),
|
|
dict(id='stop', kind='wall', position=stop, quarter=0)]
|
|
# Launch from the real +5 m/s top-contact mechanism, not an authored velocity.
|
|
first = route[0]['position']
|
|
launcher = dict(id='launcher', kind='directional_boost',
|
|
position=[first[0]-1, first[1], first[2]], quarter=0)
|
|
entities.append(launcher)
|
|
for record in fixed + solution + entities:
|
|
record['position'] = [record['position'][0], record['position'][1]+ELEVATION,
|
|
record['position'][2]]
|
|
initial = dict(schemaVersion=2, assetFamily='railbound_inspired', title=title,
|
|
pieces=fixed, entities=entities, balls=[])
|
|
inventory = dict(Counter(p['kind'] for p in solution))
|
|
inventory.update(extra_inventory or {})
|
|
data = dict(number=index, title=title, objective=objective, hint=hint,
|
|
initial=initial, spawn=dict(entityId='launcher', localX=-.15),
|
|
inventory=inventory, defaults=defaults or {},
|
|
solution=f"res://playtest/tutorial/solutions/{index:02d}.json")
|
|
(ROOT/'data'/f'{index:02d}.json').write_text(json.dumps(data, ensure_ascii=False, indent=2)+'\n')
|
|
(ROOT/'solutions'/f'{index:02d}.json').write_text(json.dumps(solution, ensure_ascii=False, indent=2)+'\n')
|
|
|
|
|
|
make(1, '接上第一条路', '接上悬空的缓坡与直槽,把加速后的球引入洞口。',
|
|
'起点箭头方块会给球初速度。缓坡负责衔接落差,低端接直槽;从已有轨道或洞口旁开始搭建。',
|
|
[piece('straight',-2,1.5),piece('straight',-1,1.5),piece('gentle',0,1.5,q=2),piece('straight',1,1),piece('straight',2,1)],
|
|
[2,3],[3,1.68,0],[4,1,0],{'gentle':2})
|
|
make(2, '在路口转弯', '用一块 90°弯槽,让球转向侧面的洞口。',
|
|
'90°弯槽连接相邻两侧。看清固定路线和洞口的位置,再点缩略图可旋转朝向。',
|
|
[piece('straight',-2,1),piece('straight',-1,1),piece('turn_90',0,1),
|
|
piece('straight',0,1,1,1),piece('straight',0,1,2,1)],
|
|
[2,3],[0,1.68,3],[0,1,4],{'straight':1})
|
|
make(3, '旋转,接通折线', '用同一种弯槽的不同朝向,搭出两次转弯。',
|
|
'再点当前缩略图,每次顺时针转 90°,然后点格子放置;直槽也需要对准方向。擦除工具可回收摆错的滑槽。',
|
|
[piece('straight',-2,1),piece('straight',-1,1),piece('turn_90',0,1,0,1),
|
|
piece('straight',0,1,-1,1),piece('turn_90',0,1,-2,3),piece('straight',1,1,-2)],
|
|
[2,3,4,5],[2,1.68,-2],[3,1,-2])
|
|
make(4, '读懂两种坡度', '按接口高度搭配缓坡与急坡,接通两级落差。',
|
|
'缓坡两端相差 0.5 m,急坡相差 1 m。看槽口高度,不只看方块底面;高端朝来球方向。',
|
|
[piece('straight',-2,2.5),piece('straight',-1,2.5),piece('gentle',0,2.5,q=2),
|
|
piece('straight',1,2),piece('steep',2,1.5,q=2),piece('straight',3,1),piece('straight',4,1)],
|
|
[2,3,4,5],[5,1.68,0],[6,1,0])
|
|
make(5, '山间长路', '综合直行、转弯、旋转与两种坡度,独立搭完路线。',
|
|
'先规划转弯,再核对两个坡段的高低端。可从已有滑槽或洞口旁向外铺设,留意库存和终点方向。',
|
|
[piece('straight',-3,2),piece('straight',-2,2),piece('straight',-1,2),
|
|
piece('turn_90',0,2,q=1),piece('straight',0,2,-1,1),piece('turn_90',0,2,-2,3),
|
|
piece('gentle',1,2,-2,2),piece('straight',2,1.5,-2),piece('steep',3,1,-2,2),
|
|
piece('straight',4,.5,-2),piece('turn_90',5,.5,-2),piece('straight',5,.5,-1,1)],
|
|
list(range(2,12)),[5,1.18,0],[5,.5,1])
|