本文整理汇总了C#中MCForge.Utils.Vector3S.Move方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3S.Move方法的具体用法?C# Vector3S.Move怎么用?C# Vector3S.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCForge.Utils.Vector3S
的用法示例。
在下文中一共展示了Vector3S.Move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMove
public Vector3S GetMove(short distance, Vector3S towards)
{
Vector3S ret = new Vector3S(x, z, y);
ret.Move(distance, towards);
return ret;
}
示例2: HandleBots
/// <summary>
/// Handles bot AI
/// </summary>
public static void HandleBots()
{
foreach (Bot Bot in Server.Bots)
{
Random Random = new Random();
bool PlayerBelow = false;
if (Bot.Movement)
{
Vector3S TemporaryLocation = new Vector3S(Bot.Player.Pos.x, Bot.Player.Pos.z, Bot.Player.Pos.y);
if (Bot.FollowPlayers) //TODO - Fix jumping (you can jump infinately), fix bot locking on target (locks on one target only)
{
#region Find Closest Player
bool HitAPlayer = false;
Vector3S ClosestLocation = Bot.Player.Level.Size * 32;
foreach (Player p in Server.Players)
{
if (p.Level == Bot.Player.Level)
{
TargetPlayerArgs eargs = new TargetPlayerArgs(p);
bool cancel = OnBotTargetPlayer.Call(Bot, eargs).Canceled;
if (!cancel)
{
HitAPlayer = true;
if (p.Pos - Bot.Player.Pos < ClosestLocation - Bot.Player.Pos)
{
ClosestLocation = new Vector3S(p.Pos);
}
}
}
}
#endregion
if (HitAPlayer)
{
Vector3S TempLocation = new Vector3S(Bot.Player.Pos);
TemporaryLocation = new Vector3S(Bot.Player.Pos);
TemporaryLocation.Move(13, ClosestLocation);
MoveEventArgs eargs = new MoveEventArgs(TemporaryLocation, Bot.Player.Pos);
bool cancel = OnBotMove.Call(Bot, eargs).Canceled;
if (cancel){
TemporaryLocation = TempLocation;
}
}
}
bool ShouldBreakBlock = true;
if (Block.CanWalkThrough(Bot.Player.Level.GetBlock(Vector3S.MinusY(TemporaryLocation, 64) / 32)) && Bot.Player.Pos.y / 32 > 1)
TemporaryLocation.y = (short)(Bot.Player.Pos.y - 21); //Gravity, 21 is a nice value, doesn't float too much and doesnt fall too far.
if (Block.CanWalkThrough(Bot.Player.Level.GetBlock(TemporaryLocation / 32)) &&
Block.CanWalkThrough(Bot.Player.Level.GetBlock(Vector3S.MinusY(TemporaryLocation, 32) / 32)))
{
Bot.Player.Pos = TemporaryLocation; //Make sure the bot doesnt walk through walls
}
else if (Bot.Jumping) //Jumping
{
if (Block.CanWalkThrough(Bot.Player.Level.GetBlock(TemporaryLocation / 32)) &&
Block.CanWalkThrough(Bot.Player.Level.GetBlock(Vector3S.MinusY(TemporaryLocation, -32) / 32)))
{
Bot.Player.Pos.y = (short)(Bot.Player.Pos.y + 21);
ShouldBreakBlock = false;
}
}
if (Bot.BreakBlocks && ShouldBreakBlock) //Can't go through dat wall, try and break it
{
if (Random.Next(1, 5) == 3 && !Block.IsOPBlock(Bot.Player.Level.GetBlock(TemporaryLocation / 32)))
Bot.Player.Level.BlockChange(Convert.ToUInt16(TemporaryLocation.x / 32), Convert.ToUInt16(TemporaryLocation.z / 32), Convert.ToUInt16(TemporaryLocation.y / 32), Block.BlockList.AIR);
if (Random.Next(1, 5) == 3 && !Block.IsOPBlock(Bot.Player.Level.GetBlock(new Vector3S(Convert.ToUInt16(TemporaryLocation.x / 32), Convert.ToUInt16(TemporaryLocation.z / 32), Convert.ToUInt16((TemporaryLocation.y - 32) / 32)))))
Bot.Player.Level.BlockChange(Convert.ToUInt16(TemporaryLocation.x / 32), Convert.ToUInt16(TemporaryLocation.z / 32), Convert.ToUInt16((TemporaryLocation.y - 32) / 32), Block.BlockList.AIR);
if (PlayerBelow)
{
try
{
if (Random.Next(1, 5) == 3 && !Block.IsOPBlock(Bot.Player.Level.GetBlock(new Vector3S(Convert.ToUInt16(TemporaryLocation.x / 32), Convert.ToUInt16(TemporaryLocation.z / 32), Convert.ToUInt16((TemporaryLocation.y - 64) / 32)))))
Bot.Player.Level.BlockChange(Convert.ToUInt16(TemporaryLocation.x / 32), Convert.ToUInt16(TemporaryLocation.z / 32), Convert.ToUInt16((TemporaryLocation.y - 64) / 32), Block.BlockList.AIR);
}
catch { }
}
}
Bot.Player.Rot = new byte[] { (byte)(Bot.Player.Rot[0] + 1), (byte)(Bot.Player.Rot[1] + 1) };
Bot.Player.UpdatePosition(true); //Pls leave this true, bots dont appear properly otherwise
}
}
}