コード例 #1
0
ファイル: SimulationStepTests.cs プロジェクト: AyyTee/Aventyr
        public void StepTest3()
        {
            Scene scene = new Scene();
            Portalable p = new Portalable(scene);
            Transform2 start = new Transform2(new Vector2(0, 0));
            Transform2 velocity = Transform2.CreateVelocity(new Vector2(3, 0));
            p.SetTransform(start);
            p.SetVelocity(velocity);

            //Scene scene = new Scene();
            FloatPortal enter = new FloatPortal(scene);
            enter.SetTransform(new Transform2(new Vector2(1, 0)));
            enter.SetVelocity(Transform2.CreateVelocity(new Vector2(1, 0)));

            FloatPortal exit = new FloatPortal(scene);
            exit.SetTransform(new Transform2(new Vector2(10, 10)));

            enter.Linked = exit;
            exit.Linked = enter;

            PortalCommon.UpdateWorldTransform(new IPortalCommon[] { p, enter, exit });
            SimulationStep.Step(new IPortalCommon[] { p, enter, exit }, new IPortal[] { enter, exit }, 1, null);

            /*Assert.IsTrue(p.WorldTransform.Position == new Vector2(9, 10));
            Assert.IsTrue(p.WorldVelocity.Position == new Vector2(-2, 0));*/
            Assert.IsTrue(p.GetTransform().Position == new Vector2(9, 10));
            Assert.IsTrue(p.GetVelocity().Position == new Vector2(-2, 0));
        }
コード例 #2
0
ファイル: Factory.cs プロジェクト: AyyTee/Aventyr
 public static Body CreatePolygon(World world, Transform2 transform, IList<Vector2> vertices)
 {
     Debug.Assert(world != null);
     Body body = BodyExt.CreateBody(world);
     CreatePolygon(body, transform, vertices);
     return body;
 }
コード例 #3
0
ファイル: EditorScene.cs プロジェクト: AyyTee/Aventyr
 public void AddKeyframe(EditorObject instance, Transform2 keyframe, float time)
 {
     if (instance.AnimatedTransform == null)
     {
         instance.AnimatedTransform = new CurveTransform2();
     }
     instance.AnimatedTransform.AddKeyframe(time, keyframe);
 }
コード例 #4
0
ファイル: Transform2Tests.cs プロジェクト: AyyTee/Aventyr
        public void GetNormalTest0()
        {
            Transform2 t = new Transform2();
            t.Position = new Vector2(100, -200);

            Vector2 normal = t.GetRight();
            Assert.IsTrue(normal == new Vector2(1, 0));
        }
コード例 #5
0
ファイル: Actor.cs プロジェクト: AyyTee/Aventyr
 public Actor(Scene scene, IList<Vector2> vertices, Transform2 transform)
     : base(scene)
 {
     _vertices = vertices.ToArray();
     _scale = transform.Scale;
     Body = Factory.CreatePolygon(Scene.World, transform, Vertices);
     BodyExt.SetData(Body, this);
     SetBodyType(BodyType.Dynamic);
 }
コード例 #6
0
ファイル: Drag.cs プロジェクト: AyyTee/Aventyr
 public Drag(List<EditorObject> modified, Transform2 transform)
 {
     IsMarker = true;
     foreach (EditorObject e in modified)
     {
         _modified.Add(new MementoDrag(e));
     }
     _transform = transform.ShallowClone();
 }
コード例 #7
0
ファイル: Transform2Tests.cs プロジェクト: AyyTee/Aventyr
        public void GetNormalTest1()
        {
            Transform2 t = new Transform2();
            t.Rotation = (float)Math.PI;
            t.Position = new Vector2(100, -200);

            Vector2 normal = t.GetRight();
            Vector2 reference = new Vector2(-1, 0);
            Assert.IsTrue(Math.Abs(normal.X - reference.X) < 0.00001 && Math.Abs(normal.Y - reference.Y) < 0.00001);
        }
