本文整理匯總了C#中fCraft.Player.Send方法的典型用法代碼示例。如果您正苦於以下問題:C# Player.Send方法的具體用法?C# Player.Send怎麽用?C# Player.Send使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fCraft.Player
的用法示例。
在下文中一共展示了Player.Send方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GunMove
public static void GunMove( Player player )
{
World world = player.World;
if ( null == world )
return;
try {
if ( null == world.Map )
return;
if ( player.IsOnline ) {
Position p = player.Position;
double ksi = 2.0 * Math.PI * ( -player.Position.L ) / 256.0;
double phi = 2.0 * Math.PI * ( player.Position.R - 64 ) / 256.0;
double sphi = Math.Sin( phi );
double cphi = Math.Cos( phi );
double sksi = Math.Sin( ksi );
double cksi = Math.Cos( ksi );
if ( player.GunCache.Values.Count > 0 ) {
foreach ( Vector3I block in player.GunCache.Values ) {
if ( player.IsOnline ) {
player.Send( PacketWriter.MakeSetBlock( block.X, block.Y, block.Z, world.Map.GetBlock( block ) ) );
Vector3I removed;
player.GunCache.TryRemove( block.ToString(), out removed );
}
}
}
for ( int y = -1; y < 2; ++y ) {
for ( int z = -1; z < 2; ++z ) {
if ( player.IsOnline ) {
//4 is the distance betwen the player and the glass wall
Vector3I glassBlockPos = new Vector3I( ( int )( cphi * cksi * 4 - sphi * ( 0.5 + y ) - cphi * sksi * ( 0.5 + z ) ),
( int )( sphi * cksi * 4 + cphi * ( 0.5 + y ) - sphi * sksi * ( 0.5 + z ) ),
( int )( sksi * 4 + cksi * ( 0.5 + z ) ) );
glassBlockPos += p.ToBlockCoords();
if ( world.Map.GetBlock( glassBlockPos ) == Block.Air ) {
player.Send( PacketWriter.MakeSetBlock( glassBlockPos.X, glassBlockPos.Y, glassBlockPos.Z, Block.Glass ) );
player.GunCache.TryAdd( glassBlockPos.ToString(), glassBlockPos );
}
}
}
}
}
} catch ( Exception ex ) {
Logger.Log( LogType.SeriousError, "GunGlass: " + ex );
}
}
示例2: HitPlayer
//hitted? jonty I thought you were better than that :(
public void HitPlayer(World world, Vector3I pos, Player hitted, Player by, ref int restDistance, IList<BlockUpdate> updates)
{
//Capture the flag
if (by.Info.isPlayingCTF)
{
//Friendly fire
if ((hitted.Info.CTFBlueTeam && by.Info.CTFBlueTeam) || (hitted.Info.CTFRedTeam && by.Info.CTFRedTeam))
{
by.Message("{0} is on your team!", hitted.Name);
return;
}
if (hitted.Info.canDodge)
{
int dodgeChance = (new Random()).Next(0, 2);
if (dodgeChance == 0)
{
by.Message("{0} dodged your attack!", hitted.Name);
return;
}
}
//Take the hit, one in ten chance of a critical hit which does 50 damage instead of 25
int critical = (new Random()).Next(0, 9);
if (critical == 0)
{
if (by.Info.strengthened)//critical by a strengthened enemy instantly kills
{
hitted.Info.Health = 0;
}
else
{
hitted.Info.Health -= 50;
}
world.Players.Message("{0} landed a critical shot on {1}!", by.Name, hitted.Name);
}
else
{
if (by.Info.strengthened)
{
hitted.Info.Health -= 50;
}
else
{
hitted.Info.Health -= 25;
}
}
//Create epic ASCII Health Bar
string healthBar = "&f[&a--------&f]";
if (hitted.Info.Health == 75)
{
healthBar = "&f[&a------&8--&f]";
}
else if (hitted.Info.Health == 50)
{
healthBar = "&f[&e----&8----&f]";
}
else if (hitted.Info.Health == 25)
{
healthBar = "&f[&c--&8------&f]";
}
else if(hitted.Info.Health <= 0)
{
healthBar = "&f[&8--------&f]";
}
if (hitted.ClassiCube && Heartbeat.ClassiCube())
{
hitted.Send(PacketWriter.MakeSpecialMessage((byte)1, healthBar));
}
else
{
hitted.Message("You have " + hitted.Info.Health.ToString() + " health.");
}
//If the hit player's health is 0 or less, they die
if (hitted.Info.Health <= 0)
{
hitted.KillCTF(world, String.Format("&f{0}&S was shot by &f{1}", hitted.Name, by.Name));
CTF.PowerUp(by);
hitted.Info.CTFKills++;
if (hitted.Info.hasRedFlag)
{
world.Players.Message("The red flag has been returned.");
hitted.Info.hasRedFlag = false;
//Put flag back
BlockUpdate blockUpdate = new BlockUpdate(null, world.redFlag, Block.Red);
foreach (Player p in world.Players)
{
p.World.Map.QueueUpdate(blockUpdate);
}
world.redFlagTaken = false;
}
//.........這裏部分代碼省略.........
示例3: WeatherHandler
static void WeatherHandler(Player player, CommandReader cmd) {
if (cmd.Count == 1) {
player.Message(Cdweather.Usage);
return;
}
string name = cmd.Next();
PlayerInfo p = PlayerDB.FindPlayerInfoOrPrintMatches(player, name, SearchOptions.IncludeSelf);
if (p == null) {
return;
}
string valueText = cmd.Next();
byte weather;
if (!byte.TryParse(valueText, out weather)) {
if (valueText.Equals("sun", StringComparison.OrdinalIgnoreCase)) {
weather = 0;
} else if (valueText.Equals("rain", StringComparison.OrdinalIgnoreCase)) {
weather = 1;
} else if (valueText.Equals("snow", StringComparison.OrdinalIgnoreCase)) {
weather = 2;
}
}
if (weather < 0 || weather > 2) {
player.Message("Please use a valid integer(0,1,2) or string(sun,rain,snow)");
return;
}
if (p != player.Info) {
if (p.IsOnline) {
if (p.PlayerObject.Supports(CpeExtension.EnvWeatherType)) {
p.PlayerObject.Message("&a{0} set your weather to {1} ({2}&a)", player.Name, weather, weather == 0 ? "&sSun" : (weather == 1 ? "&1Rain" : "&fSnow"));
player.Message("&aSet weather for {0} to {1} ({2}&a)", p.Name, weather, weather == 0 ? "&sSun" : (weather == 1 ? "&1Rain" : "&fSnow"));
p.PlayerObject.Send(Packet.SetWeather((byte)weather));
} else {
player.Message("That player does not support WeatherType packet");
}
} else if (p.IsOnline == false || !player.CanSee(p.PlayerObject)) {
player.Message("That player is not online!");
}
} else {
if (player.Supports(CpeExtension.EnvWeatherType)) {
player.Message("&aSet weather to {0} ({1}&a)", weather, weather == 0 ? "&sSun" : (weather == 1 ? "&1Rain" : "&fSnow"));
player.Send(Packet.SetWeather((byte)weather));
} else {
player.Message("You don't support WeatherType packet");
}
}
}
示例4: ClickDistanceHandler
static void ClickDistanceHandler(Player player, CommandReader cmd) {
PlayerInfo otherPlayer = InfoCommands.FindPlayerInfo(player, cmd, cmd.Next() ?? player.Name);
if (otherPlayer == null) return;
if (!player.IsStaff && otherPlayer != player.Info) {
Rank staffRank = RankManager.GetMinRankWithAnyPermission(Permission.ReadStaffChat);
if (staffRank != null) {
player.Message("You must be {0}&s+ to change another players reach distance", staffRank.ClassyName);
} else {
player.Message("No ranks have the ReadStaffChat permission so no one can change other players reachdistance, yell at the owner.");
}
return;
}
if (otherPlayer.Rank.Index < player.Info.Rank.Index) {
player.Message("Cannot change the Reach Distance of someone higher rank than you.");
return;
}
string second = cmd.Next();
if (string.IsNullOrEmpty(second)) {
if (otherPlayer == player.Info) {
player.Message("Your current ReachDistance: {0} blocks [Units: {1}]", player.Info.ReachDistance / 32, player.Info.ReachDistance);
} else {
player.Message("Current ReachDistance for {2}: {0} blocks [Units: {1}]", otherPlayer.ReachDistance / 32, otherPlayer.ReachDistance, otherPlayer.Name);
}
return;
}
short distance;
if (!short.TryParse(second, out distance)) {
if (second != "reset") {
player.Message("Please try something inbetween 0 and 32767");
return;
} else {
distance = 160;
}
}
if (distance < 0 || distance > 32767) {
player.Message("Reach distance must be between 0 and 32767");
return;
}
if (distance != otherPlayer.ReachDistance) {
if (otherPlayer != player.Info) {
if (otherPlayer.IsOnline == true) {
if (otherPlayer.PlayerObject.Supports(CpeExtension.ClickDistance)) {
otherPlayer.PlayerObject.Message("{0} set your reach distance from {1} to {2} blocks [Units: {3}]", player.Name, otherPlayer.ReachDistance / 32, distance / 32, distance);
player.Message("Set reach distance for {0} from {1} to {2} blocks [Units: {3}]", otherPlayer.Name, otherPlayer.ReachDistance / 32, distance / 32, distance);
otherPlayer.ReachDistance = distance;
otherPlayer.PlayerObject.Send(Packet.MakeSetClickDistance(distance));
} else {
player.Message("This player does not support ReachDistance packet");
}
} else {
player.Message("Set reach distance for {0} from {1} to {2} blocks [Units: {3}]", otherPlayer.Name, otherPlayer.ReachDistance / 32, distance / 32, distance);
otherPlayer.ReachDistance = distance;
}
} else {
if (player.Supports(CpeExtension.ClickDistance)) {
player.Message("Set own reach distance from {0} to {1} blocks [Units: {2}]", player.Info.ReachDistance / 32, distance / 32, distance);
player.Info.ReachDistance = distance;
player.Send(Packet.MakeSetClickDistance(distance));
} else {
player.Message("You don't support ReachDistance packet");
}
}
} else {
if (otherPlayer != player.Info) {
player.Message("{0}'s reach distance is already set to {1}", otherPlayer.ClassyName, otherPlayer.ReachDistance);
} else {
player.Message("Your reach distance is already set to {0}", otherPlayer.ReachDistance);
}
return;
}
}
示例5: SetPlayerDead
private static void SetPlayerDead( Player player )
{
try {
if ( player.IsOnline ) {
player.Send( Packets.MakeTeleport( 255, new Position( player.World.Map.Spawn.X, player.World.Map.Spawn.Y, player.World.Map.Height - 1 ) ) );
StopWoMCrashBlocks( player );
player.Position = new Position( player.World.Map.Spawn.X, player.World.Map.Spawn.Y, player.World.Map.Spawn.Z + 1000 );
if ( !player.PublicAuxStateObjects.ContainsKey( "dead" ) ) {
player.PublicAuxStateObjects.Add( "dead", true );
int Seconds = 6 - GuildManager.PlayersGuild( player.Info ).DeadSaver;
player.Message( "You will respawn in {0} seconds", Seconds );
Scheduler.NewTask( t => SetPlayerNotDead( player ) ).RunOnce( TimeSpan.FromSeconds( Seconds ) );
}
}
} catch ( Exception e ) {
Logger.Log( LogType.Error, e.ToString() );
}
}
示例6: SendGlobalAdd
public static void SendGlobalAdd(Player p, BlockDefinition def) {
if (p.Supports(CpeExtension.BlockDefinitionsExt) && def.Shape != 0)
p.Send(Packet.MakeDefineBlockExt(def));
else
p.Send(Packet.MakeDefineBlock(def));
p.Send(Packet.MakeSetBlockPermission((Block)def.BlockID, true, true));
}
示例7: towerHandler
static void towerHandler(Player player, Command cmd)
{
string Param = cmd.Next();
if (Param == null)
{
if (player.towerMode)
{
player.towerMode = false;
player.Message("TowerMode has been turned off.");
return;
}
else
{
player.towerMode = true;
player.Message("TowerMode has been turned on. " +
"All Iron blocks are now being replaced with Towers.");
}
}
else if (Param.ToLower() == "remove")
{
if (player.TowerCache != null)
{
World world = player.World;
if (world.Map != null)
{
player.World.Map.QueueUpdate(new BlockUpdate(null, player.towerOrigin, Block.Air));
foreach (Vector3I block in player.TowerCache.Values)
{
if (world.Map != null)
{
player.Send(PacketWriter.MakeSetBlock(block, player.WorldMap.GetBlock(block)));
}
}
}
player.TowerCache.Clear();
return;
}
else
{
player.Message("&WThere is no Tower to remove");
}
}
else CdTower.PrintUsage(player);
}
示例8: GunHandler
public static void GunHandler(Player player, Command cmd)
{
if (player.GunMode)
{
player.GunMode = false;
try
{
foreach (Vector3I block in player.GunCache.Values)
{
player.Send(PacketWriter.MakeSetBlock(block.X, block.Y, block.Z, player.WorldMap.GetBlock(block)));
Vector3I removed;
player.GunCache.TryRemove(block.ToString(), out removed);
}
if (player.bluePortal.Count > 0)
{
int i = 0;
foreach (Vector3I block in player.bluePortal)
{
if (player.WorldMap != null && player.World.IsLoaded)
{
player.WorldMap.QueueUpdate(new BlockUpdate(null, block, player.blueOld[i]));
i++;
}
}
player.blueOld.Clear();
player.bluePortal.Clear();
}
if (player.orangePortal.Count > 0)
{
int i = 0;
foreach (Vector3I block in player.orangePortal)
{
if (player.WorldMap != null && player.World.IsLoaded)
{
player.WorldMap.QueueUpdate(new BlockUpdate(null, block, player.orangeOld[i]));
i++;
}
}
player.orangeOld.Clear();
player.orangePortal.Clear();
}
player.Message("&SGunMode deactivated");
}
catch (Exception ex)
{
Logger.Log(LogType.SeriousError, "" + ex);
}
}
else
{
if (!player.World.gunPhysics)
{
player.Message("&WGun physics are disabled on this world");
return;
}
player.GunMode = true;
GunGlassTimer timer = new GunGlassTimer(player);
timer.Start();
player.Message("&SGunMode activated. Fire at will!");
}
}
示例9: PrintCtfState
public static void PrintCtfState(Player player) {
if (player.IsPlayingCTF && player.Supports(CpeExtension.MessageType)) {
player.Send(Packet.Message((byte)MessageType.BottomRight1, ""));
string op = "&d<=>";
if (CTF.RedTeam.TotalScore > CTF.BlueTeam.TotalScore) {
op = "&S-->";
} else if (CTF.RedTeam.TotalScore < CTF.BlueTeam.TotalScore) {
op = "&S<--";
}
player.Message((byte)MessageType.BottomRight3, "{0}{1} &a{2}{0}:&f{3} {4} {5}{6} &a{7}{5}:&f{8}",
CTF.RedTeam.Color, CTF.RedTeam.Name, CTF.RedTeam.RoundsWon, CTF.RedTeam.Score, op,
CTF.BlueTeam.Color, CTF.BlueTeam.Name, CTF.BlueTeam.RoundsWon, CTF.BlueTeam.Score);
var flagholder = player.World.Players.Where(p => p.IsHoldingFlag);
if (flagholder.FirstOrDefault() == null) {
player.Send(Packet.Message((byte)MessageType.BottomRight2, "&sNo one has the flag!"));
} else if (CTF.RedTeam.HasFlag) {
player.Message((byte)MessageType.BottomRight2, "{0} &shas the {1}&s flag!",
flagholder.First().ClassyName, CTF.BlueTeam.ClassyName);
} else if (CTF.BlueTeam.HasFlag) {
player.Message((byte)MessageType.BottomRight2,"{0} &shas the {1}&s flag!",
flagholder.First().ClassyName, CTF.RedTeam.ClassyName);
}
if (player.Team != null) {
player.Send(Packet.Message((byte)MessageType.Status3,
"&sTeam: " + player.Team.ClassyName));
} else {
player.Send(Packet.Message((byte)MessageType.Status3, "&sTeam: &0None"));
}
}
if (player.IsPlayingCTF && player.Supports(CpeExtension.EnvColors)) {
string color = null;
if (CTF.RedTeam.Score > CTF.BlueTeam.Score) {
color = CTF.RedTeam.EnvColor;
} else if (CTF.BlueTeam.Score > CTF.RedTeam.Score) {
color = CTF.BlueTeam.EnvColor;
} else {
color = Mix(CTF.RedTeam.EnvColor, CTF.BlueTeam.EnvColor);
}
player.Send(Packet.MakeEnvSetColor((byte)EnvVariable.SkyColor, color));
player.Send(Packet.MakeEnvSetColor((byte)EnvVariable.FogColor, color));
}
}
示例10: RemovePlayerFromTeam
static void RemovePlayerFromTeam(Player p, CtfTeam opposingTeam) {
p.Team.Players.Remove(p);
p.Message("&SRemoving you from the game");
if (p.IsHoldingFlag) {
world.Players.Message("&cFlag holder " + p.ClassyName + " &cleft CTF, " +
"thus dropping the flag for the " + p.Team.ClassyName + " team!");
p.Team.HasFlag = false;
p.IsHoldingFlag = false;
world.Map.QueueUpdate(new BlockUpdate(Player.Console, opposingTeam.FlagPos,
opposingTeam.FlagBlock));
}
p.IsPlayingCTF = false;
p.Team = null;
if (p.Supports(CpeExtension.HeldBlock))
p.Send(Packet.MakeHoldThis(Block.Stone, false));
}
示例11: RemovePlayer
public static void RemovePlayer(Player player, World world) {
if (player.Supports(CpeExtension.MessageType))
player.Send(Packet.Message((byte)MessageType.Status3, ""));
if (BlueTeam.Has(player))
RemovePlayerFromTeam(player, RedTeam);
else if (RedTeam.Has(player))
RemovePlayerFromTeam(player, BlueTeam);
foreach (Player p in world.Players) {
if (!p.Supports(CpeExtension.ExtPlayerList) && !p.Supports(CpeExtension.ExtPlayerList2))
continue;
p.Send(Packet.MakeExtRemovePlayerName(player.NameID));
}
}
示例12: AddPlayerToTeam
static void AddPlayerToTeam(CtfTeam team, Player p) {
team.Players.Add(p);
p.Message("&SAdding you to the " + team.ClassyName + " team");
p.TeleportTo(team.Spawn);
p.Team = team;
p.IsPlayingCTF = true;
if (p.Supports(CpeExtension.HeldBlock))
p.Send(Packet.MakeHoldThis(Block.TNT, false));
}
示例13: chatHandler
static void chatHandler(Player player, CommandReader cmd)
{
byte type;
byte.TryParse(cmd.Next(), out type);
string message = cmd.NextAll();
player.Send(Packet.Message(type, message));
}
示例14: textHotKeyHandler
private static void textHotKeyHandler(Player player, CommandReader cmd) {
string Label = cmd.Next();
string Action = cmd.Next();
string third = cmd.Next();
string fourth = cmd.Next();
if (Label == null || Action == null || third == null || fourth == null) {
CdtextHotKey.PrintUsage(player);
return;
}
int KeyCode;
if (!int.TryParse(third, out KeyCode)) {
player.Message("Error: Invalid Integer ({0})", third);
return;
}
byte KeyMod = 0;
if (null != fourth) {
if (!Byte.TryParse(fourth, out KeyMod)) {
player.Message("Error: Invalid Byte ({0})", fourth);
return;
}
}
if (player.Supports(CpeExtension.TextHotKey)) {
player.Send(Packet.MakeSetTextHotKey(Label, Action, KeyCode, KeyMod));
} else {
player.Message("You do not support TextHotKey");
return;
}
}
示例15: StopWoMCrashBlocks
private static void StopWoMCrashBlocks( Player player )
{
List<Vector3I> blocks = new List<Vector3I>();
Vector3I spawn = player.World.Map.Spawn.ToBlockCoords();
for ( int x = spawn.X - 2; x <= spawn.X + 2; x++ ) {
for ( int y = spawn.Y - 2; y <= spawn.Y + 2; y++ ) {
for ( int z = player.World.Map.Height - 2; z <= player.World.Map.Height - 1; z++ ) {
if ( player.IsOnline ) {
if ( player.World != null ) {
if ( player.World.Map.GetBlock( x, y, z ) == Block.Air ) {
player.Send( Packets.MakeSetBlock( x, y, z, Block.Glass ) );
blocks.Add( new Vector3I( x, y, z ) );
}
}
}
}
}
}
Scheduler.NewTask( t => ResetBlocks( blocks, player ) ).RunOnce( TimeSpan.FromSeconds( 6 ) );
}