本文整理汇总了C#中IPlayer.GetMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# IPlayer.GetMetadata方法的具体用法?C# IPlayer.GetMetadata怎么用?C# IPlayer.GetMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPlayer
的用法示例。
在下文中一共展示了IPlayer.GetMetadata方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public static HousePlayer Get(IPlayer player)
{
if (player.HasMetadata("HousePlayer"))
return player.GetMetadata("HousePlayer") as HousePlayer;
HousePlayer housePlayer = new HousePlayer(player);
player.SetMetadata("HousePlayer", housePlayer);
return housePlayer;
}
示例2: DigBlock
private void DigBlock(int x, int y, IPlayer player, float digStrength, bool mining, bool explosion = false)
{
if (digHardness == null)
resetDigHardness();
if (!(x > 0 && y > 0 && x < bot.Room.Width && y < bot.Room.Height))
return;
if (digHardness[x, y] <= 0)
return;
IBlock block = bot.Room.getBlock(0, x, y);
int blockId = -1;
float blockXp = 0;
DigPlayer digPlayer = null;
if (player != null)
{
if (!player.HasMetadata("digplayer"))
player.SetMetadata("digplayer", new DigPlayer(player));
digPlayer = (DigPlayer)player.GetMetadata("digplayer");
}
if (mining)
{
InventoryItem temp = ItemManager.GetItemFromOreId(block.Id);
if (temp != null)
{
Ore ore = ItemManager.GetOreByName(temp.Name);
blockId = 414;
if (digPlayer.digLevel >= Convert.ToInt32(ore.LevelRequired))
{
if (digHardness[x, y] <= digStrength)
{
digHardness[x, y] = 0F;
InventoryItem newsak = new InventoryItem(temp);
digPlayer.Inventory.AddItem(newsak, 1);
int oldLevel = digPlayer.digLevel;
digPlayer.digXp += Convert.ToInt32(ore.XPGain);
int newLevel = digPlayer.digLevel;
if (newLevel > oldLevel)
player.Reply("You have leveled up to level " + newLevel + "!");
}
}
else
{
return;
}
}
}
if (explosion)
blockId = 414;
switch (block.Id)
{
case BlockIds.Blocks.Sand.BROWN:
blockId = 414;
blockXp = 0.08f;
break;
case BlockIds.Blocks.Sand.GRAY:
blockId = 414;
blockXp = 0.1f;
break;
case 1022: // gray bricks
blockId = 414;
blockXp = 0.2f;
break;
case BlockIds.Blocks.JungleRuins.BLUE:
blockId = BlockIds.Action.Liquids.WATER;
blockXp = 0.1f;
break;
case 21:
blockId = 369; //BlockIds.Action.Liquids.MUD;
blockXp = 0.1f;
break;
default:
if (blockId == -1)
return;
else
break;
}
digHardness[x, y] -= digStrength;
if (digHardness[x, y] <= 0)
{
digHardness[x, y] = 0f;
bot.Room.setBlock(x, y, new NormalBlock(blockId));
//.........这里部分代码省略.........
示例3: CanBuy
public bool CanBuy(IPlayer player)
{
//MasterDig.DigPlayer digPlayer = MasterDig.DigPlayer.FromPlayer(player);
IInventoryContainer inventoryPlayer = (IInventoryContainer)player.GetMetadata("digplayer");
// Check if we can buy the house.
foreach (var pair in cost)
{
if (inventoryPlayer.Inventory.GetItemCount(pair.Key) < pair.Value)
{
player.Reply("You don't have enough resources to build " + this.name + ".");
PrintCost(player, inventoryPlayer.Inventory);
return false;
}
}
return true;
}
示例4: Buy
public bool Buy(IPlayer player)
{
//int cost = houseType.Cost; ?
IInventoryContainer inventoryPlayer = (IInventoryContainer)player.GetMetadata("digplayer");
if (!CanBuy(player))
return false;
// Buy it.
foreach (var pair in cost)
{
inventoryPlayer.Inventory.RemoveItem(pair.Key, pair.Value);
}
return true;
}
示例5: EndRecord
private void EndRecord(IPlayer player)
{
List<IEditChange> record = (List<IEditChange>)recordingPlayer.GetMetadata("worldeditrecord");
if (record.Count > 0)
{
if (!player.HasMetadata("worldedithistory"))
player.SetMetadata("worldedithistory", new List<IEditChange>());
List<IEditChange> history = (List<IEditChange>)player.GetMetadata("worldedithistory");
history.Add(new EditChangeList((List<IEditChange>)record));
if (!player.HasMetadata("worldedithistoryindex"))
player.SetMetadata("worldedithistoryindex", 0);
else
player.SetMetadata("worldedithistoryindex", ((int)player.GetMetadata("worldedithistoryindex")) + 1);
}
player.RemoveMetadata("worldeditrecord");
recordingPlayer = null;
}
示例6: FromPlayer
public static DigPlayer FromPlayer(IPlayer player)
{
if (!player.HasMetadata("digplayer"))
player.SetMetadata("digplayer", new DigPlayer(player));
return (DigPlayer)player.GetMetadata("digplayer");
}
示例7: getPlayerData
private GodRunPlayer getPlayerData(IPlayer player)
{
if (!player.HasMetadata("GodRunPlayer"))
player.SetMetadata("GodRunPlayer", new GodRunPlayer(player));
return player.GetMetadata("GodRunPlayer") as GodRunPlayer;
}