コード例 #8
0
ファイル: TankData.cs プロジェクト: AyyTee/Aventyr
        public TankData(long ownerId, Tank tank)
        {
            OwnerId = ownerId;
            ServerId = (int)tank.ServerId;
            Transform = tank.GetTransform();
            WorldTransform = tank.WorldTransform;
            Velocity = tank.GetVelocity();
            WorldVelocity = tank.WorldVelocity;
            TurretTransform = tank.Turret.GetTransform();
            TurretWorldTransform = tank.Turret.GetWorldTransform();

            GunFiredTime = tank.GunFiredTime;
        }
コード例 #9
0
ファイル: SimulationStepTests.cs プロジェクト: AyyTee/Aventyr
        public void StepTest0()
        {
            Scene scene = new Scene();
            Portalable p = new Portalable(scene);
            Transform2 start = new Transform2(new Vector2(1, 5), 2.3f, 3.9f);
            Transform2 velocity = Transform2.CreateVelocity(new Vector2(-3, 4), 23, 0.54f);
            p.SetTransform(start);
            p.SetVelocity(velocity);
            PortalCommon.UpdateWorldTransform(new IPortalCommon[] { p });
            SimulationStep.Step(new IPortalCommon[] { p }, new IPortal[0], 1, null);

            Assert.IsTrue(p.GetTransform().AlmostEqual(start.Add(velocity)));
        }
コード例 #10
0
ファイル: TankCamera.cs プロジェクト: AyyTee/Aventyr
 public void StepBegin(IScene scene, float stepSize)
 {
     if (Tank != null)
     {
         //Camera.ViewOffset = CameraExt.ScreenToClip(Camera, Controller.InputExt.MousePos, Vector2Ext.ToOtk(Controller.CanvasSize)) * 0.4f;
         Transform2 t = new Transform2(Tank.WorldTransform.Position, Camera.WorldTransform.Size, Camera.WorldTransform.Rotation,  Camera.WorldTransform.MirrorX);
         Camera.WorldTransform = t;
     }
     else
     {
         Camera.ViewOffset = new OpenTK.Vector2();
     }
 }
コード例 #11
0
ファイル: Portal.cs プロジェクト: AyyTee/Aventyr
        public static void Enter(IPortal portal, Body body, bool ignorePortalVelocity = false)
        {
            Transform2 transform = new Transform2(body.Position, 1, body.Rotation);
            Transform2 velocity = Transform2.CreateVelocity((Vector2)body.LinearVelocity, body.AngularVelocity);
            velocity = EnterVelocity(portal, 0.5f, velocity, ignorePortalVelocity);
            transform = Enter(portal, transform);
            body.Position = (Xna.Vector2)transform.Position;
            body.Rotation = transform.Rotation;
            body.LinearVelocity = (Xna.Vector2)velocity.Position;
            body.AngularVelocity = velocity.Rotation;

            BodyExt.ScaleFixtures(body, transform.Scale);
        }
コード例 #12
0
ファイル: MementoDrag.cs プロジェクト: AyyTee/Aventyr
 public MementoDrag(EditorObject transformable)
 {
     Transformable = transformable;
     _polygonCoord = transformable.GetPolygonCoord();
     _transform = null;
     if (_polygonCoord != null)
     {
         _parent = (IWall)transformable.Parent;
     }
     else
     {
         _transform = transformable.GetTransform();
     }
 }
