Exemple #1
0
 public Position(short X, short Y, short Z)
 {
     this = new Position(); // Using fields in the constructer is messy, so let .NET clear the messiness, then proceed.
     x = X;
     y = Y;
     z = Z;
 }
Exemple #2
0
 public Robot(string name)
 {
     this.name = name;
     this.playerID = Player.AssignID();
     pos = new Position((short)(Server.theServ.map.xdim * 16),
         (short)(Server.theServ.map.ydim * 16), (short)(Server.theServ.map.zdim * 16));
     heading = 0;
     pitch = 0;
     time = 0;
     update = true;
 }
Exemple #3
0
 public Position(byte x, byte y, byte z)
 {
     this = new Position((short)x, (short)y, (short)z);
 }
Exemple #4
0
 public override void PlayerMoves(Player Player, Position dest, byte heading, byte pitch)
 {
     // do nothing
 }
Exemple #5
0
 void Robot_Move(Robot sender, Position dest, byte heading, byte pitch)
 {
     List<Player> temp = new List<Player>(Players);
     foreach (Player P in temp) {
         P.PlayerMoves(sender, dest, heading, pitch);
     }
 }
Exemple #6
0
 void Player_Move(Player sender, Position dest, byte heading, byte pitch)
 {
     List<Player> temp = new List<Player>(Players);
     foreach (Player P in temp) {
         if(P != sender) {
             P.PlayerMoves(sender, dest, heading, pitch);
         }
     }
 }
Exemple #7
0
        public Robot SpawnRobot(Position pos, string name)
        {
            Robot Robot = new Robot(name);
            Robot.pos = pos;

            Robot.Spawn += new Robot.RobotSpawnHandler(Robot_Spawn);
            //Robot.Message += new Player.PlayerMsgHandler(Player_Message);
            Robot.Move += new Robot.RobotMoveHandler(Robot_Move);
            //Robot.BlockChange += new Player.PlayerBlockChangeHandler(Player_BlockChange);
            Robot.Disconnect += new Robot.RobotDisconnectHandler(Robot_Disconnect);

            Robots.Add(Robot);
            Robot.Start();
            return Robot;
        }
Exemple #8
0
 public void MovePlayer(Player player, Position dest, byte heading, byte pitch)
 {
     List<Player> temp = new List<Player>(Players);
     foreach (Player P in temp) {
         P.PlayerMoves(player, dest, heading, pitch);
     }
 }
Exemple #9
0
        public void Generate(bool skipTcl)
        {
            Spacecraft.Log("Generating map...");

            xdim = DefaultWidth;
            ydim = DefaultHeight;
            zdim = DefaultDepth;

            data = new byte[xdim * ydim * zdim];

            DateTime Begin = DateTime.Now;

            physicsCount = 0;
            spawn = new Position((short)(16 * xdim), (short)(16 * ydim + 48), (short)(16 * zdim));
            // Spawn the player in the (approximate) center of the map. Each block is 32x32x32 pixels.

            for (short x = 0; x < xdim; ++x)
            {
                if (x == (short)(xdim / 2)) {
                    Spacecraft.Log("Generation 50% complete");
                }

                for (short z = 0; z < zdim; ++z) {
                    for (short y = 0; y < ydim / 2; ++y) {
                        if (y == ydim / 2 - 1) {
                            SetTile_Fast(x, y, z, Block.Grass);
                        } else {
                            SetTile_Fast(x, y, z, Block.Dirt);
                        }
                    }
                }
            }

            DateTime End = DateTime.Now;
            Spacecraft.Log("Generation complete. Took " + (End - Begin).TotalMilliseconds + "ms");
        }
Exemple #10
0
 public void SetSpawn(Position p, byte heading)
 {
     spawn = p;
     spawnHeading = heading;
 }
Exemple #11
0
        void conn_PlayerMove(Position dest, byte heading, byte pitch)
        {
            if(pos == dest && this.heading == heading && this.pitch == pitch) return;

            pos = dest;
            this.heading = heading;
            this.pitch = pitch;

            // Echo event on to other listeners, e.g. the server.
            Move(this, dest, heading, pitch);
        }
Exemple #12
0
 public virtual void PlayerMoves(Robot Player, Position dest, byte heading, byte pitch)
 {
     conn.SendPlayerMovement(Player, dest, heading, pitch, false);
 }
Exemple #13
0
        public virtual void PlayerMoves(Player Player, Position dest, byte heading, byte pitch)
        {
            if (Player == this) {
                pos = dest;
            }

            conn.SendPlayerMovement(Player, dest, heading, pitch, Player == this);
        }
Exemple #14
0
        private void HandlePositionUpdate(PositionUpdatePacket positionUpdatePacket)
        {
            Position pos = new Position(positionUpdatePacket.X, positionUpdatePacket.Y, positionUpdatePacket.Z);

            byte heading = positionUpdatePacket.Heading;
            byte pitch = positionUpdatePacket.Pitch;

            if (PlayerMove != null)
                PlayerMove(pos, heading, pitch);
        }
Exemple #15
0
        public void SendPlayerMovement(Robot player, Position dest, byte heading, byte pitch, bool self)
        {
            PlayerMovePacket packet = new PlayerMovePacket();
            packet.PlayerID = player.playerID;
            if (self)
                packet.PlayerID = 255;
            packet.X = player.pos.x;
            packet.Y = player.pos.y;
            packet.Z = player.pos.z;
            packet.Heading = heading;
            packet.Pitch = pitch;

            SendPacket(packet);
        }