public void Container_Creation() { Point <int> point3D = new Point <int>(3, 3, 3); Point <int> point2D = new Point <int>(2, 2); Position <int> position3D = new Position <int>(); Position <int> position2D = new Position <int>(); Matrix <int> matrix_1 = new Matrix <int>(); Matrix <int> matrix_2 = new Matrix <int>(); Container <int> container = new Container <int>(); position3D.Add(point3D); position3D.Add(point3D); position3D.Add(point3D); matrix_1.Add(position3D); matrix_1.Add(position3D); container.Add(matrix_1); container.Add(matrix_1); Assert.IsNotEmpty(container); Assert.True(container.MatrixSize == matrix_1.Count); //Assert.Throws<ContainerRulesException>(() => container.Add(matrix_2)); }
public void TestMatrixAdd() { pos.Add(p); matrix.Add(pos); Assert.True(pos.Contains(p)); Assert.True(matrix.Contains(pos)); }
public void Cointeiners_Creating() { Point <int> point3D = new Point <int>(3, 3, 3); Point <int> point2D = new Point <int>(2, 2); Position <int> position3D = new Position <int>(); Position <int> position2D = new Position <int>(); Matrix <int> matrix_1 = new Matrix <int>(); Matrix <int> matrix_2 = new Matrix <int>(); Container <int> container_1 = new Container <int>(); Container <int> container_2 = new Container <int>(); Containers <int> containers = new Containers <int>(); position3D.Add(point3D); position3D.Add(point3D); position3D.Add(point3D); matrix_1.Add(position3D); matrix_1.Add(position3D); container_1.Add(matrix_1); container_1.Add(matrix_1); container_2.Add(matrix_1); containers.Add(container_1); containers.Add(container_1); Assert.IsNotEmpty(containers); Assert.True(containers.ContainerSize == containers.Count); Assert.Throws <ContainerRulesException>(() => containers.Add(container_2)); }
public void CollectionRule2() //The number of data points at each XYZ position will be the same for all positions on a matrix and across equivalent matrix indexes across containers. { Point <int> point3D = new Point <int>(3, 3, 3); Point <int> point2D = new Point <int>(2, 2); Position <int> position3D_1 = new Position <int>(); Position <int> position3D_2 = new Position <int>(); Position <int> position2D_1 = new Position <int>(); Position <int> position2D_2 = new Position <int>(); Matrix <int> matrix_1 = new Matrix <int>(); Matrix <int> matrix_2 = new Matrix <int>(); Container <int> container_1 = new Container <int>(); Container <int> container_2 = new Container <int>(); Containers <int> containers = new Containers <int>(); position3D_1.Add(point3D); position3D_2.Add(point3D); position3D_2.Add(point3D); position2D_1.Add(point2D); position2D_1.Add(point2D); position2D_2.Add(point2D); matrix_1.Add(position3D_1); matrix_1.Add(position3D_2); matrix_2.Add(position2D_1); matrix_2.Add(position2D_2); container_1.Add(matrix_1); container_1.Add(matrix_2); container_1.Add(matrix_1); container_2.Add(matrix_1); container_2.Add(matrix_2); container_2.Add(matrix_1); containers.Add(container_1); containers.Add(container_2); containers.Add(container_1); }
public void Render(IGameRenderService gameService) { gameService.DrawRect(_topLeft, _topLeft.Add(_inventory.MaxInventoryItems, 1), Enums.Colors.White, true); gameService.DrawToScreen(_topLeft.Add(0, -0.2), 20, "Inventory:"); if (_inventory == null) { return; } for (var i = -1; i < _inventory.MaxInventoryItems; i++) { _inventory.GetItem(i)?.Draw(gameService, _topLeft.Add(i + 1, 0)); } }
public void EnumeratorTest() { Position <int> pos = new Position <int>(); pos.Add(new Point <int>(0, 0)); pos.Add(new Point <int>(1, 1)); PositionEnumerator <int> en = new PositionEnumerator <int>(pos); en.MoveNext(); Assert.AreEqual(en.Current, pos[0]); en.Reset(); Assert.IsNull(en.Current); }
public static IEnumerable <string> GetQuadKeysInRadius(this Position position, double radius) { var topleft = position.Add(-radius, -radius); var bottomRight = position.Add(radius, radius); var topLeftX = 0; var topLeftY = 0; LatLongToPixelXY(topleft.Latitude, topleft.Longitude, MaxDepth, out topLeftX, out topLeftY); var bottomRightX = 0; var bottomRightY = 0; LatLongToPixelXY(bottomRight.Latitude, bottomRight.Longitude, MaxDepth, out bottomRightX, out bottomRightY); // get the pixels var pixels = Math.Max(Math.Abs(bottomRightX - topLeftX), Math.Abs(bottomRightY - topLeftY)); // so we know the number of pixels the diameter of our search is, let's select the right zoom level var tiles = pixels / 256; var searchLevel = (int)(MaxDepth - Math.Floor(Math.Log(tiles, 2))); searchLevel = Math.Max(3, Math.Min(MaxDepth, searchLevel)); int topLeftTileX = 0; int topLeftTileY = 0; LatLongToPixelXY(topleft.Latitude, topleft.Longitude, searchLevel, out topLeftTileX, out topLeftTileY); int bottomRightTileX = 0; int bottomRightTileY = 0; LatLongToPixelXY(bottomRight.Latitude, bottomRight.Longitude, searchLevel, out bottomRightTileX, out bottomRightTileY); topLeftTileX = topLeftTileX / 256; topLeftTileY = topLeftTileY / 256; bottomRightTileX = bottomRightTileX / 256; bottomRightTileY = bottomRightTileY / 256; for (var x = Math.Min(topLeftTileX, bottomRightTileX); x <= Math.Max(topLeftTileX, bottomRightTileX); x++) { for (var y = Math.Min(topLeftTileY, bottomRightTileY); y <= Math.Max(topLeftTileY, bottomRightTileY); y++) { yield return(TileXYToQuadKey(x, y, searchLevel)); } } }
public Particle(int Dim, double[] startPos = null, double startAngl = 0.0) { SpatialDim = Dim; // Particle history // ============================= for (int i = 0; i < m_HistoryLength; i++) { Position.Add(new double[Dim]); Angle.Add(new double()); TranslationalVelocity.Add(new double[Dim]); TranslationalAcceleration.Add(new double[Dim]); RotationalVelocity.Add(new double()); RotationalAcceleration.Add(new double()); HydrodynamicForces.Add(new double[Dim]); HydrodynamicTorque.Add(new double()); } // ============================= if (startPos == null) { startPos = new double[Dim]; } Position[0] = startPos; Position[1] = startPos; //From degree to radiant Angle[0] = StartingAngle = startAngl * 2 * Math.PI / 360; Angle[1] = startAngl * 2 * Math.PI / 360; //UpdateLevelSetFunction(); }
/// <summary> /// Removes cells that come before firstIndex or after lastIndex. /// </summary> public void TrimPath(int firstIndex, int lastIndex) { if (lastIndex < firstIndex) { throw new ArgumentOutOfRangeException("lastIndex", lastIndex, "lastIndex must be greater than or equal to firstIndex."); } if (lastIndex + 1 < m_path.Count()) { m_path.RemoveRange(lastIndex + 1, m_path.Count() - (lastIndex + 1)); } if (firstIndex > 0) { m_path.RemoveRange(0, firstIndex); // Make sure path still starts at (0, 0) var originOffset = m_path.First(); for (int i = 0; i < m_path.Count(); i++) { m_path[i] = m_path[i].Subtract(originOffset); } Position = Position.Add(originOffset); } }
public void RegisterDoor() { Shape = API.Shared.CreateSphereColShape(Position, 35f); Text = API.Shared.CreateTextLabel("~g~Door Id: " + Id, Position.Add(new Vector3(-1, 0, 0)), 5f, 1f, true); Shape.onEntityEnterColShape += Shape_onEntityEnterColShape; Doors.Add(this); }
} //tilt public void Move() { var state = Keyboard.GetState(); if (state.IsKeyDown(Key.W)) { Position = Position.Add(0, 0, -0.02f); } else if (state.IsKeyDown(Key.S)) { Position = Position.Add(0, 0, 0.02f); } else if (state.IsKeyDown(Key.D)) { Position = Position.Add(0.02f, 0, 0); } else if (state.IsKeyDown(Key.A)) { Position = Position.Add(-0.02f, 0, 0); } else if (state.IsKeyDown(Key.Z)) { Position = Position.Add(0, -0.02f, 0); } else if (state.IsKeyDown(Key.X)) { Position = Position.Add(0, 0.02f, 0); } }
private int CountRound(Position position) { var count = 0; for (var dx = -1; dx <= 1; dx++) { for (var dy = -1; dy <= 1; dy++) { for (var dz = -1; dz <= 1; dz++) { for (var dw = -1; dw <= 1; dw++) { if (dx != 0 || dy != 0 || dz != 0 || dw != 0) { var pos = position.Add(dx, dy, dz, dw); if (Actives.Contains(pos)) { count++; } } } } } } return(count); }
public void Move(double timeScale) { var newP = Position.Add(Velocity.Scale(timeScale)); Position.X = newP.X; Position.Y = newP.Y; }
bool IsDirectionFree(Position pos, Direction dir) { Position newPosition = new Position(pos.x, pos.y); newPosition.Add(bc.util.directionPositionDict[dir]); return(IsFree(newPosition)); }
public static Chunk NewFilledChunk(World world, Position chunkPos, int blockID) { BlockDef definition = BlockDefManager.GetBlockDef(blockID); Chunk chunk = new Chunk(world, chunkPos); Position globalChunkPos = chunkPos.MultAll(CHUNK_SIZE); int x, y, z; for (x = 0; x < CHUNK_SIZE; x++) { for (y = 0; y < CHUNK_SIZE; y++) { for (z = 0; z < CHUNK_SIZE; z++) { chunk.Blocks[x, y, z] = new Block(definition, globalChunkPos.Add(x, y, z), chunk); } } } if (definition.BlockType == BlockDef.TYPE_FLUID) { for (x = 0; x < CHUNK_SIZE; x++) { for (y = 0; y < CHUNK_SIZE; y++) { for (z = 0; z < CHUNK_SIZE; z++) { chunk.fluids.Add(new Fluid(chunk.Blocks[x, y, z])); } } } } return(chunk); }
static void Main(string[] args) { Position<int> p = new Position<int>(); Point<int> point = new Point<int>(3, 18); Point<int> point2 = new Point<int>(19, 29); Console.WriteLine(p.Count); p.Add(point); p.Add(point2); Console.WriteLine(p.Count); Console.WriteLine(p.Contains(point2)); p.Remove(point2); Console.WriteLine(p.Count); Console.WriteLine(p.Contains(point2)); Console.ReadKey(); }
/// <inheritdoc /> public void SkipAhead() { OnInteracting(); TimeSpan position = SkipAheadInterval.HasValue ? TimeSpanExtensions.Min(Position.Add(SkipAheadInterval.Value), MaxPosition) : MaxPosition; OnSkipAhead(position); }
public void KeyDown(KeyEventArgs keyEvent) { if (keyEvent.KeyCode == Keys.Z) { m_TurningLeft = true; } if (keyEvent.KeyCode == Keys.X) { m_TurningRight = true; } if (keyEvent.KeyCode == Keys.OemPeriod) { m_Thrusting = true; } if (keyEvent.KeyCode == Keys.OemQuestion) { if (!m_FireKeyDown) { double bulletVelocity = 220; // WIP: have a weapon and tell it to fire. // set something to fire down IVector <T> DirectionVector = MatrixFactory <T> .CreateVector2D(m_Rotation.Cos(), m_Rotation.Sin()); m_BulletList.Add(new Bullet <T>(Position.Add(DirectionVector.Multiply(m_PlayerStyleSheetReference.Instance.DistanceToFrontOfShip.ToDouble())), m_Velocity.Add(DirectionVector.Multiply(bulletVelocity)))); m_FireKeyDown = true; m_PlayerStyleSheetReference.Instance.FireSoundReference.Instance.PlayAnAvailableCopy(); } } }
public void DifferentPositionsTest() { Point1D <int> p = new Point1D <int>(1); Position <int> ptest = new Position <int>(); ptest.Add(p); matrix.Add(ptest); }
public void Move(object sender, EventArgs args) { Position = Position.Add(MoveVector); if (Position.Y < 0) { Position = Position.SetY(0); } }
public void AddPosition(string positionName) { if (Position.Contains(positionName)) { return; } Position.Add(positionName); }
private void HandlePlayerMove(IGameUpdateService gameService, Position worldPosition) { var deepGroundedBlock = gameService.WorldController.GetBlock(worldPosition.Add(0, -0.1)); if (deepGroundedBlock != null && deepGroundedBlock.IsCollidable) { gameService.GamePosition.Y = deepGroundedBlock.WorldPosition.Y; } var bottomLeft = worldPosition + new Position(-Width, -0.1); var bottomRight = worldPosition + new Position(Width, -0.1); var topLeft = worldPosition + new Position(-Width, -1.9); var topRight = worldPosition + new Position(Width, -1.9); var isLeft = gameService.WorldController.IsGrounded(bottomLeft) || gameService.WorldController.IsGrounded(topLeft); var isRight = gameService.WorldController.IsGrounded(bottomRight) || gameService.WorldController.IsGrounded(topRight); var isGrounded = gameService.WorldController.IsGrounded(worldPosition); var isTop = gameService.WorldController.IsGrounded(worldPosition + new Position(0, -2)); if (!isGrounded) { if (_jumpPosition == 0) { _jumpPosition = 30; } _jumpPosition++; } else { _jumpPosition = 0; if (gameService.IsPressed(Key.UP)) { _jumpPosition = 0.2; } } if (gameService.IsPressed(Key.LEFT) && !isLeft) { gameService.GamePosition.X -= MoveSpeed; _playerDirection = PlayerDirection.LEFT; } if (gameService.IsPressed(Key.RIGHT) && !isRight) { gameService.GamePosition.X += MoveSpeed; _playerDirection = PlayerDirection.RIGHT; } if (isTop && _jumpPosition < 30) { _jumpPosition = 30; } if (_jumpPosition != 0) { gameService.GamePosition.Y += GetJumpHeight(); } }
public PositionModel AddPositionModel(PositionModel model) { PositionModel newModel = Position.Add(model); IRatingAggregator ratingAggregator = new RatingAggregator.RatingAggregator(this); ratingAggregator.OnInsertOfPositionRecord(newModel); return(newModel); }
public void TestInitialize() { position = new Position <int>(); for (int i = 0; i < 100; i++) { position.Add(new Point2D <int>(i, i)); } }
public void TestMatrixRemove() { Point<double> p2 = new Point<double>(2d, 3d); Position<double> pos2 = new Position<double>(); pos2.Add(p2); matrix.Add(pos2); Assert.True(matrix.Contains(pos2)); matrix.Remove(pos2); Assert.False(matrix.Contains(pos2)); }
public void CollectionRule() //The number of data points at each position for XY may vary between positions and matrices { Point <int> point2D = new Point <int>(2, 2); Position <int> position2D_1 = new Position <int>(); Position <int> position2D_2 = new Position <int>(); Matrix <int> matrix = new Matrix <int>(); position2D_1.Add(point2D); position2D_1.Add(point2D); position2D_2.Add(point2D); matrix.Add(position2D_1); matrix.Add(position2D_2); Assert.True(matrix[0].Count != matrix[1].Count); }
public void DifferentSizeMatrixTest() { Point2D <int> p = new Point2D <int>(-1, -1); Position <int> ptest = new Position <int>(); Matrix <int> mtest = new Matrix <int>(); ptest.Add(p); mtest.Add(ptest); container.Add(mtest); }
public void MatrixRemoveTest() { Point2D <int> p = new Point2D <int>(-1, -1); Position <int> ptest = new Position <int>(); ptest.Add(p); matrix.Add(ptest); matrix.Remove(ptest); Assert.IsFalse(matrix.Contains(ptest)); }
public void MatrixAddTest() { Point2D <int> p = new Point2D <int>(-1, -1); Position <int> ptest = new Position <int>(); ptest.Add(p); matrix.Add(ptest); Assert.IsTrue(ptest.Contains(p)); Assert.IsTrue(matrix.Contains(ptest)); }
public void Update(double timeSinceLastUpdate) { timeSinceSnakeMove += timeSinceLastUpdate; if (timeSinceSnakeMove >= snakeMoveTime) { timeSinceSnakeMove = 0; var endOfSnakeBeforeMove = new Vector2(Position.Last().X, Position.Last().Y); //Move Existing Snake //Tail for (var i = Position.Count() - 1; i > 0; i--) { Position[i] = Position[i - 1]; } //Head Position[0] += Direction; for (var i = 1; i < Position.Count; i++) { if (Position[0].X == Position[i].X && Position[0].Y == Position[i].Y) { SnakeIntersectsSnake = true; } } //GrowSnake if (growing) { Position.Add(endOfSnakeBeforeMove); growing = false; } } //TODO : Current code protects against the snake goind back on itself //However, you can get round this by going another direction then back on itself //before the snake has moved, Need to protect against this. KeyboardState keyboardState = Keyboard.GetState(); if (keyboardState.IsKeyDown(Keys.Left) && Direction.X != 1) { Direction = new Vector2(-1, 0); } else if (keyboardState.IsKeyDown(Keys.Right) && Direction.X != -1) { Direction = new Vector2(1, 0); } if (keyboardState.IsKeyDown(Keys.Up) && Direction.Y != 1) { Direction = new Vector2(0, -1); } else if (keyboardState.IsKeyDown(Keys.Down) && Direction.Y != -1) { Direction = new Vector2(0, 1); } }
/// <summary> /// Rotates the camera about the specified axis and center point by the specified angle in degrees. /// </summary> public void Rotate(Vector3D axis, double angle, Point3D center) { if (!center.IsValid()) { center = Math3D.Origin; } Position = Position.Subtract(center); Rotate(axis, angle); Position = Position.Add(center); }
public void TestMatrixRemove() { Point <double> p2 = new Point <double>(2d, 3d); Position <double> pos2 = new Position <double>(); pos2.Add(p2); matrix.Add(pos2); Assert.True(matrix.Contains(pos2)); matrix.Remove(pos2); Assert.False(matrix.Contains(pos2)); }
public void Init() { positions = new Position<int>(); p = new Point<int>(10, 10); var n = new Random(); for (int i = 0; i < MAX_POINTS; i++) { positions.Add(new Point<int>(n.Next(5, 50), n.Next(1, 50))); } }
public void Init() { matrix = new Matrix<double>(); p = new Point<double>(10d, 10d); pos = new Position<double>(); var n = new Random(); for (int i = 0; i < MAX_POSITIONS; i++) { for (int j = 0; j < MAX_POINTS; j++) { pos.Add(new Point<double>(n.NextDouble(), n.NextDouble())); } matrix.Add(pos); } }