コード例 #13
0
ファイル: Factory.cs プロジェクト: AyyTee/Aventyr
        public static void CreatePolygon(Body body, Transform2 transform, IList<Vector2> vertices)
        {
            Debug.Assert(body != null);
            Debug.Assert(transform != null);
            Debug.Assert(vertices != null && vertices.Count >= 3);
            List<Vector2> fixtureContour = Actor.GetFixtureContour(vertices, transform.Scale);
            fixtureContour = MathExt.SetWinding(fixtureContour, false);

            var convexList = PolygonExt.DecomposeConcave(fixtureContour);

            List<FarseerPhysics.Common.Vertices> vList = new List<FarseerPhysics.Common.Vertices>();

            BodyExt.SetTransform(body, transform);

            for (int i = convexList.Count - 1; i >= 0; i--)
            {
                int vertMax = FarseerPhysics.Settings.MaxPolygonVertices;
                int divs = 1 + convexList[i].Count / vertMax;
                if (divs < 2)
                {
                    continue;
                }
                int j = 1;
                while (j < convexList[i].Count)
                {
                    List<Vector2> list = new List<Vector2>();
                    list.Add(convexList[i][0]);

                    list.AddRange(convexList[i].GetRange(j, Math.Min(convexList[i].Count - j, vertMax - 1)));
                    j += vertMax - 2;
                    convexList.Add(list);
                }
                convexList.RemoveAt(i);
            }

            for (int i = 0; i < convexList.Count; i++)
            {
                var v1 = new FarseerPhysics.Common.Vertices();
                v1.AddRange(convexList[i].Select(v => (Xna.Vector2)v));

                vList.Add(v1);
                PolygonShape shape = new PolygonShape(v1, 1);
                Fixture fixture = body.CreateFixture(shape);
                FixtureData userData = FixtureExt.SetData(fixture);
            }
        }
コード例 #14
0
ファイル: Ray.cs プロジェクト: AyyTee/Aventyr
        /// <summary>
        /// Determine a position that is sufficiently far away from all portals so that it isn't ambiguous which side of a 
        /// portal the position is at.
        /// </summary>
        /// <param name="portals"></param>
        /// <param name="portalPrevious">The last portal that was exited.</param>
        /// <param name="transform"></param>
        /// <param name="velocity"></param>
        private static Transform2 AddMargin(IEnumerable<IPortal> portals, IPortal portalPrevious, Transform2 transform, Transform2 velocity)
        {
            transform = transform.ShallowClone();
            foreach (IPortal p in portals)
            {
                if (!Portal.IsValid(p))
                {
                    continue;
                }
                LineF exitLine = new LineF(Portal.GetWorldVerts(p));
                Vector2 position = transform.Position;
                double distanceToPortal = MathExt.PointLineDistance(position, exitLine, true);
                if (distanceToPortal < Portal.EnterMinDistance)
                {
                    Vector2 exitNormal = p.WorldTransform.GetRight();
                    Side sideOf;
                    if (p == portalPrevious)
                    {
                        sideOf = exitLine.GetSideOf(position + velocity.Position);
                    }
                    else
                    {
                        sideOf = exitLine.GetSideOf(position - velocity.Position);
                    }
                    if (sideOf != exitLine.GetSideOf(exitNormal + p.WorldTransform.Position))
                    {
                        exitNormal = -exitNormal;
                    }

                    Vector2 pos = exitNormal * (Portal.EnterMinDistance - (float)distanceToPortal);
                    transform.Position += pos;
                    break;
                }
            }
            return transform;
        }
コード例 #15
0
ファイル: WallAdded.cs プロジェクト: AyyTee/Aventyr
 public WallAdded(Wall wall)
 {
     ServerId = (int)wall.ServerId;
     Vertices = wall.Vertices.ToArray();
     Transform = wall.GetTransform();
 }
コード例 #16
0
 public Cone()
 {
     color     = Color.Orange;
     transform = new Transform2(new Size2(400, 400));
     angle     = new Rotation2(90);
 }
コード例 #17
0
ファイル: Sprite.cs プロジェクト: zockware/MonoGame.Extended
 public RectangleF GetBoundingRectangle(Transform2 transform)
 {
     return(GetBoundingRectangle(transform.Position, transform.Rotation, transform.Scale));
 }
