예제 #1
0
 public override string Run(string command, string[] args, string argStr)
 {
     if (args.Length > 0)
     {
         tcpClientRetriever.GetTcpClient().SendText(argStr);
         return("");
     }
     else
     {
         return(CMDDesc);
     }
 }
예제 #2
0
        public override string Run(string command, string[] args, string argStr)
        {
            McTcpClient handler = tcpClientRetriever.GetTcpClient();

            if (args.Length == 1)
            {
                string    dirStr    = args[0].Trim().ToLower();
                Direction direction = DirectionMethods.FromString(dirStr);
                if (direction == Direction.None)
                {
                    return("Invalid direction: " + dirStr);
                }

                player.UpdateLocation(player.GetCurrentLocation(), direction);
                return("Looking " + dirStr);
            }
            else if (args.Length == 2)
            {
                try
                {
                    float yaw   = Single.Parse(args[0]);
                    float pitch = Single.Parse(args[1]);

                    player.UpdateLocation(player.GetCurrentLocation(), yaw, pitch);
                    return(String.Format("Looking at YAW: {0} PITCH: {1}", yaw.ToString("0.00"), pitch.ToString("0.00")));
                }
                catch (FormatException) { return(CMDDesc); }
            }
            else if (args.Length == 3)
            {
                try
                {
                    int x = int.Parse(args[0]);
                    int y = int.Parse(args[1]);
                    int z = int.Parse(args[2]);

                    Location block = new Location(x, y, z);
                    player.UpdateLocation(player.GetCurrentLocation(), block);

                    return("Looking at " + block);
                }
                catch (FormatException) { return(CMDDesc); }
            }
            else
            {
                return(CMDDesc);
            }
        }
예제 #3
0
        public override string Run(string command, string[] args, string argStr)
        {
            McTcpClient handler = tcpClientRetriever.GetTcpClient();

            if (args.Length == 1)
            {
                if (argStr == "get")
                {
                    return(handler.player.GetCurrentLocation().ToString());
                }

                Direction direction = DirectionMethods.FromString(argStr);

                if (Movement.CanMove(handler.GetWorld(), handler.player.GetCurrentLocation(), direction))
                {
                    //handler.player.MoveTo(Movement.Move(handler.player.GetCurrentLocation(), direction));
                    return("Moving " + argStr + '.');
                }
                else
                {
                    return("Cannot move in that direction.");
                }
            }
            else if (args.Length == 3)
            {
                try
                {
                    int      x    = int.Parse(args[0]);
                    int      y    = int.Parse(args[1]);
                    int      z    = int.Parse(args[2]);
                    Location goal = new Location(x, y, z);
                    //if (handler.player.MoveTo(goal))
                    //return "Walking to " + goal;
                    return("Failed to compute path to " + goal);
                }
                catch (FormatException) { return(CMDDesc); }
            }
            else
            {
                return(CMDDesc);
            }
        }
예제 #4
0
 public override string Run(string command, string[] args, string argStr)
 {
     return("PlayerList: " + string.Join(", ", tcpClientRetriever.GetTcpClient().GetOnlinePlayers()));
 }
예제 #5
0
 public override string Run(string command, string[] args, string argStr)
 {
     tcpClientRetriever.GetTcpClient().SendRespawnPacket();
     return("You have respawned.");
 }