Exemple #1
0
 public Map(Minecraft minecraft)
 {
     this.minecraft = minecraft;
     chunks = new Chunk[21, 21];
     center = this.chunks.GetLength (0) / 2;
     playerChunk = null;
 }
 public Player(string name, Minecraft minecraft)
 {
     this.name       = name;
     this.minecraft  = minecraft;
     entityID        = 0;
     this.position   = new XYZ <double> (0, 0, 0);
     look            = new Look <float> (0, 0);
     moving          = new Timer(50);
     moving.Elapsed += delegate(object source, ElapsedEventArgs e) {
         this.nextMove();
     };
     moving.Start();
     speed = 5;            //per 1 second
     //endPosition = new XYZ<double> (0, 0, 0);
 }
 public Player(string name, Minecraft minecraft)
 {
     this.name = name;
     this.minecraft = minecraft;
     entityID = 0;
     this.position = new XYZ<double> (0, 0, 0);
     look = new Look<float> (0, 0);
     moving = new Timer (50);
     moving.Elapsed += delegate( object source, ElapsedEventArgs e ) {
         this.nextMove ();
     };
     moving.Start ();
     speed = 5;//per 1 second
     //endPosition = new XYZ<double> (0, 0, 0);
 }
Exemple #4
0
        public static void Main(string[] args)
        {
            Minecraft m = new Minecraft("main.ttyh.ru", 25565);

            m.Status();
            Thread connection = new Thread(new ThreadStart(delegate {
                m.Start("HypnoToad");
            }
                                                           )
                                           );

            connection.Start();
            while (!m.isLogged)
            {
                Thread.Sleep(100);
            }
            while (m.isLogged)
            {
                string command = Console.ReadLine();
                if (command.Length > 0)
                {
                    if (command [0] == '!')
                    {
                        string[] line = command.Split(' ');
                        if (line [0] == "!move" && line.Length >= 4)
                        {
                            XYZ <double> next = new XYZ <double> (m.player.position.x, m.player.position.y, m.player.position.z);
                            double.TryParse(line [1], out next.x);
                            double.TryParse(line [2], out next.y);
                            double.TryParse(line [3], out next.z);
                            m.player.MoveTo(next);
                        }
                        if (line [0] == "!player" && line.Length >= 2)
                        {
                            bool onGround = false;
                            bool.TryParse(line [1], out onGround);
                            Console.WriteLine("onGround: {0}", onGround);
                            m.player.changeGround(onGround);
                        }
                        if (line [0] == "!map")
                        {
                            m.map.WriteMap();
                        }
                        if (line [0] == "!control")
                        {
                            ConsoleKeyInfo info = Console.ReadKey();
                            while (info.KeyChar != 'q')
                            {
                                if (info.KeyChar == 'w')
                                {
                                    XYZ <double> next = new XYZ <double> (m.player.position.x, m.player.position.y, m.player.position.z);
                                    next.x += 0.25;
                                    m.player.MoveTo(next);
                                }
                                if (info.KeyChar == 's')
                                {
                                    XYZ <double> next = new XYZ <double> (m.player.position.x, m.player.position.y, m.player.position.z);
                                    next.x -= 0.25;
                                    m.player.MoveTo(next);
                                }
                                if (info.KeyChar == 'a')
                                {
                                    XYZ <double> next = new XYZ <double> (m.player.position.x, m.player.position.y, m.player.position.z);
                                    next.z -= 0.25;
                                    m.player.MoveTo(next);
                                }
                                if (info.KeyChar == 'd')
                                {
                                    XYZ <double> next = new XYZ <double> (m.player.position.x, m.player.position.y, m.player.position.z);
                                    next.z += 0.25;
                                    m.player.MoveTo(next);
                                }
                                if (info.KeyChar == 'x')
                                {
                                    XYZ <double> next = new XYZ <double> (m.player.position.x, m.player.position.y, m.player.position.z);
                                    next.y -= 0.25;
                                    m.player.MoveTo(next);
                                }
                                if (info.KeyChar == ' ')
                                {
                                    XYZ <double> next = new XYZ <double> (m.player.position.x, m.player.position.y, m.player.position.z);
                                    next.y += 0.25;
                                    m.player.MoveTo(next);
                                }
                                info = Console.ReadKey();
                            }
                        }
                    }
                    else
                    {
                        m.writeToChat(command);
                    }
                }
            }
        }
Exemple #5
0
 public static void Main(string[] args)
 {
     Minecraft m = new Minecraft ("main.ttyh.ru", 25565);
     m.Status ();
     Thread connection = new Thread (new ThreadStart (delegate {
         m.Start ("HypnoToad");
     }
     )
     );
     connection.Start ();
     while (!m.isLogged)
         Thread.Sleep (100);
     while (m.isLogged) {
         string command = Console.ReadLine ();
         if (command.Length > 0) {
             if (command [0] == '!') {
                 string[] line = command.Split (' ');
                 if (line [0] == "!move" && line.Length >= 4) {
                     XYZ<double> next = new XYZ<double> (m.player.position.x, m.player.position.y, m.player.position.z);
                     double.TryParse (line [1], out next.x);
                     double.TryParse (line [2], out next.y);
                     double.TryParse (line [3], out next.z);
                     m.player.MoveTo (next);
                 }
                 if (line [0] == "!player" && line.Length >= 2) {
                     bool onGround = false;
                     bool.TryParse (line [1], out onGround);
                     Console.WriteLine ("onGround: {0}", onGround);
                     m.player.changeGround (onGround);
                 }
                 if (line [0] == "!map") {
                     m.map.WriteMap ();
                 }
                 if (line [0] == "!control") {
                     ConsoleKeyInfo info = Console.ReadKey ();
                     while (info.KeyChar!='q') {
                         if (info.KeyChar == 'w') {
                             XYZ<double> next = new XYZ<double> (m.player.position.x, m.player.position.y, m.player.position.z);
                             next.x += 0.25;
                             m.player.MoveTo (next);
                         }
                         if (info.KeyChar == 's') {
                             XYZ<double> next = new XYZ<double> (m.player.position.x, m.player.position.y, m.player.position.z);
                             next.x -= 0.25;
                             m.player.MoveTo (next);
                         }
                         if (info.KeyChar == 'a') {
                             XYZ<double> next = new XYZ<double> (m.player.position.x, m.player.position.y, m.player.position.z);
                             next.z -= 0.25;
                             m.player.MoveTo (next);
                         }
                         if (info.KeyChar == 'd') {
                             XYZ<double> next = new XYZ<double> (m.player.position.x, m.player.position.y, m.player.position.z);
                             next.z += 0.25;
                             m.player.MoveTo (next);
                         }
                         if (info.KeyChar == 'x') {
                             XYZ<double> next = new XYZ<double> (m.player.position.x, m.player.position.y, m.player.position.z);
                             next.y -= 0.25;
                             m.player.MoveTo (next);
                         }
                         if (info.KeyChar == ' ') {
                             XYZ<double> next = new XYZ<double> (m.player.position.x, m.player.position.y, m.player.position.z);
                             next.y += 0.25;
                             m.player.MoveTo (next);
                         }
                         info = Console.ReadKey ();
                     }
                 }
             } else {
                 m.writeToChat (command);
             }
         }
     }
 }