コード例 #18
0
 public SpriteAnimationFrame(Texture2D sprite, float scale, float durationInSeconds)
 {
     _sprite           = sprite;
     _transform        = new Transform2(new Size2((int)(sprite.Width * scale), (int)(sprite.Height * scale)));
     DurationInSeconds = durationInSeconds;
 }
コード例 #19
0
        public void Draw(Transform2 parentTransform)
        {
            var position = parentTransform + Transform;

            World.DrawRotatedFromCenter(_background, position.ToRectangle(), Transform.Rotation);
        }
コード例 #20
0
ファイル: UI.cs プロジェクト: EnigmaDragons/MonoGameJam
 public static void Draw(string imageName, Transform2 transform, Color tint)
 {
     SpriteBatch.Draw(Resources.Load <Texture2D>(imageName), ScaleRectangle(transform.ToRectangle()), tint);
 }
コード例 #21
0
 public void Draw(Transform2 parentTransform)
 {
     _dialogBox.Draw(parentTransform);
     _chatBox.Draw(parentTransform);
     _faceImage.Draw(parentTransform);
 }
コード例 #22
0
 public void Draw(Transform2 parentTransform)
 {
     _visuals.ForEach(x => x.Draw(parentTransform));
 }
コード例 #23
0
 public PoliceCruiserToDockingBay(Transform2 transform)
 {
     _transform   = transform;
     _destination = nameof(DockingBay);
 }
コード例 #24
0
 public ExpandingImageButton(string basic, string hover, string press, Transform2 transform, Size2 sizeIncrease, Action onClick)
     : this(basic, hover, press, transform, sizeIncrease, onClick, () => true)
 {
 }
コード例 #25
0
ファイル: Label.cs プロジェクト: EnigmaDragons/MegaBuy
 public void Draw(Transform2 parentTransform)
 {
     _background.Draw(parentTransform);
     UI.DrawTextAligned(Text, new Rectangle((parentTransform.Location + Transform.Location).ToPoint(), Transform.Size.ToPoint()), TextColor, Font, HorizontalAlignment);
 }
コード例 #26
0
ファイル: Rigidbody.cs プロジェクト: RhythNS/MonoNet
 protected override void OnInitialize()
 {
     transform = Actor.GetComponent <Transform2>();
 }
コード例 #27
0
        public void Draw(Transform2 parentTransform)
        {
            var position = parentTransform + Transform;

            World.Draw(_background, position.ToRectangle());
        }
コード例 #28
0
 public ColoredRectangle()
 {
     Transform   = new Transform2(new Size2(400, 100));
     _background = new RectangleTexture(Color.Transparent).Create();
 }
コード例 #29
0
ファイル: Portal.cs プロジェクト: AyyTee/Aventyr
        /// <summary>
        /// Returns a polygon in world space representing the 2D FOV through the portal.  
        /// Polygon is not guaranteed to be non-degenerate which can occur if the viewPoint is edge-on to the portal.
        /// </summary>
        public static Vector2[] GetFov(IPortal portal, Vector2 viewPoint, float distance, int detail, Transform2 transform)
        {
            Matrix4 a = transform.GetMatrix();
            Vector2[] verts = new Vector2[detail + 2];
            Vector2[] portalVerts = Portal.GetVerts(portal);
            for (int i = 0; i < portalVerts.Length; i++)
            {
                Vector4 b = Vector4.Transform(new Vector4(portalVerts[i].X, portalVerts[i].Y, 0, 1), a);
                verts[i] = new Vector2(b.X, b.Y);
            }
            //Minumum distance in order to prevent self intersections.
            const float errorMargin = 0.01f;
            float distanceMin = Math.Max((verts[0] - viewPoint).Length, (verts[1] - viewPoint).Length) + errorMargin;
            distance = Math.Max(distance, distanceMin);
            //get the leftmost and rightmost edges of the FOV
            verts[verts.Length - 1] = (verts[0] - viewPoint).Normalized() * distance + viewPoint;
            verts[2] = (verts[1] - viewPoint).Normalized() * distance + viewPoint;
            //find the angle between the edges of the FOV
            double angle0 = MathExt.AngleLine(verts[verts.Length - 1], viewPoint);
            double angle1 = MathExt.AngleLine(verts[2], viewPoint);
            double diff = MathExt.AngleDiff(angle0, angle1);
            Debug.Assert(diff <= Math.PI + double.Epsilon && diff >= -Math.PI);
            //handle case where lines overlap eachother
            /*const double angleDiffMin = 0.0001f;
            if (Math.Abs(diff) < angleDiffMin)
            {
                return new Vector2[0];
            }*/

            Matrix2 Rot = Matrix2.CreateRotation((float)diff / (detail - 1));
            for (int i = 3; i < verts.Length - 1; i++)
            {
                verts[i] = Vector2Ext.Transform(verts[i - 1] - viewPoint, Rot) + viewPoint;
            }
            return verts;
        }
