更改

添加1,914字节 、 2021年6月9日 (三) 14:19
无编辑摘要
第33行: 第33行:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
===添加物品到背包===
+
===添加物品到背包 (Inventory)===
 
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
 
// You can add items found in ObjectInformation using:
 
// You can add items found in ObjectInformation using:
第53行: 第53行:  
 在大多数情况下,仅需调用 .removeItemFromInventory(Item) 方法。
 
 在大多数情况下,仅需调用 .removeItemFromInventory(Item) 方法。
   −
==地点(Locations)==
+
==地点 (Locations)==
 
 见 [[模组:制作指南/游戏基本架构#地点|游戏基本架构#地点]]。
 
 见 [[模组:制作指南/游戏基本架构#地点|游戏基本架构#地点]]。
    
===获取所有地点===
 
===获取所有地点===
<tt>Game1.locations</tt>属性中储存着主要的地点,但是不包括建筑的室内。以下这个方法提供了主玩家的所有地点。
+
<tt>Game1.locations</tt>属性中 虽然 储存着主要的地点,但是不包括'' 建筑的室内''(constructed building interiors) 。以下这个方法提供了主玩家的所有地点。
 
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
 
/// <summary>Get all game locations.</summary>
 
/// <summary>Get all game locations.</summary>
第80行: 第80行:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
 注意:联机中客机是拿不到所有地点的。见[[模组:制作指南/APIs/Multiplayer#Get active locations|获取有效的地点]]。
+
 注意: 联机 模式 客机是拿不到 上述 所有地点的。 要解决这一问题, 见[[模组:制作指南/APIs/Multiplayer#Get active locations|获取有效的地点]]。
 +
 
 +
===编辑地图===
 +
见[[模组:地图数据]]。
 +
 
 +
==玩家 (Player)==
 +
===自定义精灵 (Custom Sprite)===
 +
 
 +
===位置 (Position)===
 +
角色(Character) 的位置(Position) 表示他在当前地点(Location) 的坐标。
 +
====相对于地图 (Map)====
 +
每个地点(location) 都有一个对应的xTile地图(map)。如果以像素(pixel) 为单位,地图左上角坐标代表''(0, 0)'',坐下角则代表<tt>(location.Map.DisplayWidth, location.Map.DisplayHeight)</tt>。
 +
角色在当前地点的位置有两种表达方式:
 +
* 以像素(pixel) 为单位的绝对(absoulte) 坐标:<code>Position.X</code>与<code>Position.Y</code>。
 +
* 以图块(tile) 为单位的图块(tile) 坐标:<code>getTileX()</code>与<code>getTileY()</code>。
 +
 
 +
常量<code>Game1.tileSize</code>规定,游戏内每个图块(tile) 大小为64x64像素。于是有以下单位换算:
 +
<syntaxhighlight lang='c#'>
 +
// 绝对坐标 → 图块坐标
 +
Math.Floor(Game1.player.Position.X / Game1.tileSize)
 +
Math.Floor(Game1.player.Position.Y / Game1.tileSize)
 +
 
 +
// 图块坐标 → 绝对坐标
 +
Game1.player.getTileX() * Game1.tileSize
 +
Game1.player.getTileY() * Game1.tileSize
 +
 
 +
// 地图大小(以图块为单位)
 +
Math.Floor(Game1.player.currentLocation.Map.DisplayWidth / Game1.tileSize)
 +
Math.Floor(Game1.player.currentLocation.Map.DisplayHeight / Game1.tileSize)
 +
</syntaxhighlight>
 +
 
 +
====相对于视野 (Viewport)====
 +
视野、视口、视窗(Viewport) 代表在当前屏幕上的区域。若以像素计算,其宽高应该与游戏的屏幕分辨率相等,分别为<code>Game1.viewport.Width</code>和<code>Game1.viewport.Height</code>。
 +
 
 +
玩家相对于视野的位置(像素)可表示为:
 +
<syntaxhighlight lang='c#'>
 +
Game1.player.Position.X - Game1.viewport.X
 +
Game1.player.Position.Y - Game1.viewport.Y
 +
</syntaxhighlight>
50

个编辑