本文整理汇总了C#中Zone.AddEntity方法的典型用法代码示例。如果您正苦于以下问题:C# Zone.AddEntity方法的具体用法?C# Zone.AddEntity怎么用?C# Zone.AddEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zone
的用法示例。
在下文中一共展示了Zone.AddEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SwitchToZoneAndPosition
/// <summary>
/// Switches a player from their current zone to one specified.
/// </summary>
/// <param name="player"></param>
/// <param name="zone">The zone to switch the player into</param>
/// <param name="position"></param>
public void SwitchToZoneAndPosition(Player player, Zone zone, Vector2 position)
{
if(zone == null)
throw new ArgumentNullException("The zone cannot be null");
// Remove our player from here
player.Zone.RemoveEntity(player);
// Add them to the new zone and move them
player.Position = position;
zone.AddEntity(player);
}
示例2: MoveEntity
public void MoveEntity(Entity entity, Zone newZone)
{
lock (zoneMngrLock)
{
if (entity_lookup.ContainsKey(entity.Id))
{
Zone z = entity_lookup[entity.Id];
if (z != newZone)
{
z.RemoveEntity(entity);
newZone.AddEntity(entity);
entity.Zone = newZone.Id;
entity_lookup[entity.Id] = newZone;
}
}
else
{
newZone.AddEntity(entity);
entity.Zone = newZone.Id;
entity_lookup.Add(entity.Id, newZone);
}
}
}