コード例 #30
0
 public void Draw(Transform2 parentTransform)
 {
     _label.Draw(parentTransform);
 }
コード例 #31
0
 public void Add(IVisual visual, Transform2 transform)
 {
     _visuals[visual] = transform;
 }
コード例 #32
0
 public void Draw(Transform2 parentTransform)
 {
     _elements.ForEach(x => x.Draw(parentTransform));
 }
コード例 #33
0
 public static void DrawCentered(string imageName, Transform2 transform)
 {
     DrawCenteredWithOffset(imageName, transform.ToRectangle().Size.ToVector2(), transform.Location);
 }
コード例 #34
0
 public void Draw(Transform2 parentTransform)
 {
     _currentlyDisplayedMessage.Split('\n').ForEachIndex((l, i)
                                                         => UI.DrawText(l, new Vector2(parentTransform.Location.X, parentTransform.Location.Y + i * _lineSpacing), Color.White));
 }
コード例 #35
0
 public void Draw(Transform2 transform)
 {
     CurrentAnimation.Draw(transform);
 }
コード例 #36
0
ファイル: Portal.cs プロジェクト: AyyTee/Aventyr
 /// <summary>
 /// Get the portal's vertices in world coordinates.
 /// </summary>
 public static Vector2[] GetWorldVerts(IPortal portal, Transform2 worldTransform)
 {
     return Vector2Ext.Transform(GetVerts(portal), worldTransform.GetMatrix());
 }
コード例 #37
0
 public SceneActor(Scene scene) : base(scene)
 {
     Transform       = new Transform2();
     Transform.Scale = new System.Numerics.Vector2(1, 1);
 }
コード例 #38
0
 protected Clue(string roomImage, Transform2 position, Size2 zoomInSize, string clueId, string tooltip)
     : this(roomImage, roomImage, position, zoomInSize, clueId, tooltip)
 {
 }
コード例 #39
0
ファイル: SimulationStepTests.cs プロジェクト: AyyTee/Aventyr
        public void StepTest6()
        {
            Scene scene = new Scene();

            Actor actor = new Actor(scene, PolygonFactory.CreateRectangle(2, 2));
            actor.SetTransform(new Transform2(new Vector2(1, 1)));
            actor.SetVelocity(Transform2.CreateVelocity(new Vector2(0, 3)));
            Entity entity = new Entity(scene);
            entity.SetParent(actor);

            FloatPortal enter = new FloatPortal(scene);
            enter.SetTransform(new Transform2(new Vector2(1, 2), 1, (float)Math.PI/2));
            //enter.SetVelocity(Transform2.CreateVelocity(new Vector2(1, 0)));

            FloatPortal exit = new FloatPortal(scene);
            exit.SetTransform(new Transform2(new Vector2(10, 10)));
            //exit.SetVelocity(Transform2.CreateVelocity(new Vector2(10, 0)));

            enter.Linked = exit;
            exit.Linked = enter;

            PortalCommon.UpdateWorldTransform(scene);
            SimulationStep.Step(scene.GetAll().OfType<IPortalCommon>(), scene.GetAll().OfType<IPortal>(), 1, null);

            Transform2 expected = new Transform2(new Vector2(8, 10), 1, (float)Math.PI / 2, true);
            Assert.IsTrue(actor.WorldTransform.AlmostEqual(expected));
            Assert.IsTrue(entity.WorldTransform.AlmostEqual(expected));
            Assert.IsTrue(entity.GetTransform() == new Transform2());
            Assert.IsTrue(entity.GetVelocity() == Transform2.CreateVelocity());
            Assert.IsTrue(actor.GetTransform() == actor.WorldTransform);
        }
