更改

删除8字节 、 2021年6月9日 (三) 11:59
无编辑摘要
第13行: 第13行:  
 物品 代表那些能够放在背包里的东西,比如说工具、农作物等等。
 
 物品 代表那些能够放在背包里的东西,比如说工具、农作物等等。
   −
===创建一个物品的实例 (类型:Object)===
+
===创建一个物品的实例(Object)===
 
Object中所有的构造函数:
 
Object中所有的构造函数:
   −
<syntaxhightlight lang="c#">
+
<syntaxhighlight lang="c#">
 
  public Object(Vector2 tileLocation, int parentSheetIndex, int initialStack);
 
  public Object(Vector2 tileLocation, int parentSheetIndex, int initialStack);
 
  public Object(Vector2 tileLocation, int parentSheetIndex, bool isRecipe = false);
 
  public Object(Vector2 tileLocation, int parentSheetIndex, bool isRecipe = false);
第26行: 第26行:     
===在地上生成物品===
 
===在地上生成物品===
<syntaxhightlight lang="c#">
+
<syntaxhighlight lang="c#">
 
public virtual bool dropObject(Object obj, Vector2 dropLocation, xTile.Dimensions.Rectangle viewport, bool initialPlacement, Farmer who = null);
 
public virtual bool dropObject(Object obj, Vector2 dropLocation, xTile.Dimensions.Rectangle viewport, bool initialPlacement, Farmer who = null);
   第34行: 第34行:     
===添加物品到背包===
 
===添加物品到背包===
<syntaxhightlight lang="c#">
+
<syntaxhighlight lang="c#">
 
// You can add items found in ObjectInformation using:
 
// You can add items found in ObjectInformation using:
 
    Game1.player.addItemByMenuIfNecessary((Item)new StardewValley.Object(int parentSheetIndex, int initialStack, [bool isRecipe = false], [int price = -1], [int quality = 0]));
 
    Game1.player.addItemByMenuIfNecessary((Item)new StardewValley.Object(int parentSheetIndex, int initialStack, [bool isRecipe = false], [int price = -1], [int quality = 0]));
 
</syntaxhightlight>
 
</syntaxhightlight>
 
 例2:
 
 例2:
<syntaxhightlight lang="c#">
+
<syntaxhighlight lang="c#">
 
// Add a weapon directly into player's inventory
 
// Add a weapon directly into player's inventory
 
    const int WEAP_ID = 19;          // Shadow Dagger -- see Data/weapons
 
    const int WEAP_ID = 19;          // Shadow Dagger -- see Data/weapons
第53行: 第53行:  
 在大多数情况下,仅需调用 .removeItemFromInventory(Item) 方法。
 
 在大多数情况下,仅需调用 .removeItemFromInventory(Item) 方法。
   −
==地点==
+
==地点(Locations)==
 
 见 [[模组:制作指南/游戏基本架构#地点|游戏基本架构#地点]]。
 
 见 [[模组:制作指南/游戏基本架构#地点|游戏基本架构#地点]]。
    
==获取所有地点==
 
==获取所有地点==
 
<tt>Game1.locations</tt>属性中储存着主要的地点,但是不包括建筑的室内。以下这个方法提供了主玩家的所有地点。
 
<tt>Game1.locations</tt>属性中储存着主要的地点,但是不包括建筑的室内。以下这个方法提供了主玩家的所有地点。
<syntaxhightlight lang="c#">
+
<syntaxhighlight lang="c#">
 
/// <summary>Get all game locations.</summary>
 
/// <summary>Get all game locations.</summary>
 
public static IEnumerable<GameLocation> GetLocations()
 
public static IEnumerable<GameLocation> GetLocations()
第73行: 第73行:     
 遍历:
 
 遍历:
<syntaxhightlight lang="c#">
+
<syntaxhighlight lang="c#">
 
foreach (GameLocation location in this.GetLocations())
 
foreach (GameLocation location in this.GetLocations())
 
{
 
{
50

个编辑