예제 #1
0
        private Position RemoveNoise(Position nextPosition) {
            if (NoiseThreshold == 0) {
                return nextPosition;
            }
            var i0 = _position.Image;
            var w0 = _position.World;
            var i1 = nextPosition.Image;
            var w1 = nextPosition.World;

            if (Math.Abs(i0.X - i1.X) <= NoiseThreshold) {
                i1.X = i0.X;
            }
            if (Math.Abs(i0.Y - i1.Y) <= NoiseThreshold) {
                i1.Y = i0.Y;
            }
            if (Math.Abs(i0.Z - i1.Z) <= NoiseThreshold) {
                i1.Z = i0.Z;
            }
            if (Math.Abs(w0.X - w1.X) <= NoiseThreshold) {
                w1.X = w0.X;
            }
            if (Math.Abs(w0.Y - w1.Y) <= NoiseThreshold) {
                w1.Y = w0.Y;
            }
            if (Math.Abs(w0.Z - w1.Z) <= NoiseThreshold) {
                w1.Z = w0.Z;
            }
            return new Position {
                Image = i1,
                World = w1
            };
        }
예제 #2
0
 private bool DidNotChange(Position nextPosition)
 {
     return nextPosition.Image.Equals(_position.Image);
 }
예제 #3
0
 protected virtual void OnMove(Position oldPosition, Position newPosition)
 {
     var handler = Moved;
     if (handler != null) handler(this, new PositionEventArgs(oldPosition, newPosition));
 }
예제 #4
0
 public PositionEventArgs(Position oldPosition, Position newPosition)
 {
     OldPosition = oldPosition;
     NewPosition = newPosition;
 }
예제 #5
0
 protected virtual void OnMove(Position oldPosition, Position newPosition) {
     Moved?.Invoke(this, new PositionEventArgs(oldPosition, newPosition));
 }