コード例 #40
0
ファイル: NodePortalable.cs プロジェクト: AyyTee/Aventyr
 public override void SetTransform(Transform2 transform)
 {
     Transform = transform.ShallowClone();
     base.SetTransform(transform);
 }
コード例 #41
0
 public void Draw(Transform2 parentTransform)
 {
 }
コード例 #42
0
ファイル: BulletData.cs プロジェクト: AyyTee/Aventyr
 public BulletData(Bullet bullet)
 {
     Transform = bullet.GetTransform();
     Velocity = bullet.GetVelocity();
     ServerId = (int)bullet.ServerId;
 }
コード例 #43
0
ファイル: PolygonExt.cs プロジェクト: AyyTee/Aventyr
 public static Transform2 GetTransform(IList<Vector2> vertices, IPolygonCoord coord)
 {
     Transform2 transform = new Transform2();
     LineF line = GetEdge(vertices, coord);
     transform.Position = line.Lerp(coord.EdgeT);
     transform.Rotation = -(float)MathExt.AngleVector(GetEdge(vertices, coord).GetNormal());
     return transform;
 }
コード例 #44
0
ファイル: Actor.cs プロジェクト: AyyTee/Aventyr
 /// <summary>
 /// Set Actor's velocity.  The scale component is ignored.
 /// </summary>
 public override void SetVelocity(Transform2 velocity)
 {
     BodyExt.SetVelocity(Body, velocity);
     base.SetVelocity(velocity);
 }
コード例 #45
0
ファイル: Portal.cs プロジェクト: AyyTee/Aventyr
        /// <summary>
        /// Returns new velocity from entering portal.
        /// </summary>
        /// <param name="portal">Portal being entered.</param>
        /// <param name="intersectT">Intersection point on the portal.</param>
        /// <param name="velocity">Velocity before entering.</param>
        public static Transform2 EnterVelocity(IPortal portal, float intersectT, Transform2 velocity, bool ignorePortalVelocity = false)
        {
            Debug.Assert(IsValid(portal));
            Matrix4 matrix = GetLinkedMatrix(portal);
            Vector2 origin = Vector2Ext.Transform(new Vector2(), matrix);
            Transform2 velocityClone = velocity.ShallowClone();

            if (!ignorePortalVelocity)
            {
                velocityClone.Position -= portal.WorldVelocity.Position;
                velocityClone.Rotation -= portal.WorldVelocity.Rotation;
                velocityClone.Position -= GetAngularVelocity(portal, intersectT);
            }
            velocityClone.Position = Vector2Ext.Transform(velocityClone.Position, matrix);
            velocityClone.Position -= origin;

            if (portal.WorldTransform.MirrorX == portal.Linked.WorldTransform.MirrorX)
            {
                velocityClone.Rotation = -velocityClone.Rotation;
            }
            if (!ignorePortalVelocity)
            {
                velocityClone.Position += portal.Linked.WorldVelocity.Position;
                velocityClone.Rotation += portal.Linked.WorldVelocity.Rotation;
                velocityClone.Position += GetAngularVelocity(portal.Linked, intersectT);
            }
            return velocityClone;
        }
