本文整理汇总了C#中NPC.Spawn方法的典型用法代码示例。如果您正苦于以下问题:C# NPC.Spawn方法的具体用法?C# NPC.Spawn怎么用?C# NPC.Spawn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPC
的用法示例。
在下文中一共展示了NPC.Spawn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpawnWolf
private void SpawnWolf(int regionId, Random rnd)
{
var pos = Center.GetRandomInRect(6000, 4000, rnd);
// Spawn wolf on random position and respawn it if it dies.
var npc = new NPC(20001); // Gray Wolf
npc.Death += (killed, killer) =>
{
SpawnWolf(regionId, rnd);
};
npc.Spawn(regionId, pos.X, pos.Y);
}
示例2: CreateRegionAndWarp
public void CreateRegionAndWarp(Creature creature)
{
var region = new DynamicRegion(118);
ChannelServer.Instance.World.AddRegion(region);
var rnd = RandomProvider.Get();
var sheepAmount = SheepAmount;
// After x ms (success)
var timer = SetTimeout(Time, () =>
{
// Unofficial, I think the msg also depends on how well you did.
Send.Notice(creature, NoticeType.MiddleSystem, L("The time is over, you did it."));
Send.RemoveQuestTimer(creature);
creature.Keywords.Give("TirChonaill_Tutorial_Thinking");
creature.Warp(1, 27622, 42125);
});
// Spawn sheep
for (int i = 0; i < sheepAmount; ++i)
{
var pos = Center.GetRandomInRect(6000, 4000, rnd);
var npc = new NPC(40001); // Sheep
npc.Death += (killed, killer) =>
{
sheepAmount--;
// Cancel if success is not possible anymore.
if (sheepAmount < SheepMinAmount)
{
Send.Notice(creature, NoticeType.MiddleSystem, L("You've failed to save the sheep."));
Send.RemoveQuestTimer(creature);
StopTimer(timer);
creature.Warp(1, 27622, 42125);
return;
}
Send.UpdateQuestTimerCounter(creature, L("Remaining sheep: {0}"), sheepAmount);
};
npc.Spawn(region.Id, pos.X, pos.Y);
}
// Spawn wolves
for (int i = 0; i < WolfAmount; ++i)
SpawnWolf(region.Id, rnd);
// Warp to region and start visible timer
creature.Warp(region.Id, 60000, 58000);
Send.SetQuestTimer(creature, Time, L("Protect the sheep from wolves"), L("Deadline: {0}"), L("Remaining sheep: {0}"), sheepAmount);
}
示例3: SpawnMinion
protected Creature SpawnMinion(int raceId, int xOffset, int yOffset)
{
var regionId = Spawn.Location.RegionId;
var x = Spawn.Location.X + xOffset;
var y = Spawn.Location.Y + yOffset;
var npc = new NPC(raceId);
npc.Death += this.OnMinionDied;
npc.Spawn(regionId, x, y);
Send.SpawnEffect(SpawnEffect.Monster, regionId, x, y, npc, npc);
lock (_syncLock)
_minions.Add(npc);
return npc;
}