Exemple #1
0
        internal override void ReadFrom(BinaryReader reader)
        {
            Id = reader.ReadInt32();
            float x = reader.ReadSingle();
            float y = reader.ReadSingle();

            Position = new Vector2(x, y);
            Heading  = (PlayerHeading)reader.ReadByte();
        }
        public void Move(PlayerHeading movementDirection)
        {
            Heading = movementDirection;
            var nextPosition = Position + Vector2.Multiply(HeadingVector, MovementSpeed);
            var nextField    = Playground.FieldAt(Field.CalculateColumn(nextPosition), Field.CalculateRow(nextPosition));

            if (nextField.IsAccessible)
            {
                Position = nextPosition;
            }
        }
Exemple #3
0
        public void MovePlayer(PlayerHeading direction)
        {
            if (AssignedPlayer == null)
            {
                return;
            }

            AssignedPlayer.Move(direction);
            NetworkPacketSerializer.WritePacket(new PlayerUpdatePacket(AssignedPlayer), Socket);
            //TODO: move/interact might be pulled into own interface implemented by Player and some kind of network-decorator for Player
        }
 public void Update(Vector2 newPosition, PlayerHeading newHeading)
 {
     Position = newPosition;
     Heading  = newHeading;
 }
        public void MovePlayer(PlayerHeading direction)
        {
            if (AssignedPlayer == null)
                return;

            AssignedPlayer.Move(direction);
            NetworkPacketSerializer.WritePacket(new PlayerUpdatePacket(AssignedPlayer), Socket);
            //TODO: move/interact might be pulled into own interface implemented by Player and some kind of network-decorator for Player
        }
Exemple #6
0
 public PlayerUpdatePacket(Player player)
 {
     Id       = player.Id;
     Position = player.Position;
     Heading  = player.Heading;
 }
 public void Update(Vector2 newPosition, PlayerHeading newHeading)
 {
     Position = newPosition;
     Heading = newHeading;
 }
 public void Move(PlayerHeading movementDirection)
 {
     Heading = movementDirection;
     var nextPosition = Position + Vector2.Multiply(HeadingVector, MovementSpeed);
     var nextField = Playground.FieldAt(Field.CalculateColumn(nextPosition), Field.CalculateRow(nextPosition));
     if (nextField.IsAccessible)
         Position = nextPosition;
 }