コード例 #46
0
ファイル: Actor.cs プロジェクト: AyyTee/Aventyr
        private void _setTransform(Body body, Transform2 transform, bool checkScale = true)
        {
            if (checkScale && _scale != transform.Scale)
            {
                Debug.Assert(!Scene.InWorldStep, "Scale cannot change during a physics step.");

                BodyExt.ScaleFixtures(body, transform.Scale);
            }
            BodyExt.SetTransform(body, transform);

            foreach (BodyData data in BodyExt.GetData(body).Children)
            {
                _setTransform(data.Body, Portal.Enter(data.BodyParent.Portal, transform));
            }
        }
コード例 #47
0
ファイル: Portal.cs プロジェクト: AyyTee/Aventyr
 public static LineF[] GetFovLines(IPortal portal, Vector2 origin, float distance, Transform2 transform)
 {
     Vector2[] vertices = GetFov(portal, origin, distance);
     LineF[] lines = new LineF[] {
         new LineF(vertices[1], vertices[2]),
         new LineF(vertices[0], vertices[vertices.Length-1])
     };
     return lines;
 }
コード例 #48
0
 public void Draw(Transform2 parentTransform)
 {
     _visuals.ForEach(x => x.Key.Draw(x.Value + parentTransform));
 }
コード例 #49
0
ファイル: Portal.cs プロジェクト: AyyTee/Aventyr
 public static Transform2 Enter(IPortal portal, Transform2 transform)
 {
     Debug.Assert(IsValid(portal));
     return transform.Transform(GetLinkedTransform(portal, portal.Linked));
 }
コード例 #50
0
        public override void LoadContent()
        {
            var wallTexture = _sceneHandler._content.Load <Texture2D>("background2");

            wallSprite = new Sprite(wallTexture);
            transform  = new Transform2(new Vector2(512, 400));

            b2DWorld = new B2DWorld(new System.Numerics.Vector2(0.0f, 1.500000000000000e+01f));
            client   = new Client <Frame>(0);
            client.Connect(new IPEndPoint(IPAddress.Parse(_ip), 1337));
            inputClient = new Client <byte>(0);
            inputClient.Connect(inputEndPoint);

            var xx     = ProtoHelper.LoadEntities();
            var camera = new OrthographicCamera(_sceneHandler._graphicsDevice);

            ProtoHelper.OnChatRecieve += OnChatRecive;
            spriteBatch = new SpriteBatch(_sceneHandler._graphicsDevice);
            world       = new WorldBuilder()
                          .AddSystem(new RenderSystem(spriteBatch, camera))
                          .AddSystem(new PhysicsSystem())
                          .AddSystem(new MouseSystem())
                          .AddSystem(new MovementSystem())
                          .Build();

            _sceneHandler._gameComponents.Add(world);

            entityFactory = new EntityFactory(
                b2DWorld,
                world,
                _sceneHandler._content,
                _sceneHandler._graphicsDevice);

            foreach (var x in xx)
            {
                if (x.Kind == 2)
                {
                    entityFactory.CreateDynamicCircle(new Vector2(x.PositionX, x.PositionY), x.SizeX).Get <IRigidBody>().id = x.Id;
                }
                if (x.Kind == 3)
                {
                    var pars   = x.Params.Split(",");
                    var skin   = (skin)int.Parse(pars[1]);
                    var player = entityFactory.CreatePlayer(x.Params, new Vector2(x.PositionX, x.PositionY), skin.ToString());
                    player.Get <IRigidBody>().id = x.Id;
                }
                if (x.Params == "foot")
                {
                    entityFactory.CreateFoot(new Vector2(x.PositionX, x.PositionY), new Vector2(x.SizeX, x.SizeY)).Get <IRigidBody>().id = x.Id;
                }
                if (x.Params == "rfoot")
                {
                    entityFactory.CreateReverseFoot(new Vector2(x.PositionX, x.PositionY), new Vector2(x.SizeX, x.SizeY)).Get <IRigidBody>().id = x.Id;
                }
            }

            points      = entityFactory.CreateText(new Vector2(50, 50), "0", 0);
            enemyPoints = entityFactory.CreateText(new Vector2(720, 50), "0", 0);

            new TaskFactory().StartNew(() =>
            {
                while (true)
                {
                    try
                    {
                        var msg       = client.Listen();
                        var RigitBody = BodyFactory.RigidBodies.FirstOrDefault(x => x.id == msg.id);
                        if (RigitBody != null)
                        {
                            RigitBody.Position = new System.Numerics.Vector2(msg.X, msg.Y);
                            RigitBody.Angle    = msg.R;
                        }
                    }
                    catch { }
                }
            }
                                       );

            IsLoaded = true;
        }
