public Layer(FightingZone Owner, BinaryReader BR) : this(Owner) { Dictionary <string, Prop> DicPropsByName = Prop.GetAllPropsByName(); int ListPolygonCount = BR.ReadInt32(); ListWorldCollisionPolygon = new List <WorldPolygon>(ListPolygonCount); for (int P = 0; P < ListPolygonCount; P++) { int ArrayVertexCount = BR.ReadInt32(); Vector2[] ArrayVertex = new Vector2[ArrayVertexCount]; for (int V = 0; V < ArrayVertexCount; V++) { ArrayVertex[V] = new Vector2(BR.ReadSingle(), BR.ReadSingle()); } bool BlockBullets = BR.ReadBoolean(); bool IsPlatform = BR.ReadBoolean(); WorldPolygon NewPolygon; if (GameScreen.GraphicsDevice != null) { NewPolygon = new WorldPolygon(ArrayVertex, GameScreen.GraphicsDevice.PresentationParameters.BackBufferWidth, GameScreen.GraphicsDevice.PresentationParameters.BackBufferHeight); } else { NewPolygon = new WorldPolygon(ArrayVertex, 1, 1); } NewPolygon.BlockBullets = BlockBullets; NewPolygon.IsPlatform = IsPlatform; NewPolygon.ComputerCenter(); ListWorldCollisionPolygon.Add(NewPolygon); } int ArrayGroundLevelCollisionCount = BR.ReadInt32(); Vector2[] ArrayGroundLevelCollision = new Vector2[ArrayGroundLevelCollisionCount]; for (int V = 0; V < ArrayGroundLevelCollisionCount; V++) { ArrayGroundLevelCollision[V] = new Vector2(BR.ReadSingle(), BR.ReadSingle()); } short[] ArrayGroundLevelCollisionIndex = new short[2]; ArrayGroundLevelCollisionIndex[0] = 0; ArrayGroundLevelCollisionIndex[1] = 1; if (GameScreen.GraphicsDevice != null) { GroundLevelCollision = new Polygon(ArrayGroundLevelCollision, ArrayGroundLevelCollisionIndex, GameScreen.GraphicsDevice.PresentationParameters.BackBufferWidth, GameScreen.GraphicsDevice.PresentationParameters.BackBufferHeight); } else { GroundLevelCollision = new Polygon(ArrayGroundLevelCollision, ArrayGroundLevelCollisionIndex, 1, 1); } int ListImagesCount = BR.ReadInt32(); ListImages = new List <SimpleAnimation>(ListImagesCount); for (int P = 0; P < ListImagesCount; P++) { SimpleAnimation NewBackground = new SimpleAnimation(BR, true); NewBackground.Position = new Vector2(BR.ReadSingle(), BR.ReadSingle()); NewBackground.Depth = BR.ReadSingle(); if (!Owner.IsServer) { NewBackground.Load(Owner.Content, ""); ListImages.Add(NewBackground); } } int ListPropCount = BR.ReadInt32(); for (int P = 0; P < ListPropCount; ++P) { string PropName = BR.ReadString(); Prop NewProp = DicPropsByName[PropName].Copy(); NewProp.Load(BR, Owner.Content, this, Owner); //Props are Client side only. if (NewProp.CanRunOnServer || !Owner.IsServer) { ListProp.Add(NewProp); } } int ListSpawnPointSPCount = BR.ReadInt32(); for (int S = 0; S < ListSpawnPointSPCount; ++S) { ListSpawnPointTeam.Add(SpawnPoint.Load(BR)); } int ListSpawnPointMPCount = BR.ReadInt32(); for (int S = 0; S < ListSpawnPointMPCount; ++S) { ListSpawnPointTeam.Add(SpawnPoint.Load(BR)); } }
private void ProcessGeometry(Geometry geom) { if (geom == null) { return; } var GeometryType = geom.GetGeometryType(); switch ((wkbGeometryType)((int)GeometryType & 0xffff)) { case wkbGeometryType.wkbUnknown: break; case wkbGeometryType.wkbPoint: var pnt = new double[3]; geom.GetPoint(0, pnt); NewPoint?.Invoke(new point(pnt)); break; case wkbGeometryType.wkbLineString: { List <point> ls = new List <point>(); var pointcount = geom.GetPointCount(); for (int p = 0; p < pointcount; p++) { double[] pnt2 = new double[3]; geom.GetPoint(p, pnt2); ls.Add(pnt2); } NewLineString?.Invoke(ls); break; } case wkbGeometryType.wkbPolygon: { List <point> poly = new List <point>(); for (int i = 0; i < geom.GetGeometryCount(); i++) { var geom2 = geom.GetGeometryRef(i); var pointcount1 = geom2.GetPointCount(); for (int p = 0; p < pointcount1; p++) { double[] pnt2 = new double[3]; geom2.GetPoint(p, pnt2); poly.Add(pnt2); } NewPolygon?.Invoke(poly); } break; } case wkbGeometryType.wkbMultiPoint: case wkbGeometryType.wkbMultiLineString: case wkbGeometryType.wkbMultiPolygon: case wkbGeometryType.wkbGeometryCollection: case wkbGeometryType.wkbLinearRing: { Geometry sub_geom; for (int i = 0; i < geom.GetGeometryCount(); i++) { sub_geom = geom.GetGeometryRef(i); ProcessGeometry(sub_geom); } break; } case wkbGeometryType.wkbNone: break; } }