예제 #1
0
 private void AssertRemove(WallIndexMap map)
 {
     Assert.IsFalse(map.Remove(-1, -1, 1));
     Assert.IsFalse(map.Remove(2, 0, 1));
     Assert.IsFalse(map.Remove(0, 2, 1));
     Assert.IsTrue(map.Remove(0, 0, 1));
     Assert.IsEmpty(_removedTriangles);
     Assert.IsTrue(map.Remove(0, 0, 1));
     Assert.IsEmpty(_removedTriangles);
     Assert.IsTrue(map.Remove(0, 0, 1));
     Assert.AreEqual(new[] { 0 }, _removedTriangles);
 }
예제 #2
0
 public void TestSerialize()
 {
     var map = CreateMap(0, 0, 0, 2, 2, 0);
     var buffer = new MemoryStream();
     var writer = new BinaryWriter(buffer);
     map.Serialize(writer);
     buffer.Seek(0, SeekOrigin.Begin);
     var boundingBox = new Rectangle(0, 0, 2, 2); // FIXME !!! this is stupid; WallIndexMap should figure out the bounding box by itself
     var map2 = new WallIndexMap(x => { }, boundingBox, new BinaryReader(buffer));
     Assert.AreEqual(map.WallToIndexMapTransform, map2.WallToIndexMapTransform);
     Assert.AreEqual(Tuple.Create(map.Width, map.Height), Tuple.Create(map2.Width, map2.Height));
 }
예제 #3
0
파일: Wall.cs 프로젝트: vvnurmi/assaultwing
 public WallIndexMap CreateIndexMap()
 {
     var transformedVertexPositions = new Vector2[_vertexData.Length];
     var transformation = Matrix.CreateRotationZ(Rotation);
     Vector2.Transform(_vertexData.Select(AWMathHelper.ProjectXY).ToArray(),
         ref transformation, transformedVertexPositions);
     var indexMap = new WallIndexMap(_removedTriangleIndices.Add,
         AW2.Helpers.Geometric.Rectangle.FromVector2(transformedVertexPositions),
         transformedVertexPositions, _indexData);
     #if VERY_SMALL_TRIANGLES_ARE_COLLIDABLE
     indexMap.ForceVerySmallTrianglesIntoIndexMap(_vertexData, _indexData);
     #endif
     return indexMap;
 }
예제 #4
0
파일: Wall.cs 프로젝트: vvnurmi/assaultwing
 public override void Activate()
 {
     base.Activate();
     if (Arena.IsForPlaying)
     {
         var gobVertices = _vertexData.Select(AWMathHelper.ProjectXY).ToArray();
         var worldMatrix = Matrix.CreateRotationZ(Rotation); // FIXME: Use WorldMatrix or nothing
         Vector2.Transform(gobVertices, ref worldMatrix, gobVertices);
         var boundingBox = gobVertices.GetBoundingBox();
         _drawBoundsMin = boundingBox.Min + Pos;
         _drawBoundsMax = boundingBox.Max + Pos;
         var binReader = new System.IO.BinaryReader(Arena.Bin[StaticID]);
         _indexMap = new WallIndexMap(_removedTriangleIndices.Add, boundingBox, binReader);
         binReader.Close();
         CreateCollisionAreas();
     }
     WallActivatedCounter++;
 }