コード例 #51
0
ファイル: ToolAddPortal.cs プロジェクト: AyyTee/Aventyr
 private Transform2 GetPortalTransform()
 {
     var coord = GetEdgeCoord();
     if (coord != null)
     {
         Transform2 transform = PolygonExt.GetTransform(coord.Wall.GetWorldVertices(), coord);
         transform.Size = 1;
         return transform;
     }
     else
     {
         Transform2 transform = new Transform2();
         transform.Position = Controller.GetMouseWorld();
         //transform.Rotation = _mouseFollow.GetTransform().Rotation;
         transform.Rotation = unsnapAngle;
         //Transform2.SetRotation(_mouseFollow, unsnapAngle);
         transform.Size = _mouseFollow.GetTransform().Size;
         transform.MirrorX = _mouseFollow.GetTransform().MirrorX;
         return transform;
     }
 }
コード例 #52
0
 public LobbyToVacantRoom(Transform2 transform)
     : base(transform, nameof(VacantRoom), "Traverse/LobbyDoor1", "To Raymond's Room")
 {
 }
コード例 #53
0
ファイル: NodePortalable.cs プロジェクト: AyyTee/Aventyr
 public override void SetVelocity(Transform2 velocity)
 {
     Velocity = velocity.ShallowClone();
     base.SetVelocity(velocity);
 }
コード例 #54
0
 private static RectangleF GetBoundingRectangle(Transform2 transform, Body body)
 {
     return(new RectangleF(transform.Position.X - body.Size.Width / 2f, transform.Position.Y + body.Size.Height / 2f, body.Size.Width, body.Size.Height));
 }
コード例 #55
0
ファイル: Actor.cs プロジェクト: AyyTee/Aventyr
 public override void SetTransform(Transform2 transform)
 {
     _setTransform(Body, transform);
     _scale = transform.Scale;
     base.SetTransform(transform);
 }
コード例 #56
0
 public void Draw(Transform2 parentTransform)
 {
     IfRunning(() => _visual.Draw(new Transform2(_currentPosition)));
 }
コード例 #57
0
ファイル: Actor.cs プロジェクト: AyyTee/Aventyr
 private static Transform2 UndoPortalTransform(BodyData data, Transform2 transform)
 {
     Transform2 copy = transform.ShallowClone();
     if (data.Parent == null)
     {
         return copy;
     }
     return UndoPortalTransform(
         data.Parent,
         copy.Transform(Portal.GetLinkedTransform(data.BodyParent.Portal).Inverted()));
 }
コード例 #58
0
 public void Draw(Transform2 parentTransform)
 {
     UI.DrawCentered(_image);
 }
コード例 #59
0
 public void Draw(Transform2 parentTransform)
 {
     World.Draw("Images/UI/" + _energy, parentTransform + _transform + new Transform2(Sizes.OverlayIcon));
 }
コード例 #60
0
ファイル: UI.cs プロジェクト: EnigmaDragons/MonoGameJam
 public static void Draw(string imageName, Transform2 transform)
 {
     Draw(imageName, transform.ToRectangle());
 }