本文整理汇总了C#中TShockAPI.TSPlayer.Teleport方法的典型用法代码示例。如果您正苦于以下问题:C# TSPlayer.Teleport方法的具体用法?C# TSPlayer.Teleport怎么用?C# TSPlayer.Teleport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TShockAPI.TSPlayer
的用法示例。
在下文中一共展示了TSPlayer.Teleport方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePlayerSpawn
public virtual bool HandlePlayerSpawn(TSPlayer player, DPoint spawnTileLocation)
{
if (this.IsDisposed)
return false;
bool isBedSpawn = (spawnTileLocation.X != -1 || spawnTileLocation.Y != -1);
RemoteClient client = Netplay.Clients[player.Index];
if (!isBedSpawn || client.State <= 3)
return false;
DPoint bedTileLocation = new DPoint(spawnTileLocation.X, spawnTileLocation.Y - 1);
Tile spawnTile = TerrariaUtils.Tiles[bedTileLocation];
bool isInvalidBedSpawn = (!spawnTile.active() || spawnTile.type != TileID.Beds);
bool allowNewSpawnSet = true;
if (isInvalidBedSpawn) {
player.Teleport(Main.spawnTileX * TerrariaUtils.TileSize, (Main.spawnTileY - 3) * TerrariaUtils.TileSize);
this.PluginTrace.WriteLineWarning($"Player \"{player.Name}\" tried to spawn on an invalid location.");
allowNewSpawnSet = false;
} else if (this.Config.EnableBedSpawnProtection) {
if (this.CheckProtected(player, bedTileLocation, false)) {
player.SendErrorMessage("The bed you have set spawn at is protected, you can not spawn there.");
player.SendErrorMessage("You were transported to your last valid spawn location instead.");
if (player.TPlayer.SpawnX == -1 && player.TPlayer.SpawnY == -1)
player.Teleport(Main.spawnTileX * TerrariaUtils.TileSize, (Main.spawnTileY - 3) * TerrariaUtils.TileSize);
else
player.Teleport(player.TPlayer.SpawnX * TerrariaUtils.TileSize, (player.TPlayer.SpawnY - 3) * TerrariaUtils.TileSize);
allowNewSpawnSet = false;
}
}
if (allowNewSpawnSet) {
player.TPlayer.SpawnX = spawnTileLocation.X;
player.TPlayer.SpawnY = spawnTileLocation.Y;
player.sX = spawnTileLocation.X;
player.sY = spawnTileLocation.X;
}
player.TPlayer.Spawn();
NetMessage.SendData(12, -1, player.Index, string.Empty, player.Index);
player.Dead = false;
return true;
}
示例2: Update
public void Update(TSPlayer player)
{
if ((DateTime.Now - lastDisabled).TotalSeconds > 10)
{
disabled = false;
lastDisabled = DateTime.Now;
}
bool bypassFlag = BypassFlag(player);
bool warning = ((DateTime.Now - lastWarned).TotalSeconds > 1);
if (regionStorage.flags.Contains("HEAL"))
{
if (regionStorage.healinterval < 0 || regionStorage.healamount < 0)
return;
if ((DateTime.Now - lastHealUpdate).TotalSeconds >= regionStorage.healinterval)
{
lastHealUpdate = DateTime.Now;
player.Heal(regionStorage.healamount);
}
}
if (regionStorage.flags.Contains("MANA"))
{
if (regionStorage.manainterval < 0 || regionStorage.healamount < 0)
return;
if ((DateTime.Now - lastManaUpdate).TotalSeconds >= regionStorage.manainterval)
{
lastManaUpdate = DateTime.Now;
var matches = TShock.Utils.GetItemByIdOrName("184");
Item star = matches[0];
player.GiveItem(star.netID, star.name, star.width, star.height, regionStorage.healamount);
}
}
if (regionStorage.flags.Contains("PRIVATE") && !bypassFlag)
{
if (!gotWarnMessage)
{
player.Teleport(lastPos.X, lastPos.Y, 1);
player.SendErrorMessage("No permission to enter private region!");
gotWarnMessage = true;
}
}
if (regionStorage.flags.Contains("PVP") && !bypassFlag)
{
if (!player.TPlayer.hostile)
{
player.SendSuccessMessage("PVP arena entered, pvp enabled.");
player.TPlayer.hostile = true;
NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
}
}
if (regionStorage.flags.Contains("NOPVP") && !bypassFlag)
{
if (player.TPlayer.hostile)
{
player.SendSuccessMessage("PVP arena entered, pvp disabled.");
player.TPlayer.hostile = false;
NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index);
}
}
if (regionStorage.flags.Contains("TEMPGROUP") && !bypassFlag)
{
if (!groupset)
{
player.tempGroup = regionStorage.tempgroup;
player.SendSuccessMessage("Your group has been temporarily set to \"{0}\"!", regionStorage.tempgroup.Name);
groupset = true;
}
}
if (regionStorage.flags.Contains("DEATH") && !bypassFlag)
{
if (!killed)
{
player.DamagePlayer(1200);
player.SendErrorMessage("You entered a death zone! RIP");
killed = true;
}
}
if (regionStorage.flags.Contains("HURT") && !bypassFlag)
{
if (regionStorage.damageinterval < 0 || regionStorage.damageamount< 0)
return;
if ((DateTime.Now - lastDamageUpdate).TotalSeconds >= regionStorage.damageinterval)
{
lastDamageUpdate = DateTime.Now;
player.DamagePlayer(regionStorage.damageamount);
}
}
if (regionStorage.flags.Contains("COMMAND") && !bypassFlag)
{
if (!executedcommand)
{
if (regionStorage.command != null && regionStorage.command != "")
{
Commands.HandleCommand(TSPlayer.Server, "/" + regionStorage.command);
executedcommand = true;
}
}
}
if (regionStorage.flags.Contains("PROMOTE") && !bypassFlag)
//.........这里部分代码省略.........
示例3: HandlePlayerSpawn
public virtual bool HandlePlayerSpawn(TSPlayer player, DPoint spawnTileLocation)
{
if (this.IsDisposed)
return false;
if (this.Config.EnableBedSpawnProtection) {
DPoint bedTileLocation = new DPoint(spawnTileLocation.X, spawnTileLocation.Y - 1);
Tile spawnTile = TerrariaUtils.Tiles[bedTileLocation];
if (!spawnTile.active() || spawnTile.type != (int)BlockType.Bed)
return false;
if (this.CheckProtected(player, bedTileLocation, false)) {
player.SendErrorMessage("The bed you have set spawn at is protected, you can not spawn there.");
player.SendErrorMessage("You were transported to your last valid spawn location instead.");
if (player.TPlayer.SpawnX == -1 && player.TPlayer.SpawnY == -1)
player.Teleport(Main.spawnTileX * TerrariaUtils.TileSize, (Main.spawnTileY - 3) * TerrariaUtils.TileSize);
else
player.Teleport(player.TPlayer.SpawnX * TerrariaUtils.TileSize, (player.TPlayer.SpawnY - 3) * TerrariaUtils.TileSize);
return true;
}
}
return false;
}
示例4: DoCommand
//.........这里部分代码省略.........
doplay.toldperm = 5;
}
else if (doplay.toldcool <= 0 && smob && (!nocool && (!getConfig.GlobalSpawnMobCooldown && doplay.CooldownSpawnMob > 0)) &&
(cmd.StartsWith("spawn mob ") || cmd.StartsWith("spawnmob ") || cmd.StartsWith("spawn ")))
{
tplayer.SendMessage("You have to wait another " + doplay.CooldownSpawnMob + " seconds before using this sign", Color.IndianRed);
doplay.toldcool = 5;
}
else if (doplay.toldcool <= 0 && smob && (!nocool && (getConfig.GlobalSpawnMobCooldown && GlobalSpawnMobCooldown > 0)) &&
(cmd.StartsWith("spawn mob ") || cmd.StartsWith("spawnmob ") || cmd.StartsWith("spawn ")))
{
tplayer.SendMessage("Everyone has to wait another " + GlobalSpawnMobCooldown + " seconds before using this sign", Color.IndianRed);
doplay.toldcool = 5;
}
#endregion
#region Warp
if (swarp && cmd.StartsWith("warp "))
{
try
{
string[] linesplit = cmd.Split('\'', '\"');
var warpxy = TShock.Warps.FindWarp(linesplit[1]);
if (warpxy.WarpName == "" || warpxy.WarpPos.X == 0 || warpxy.WarpPos.Y == 0 || warpxy.WorldWarpID == "")
{
if (doplay.toldalert <= 0)
{
doplay.toldalert = 3;
tplayer.SendMessage("Could not find warp!", Color.IndianRed);
}
}
else
tplayer.Teleport((int)warpxy.WarpPos.X, (int)warpxy.WarpPos.Y);
}
catch (Exception)
{
if (doplay.toldalert <= 0)
{
doplay.toldalert = 3;
tplayer.SendMessage("Could not parse Warp - Correct Format: \"<Warp Name>\"", Color.IndianRed);
}
}
}
else if (doplay.toldperm <= 0 && !swarp && cmd.StartsWith("warp "))
{
tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed);
doplay.toldperm = 5;
}
#endregion
#region Item
if (cmd.StartsWith("item ") && sitem && (nocool || doplay.CooldownItem <= 0))
{
try
{
string[] linesplit = cmd.Split('\'', '\"');
bool containsamount = false;
string[] datasplit;
if (linesplit[1].Contains(","))
{
datasplit = linesplit[1].Split(',');
containsamount = true;
}
else