/// <summary> /// Get all entity /// </summary> /// <param name="subPathUri"></param> /// <returns></returns> private async Task <List <TEntity> > ApiGetAsync(string subPathUri = null) { List <TEntity> currentReturnCollection = null; if (string.IsNullOrWhiteSpace(subPathUri)) { subPathUri = "/api/app/" + typeof(TEntity).Name; } try { if (_httpClient.BaseAddress == null) { _httpClient.BaseAddress = new Uri(_configurationManager.GetValue("ApiBaseAddress")); } if (await _apiAuthentication.ExecuteLoginAsync(_httpClient) == true) { HttpResponseMessage responseResult = _httpClient.GetAsync(subPathUri).Result; responseResult.EnsureSuccessStatusCode(); ContentWrapper <TEntityDto> deserializedContent = JsonConvert.DeserializeObject <ContentWrapper <TEntityDto> >(await responseResult.Content.ReadAsStringAsync()); currentReturnCollection = _mapper.Map <List <TEntityDto>, List <TEntity> >(deserializedContent.Items); } } catch (Exception apiCommunicationError) { _applicationLogTools.LogError(apiCommunicationError, new Dictionary <string, dynamic> { { "MethodName", "ApiGetAsync(string subPathUri = null)" }, { "ClassName", "ApiRepository " + typeof(TEntity).Name } }); } return(currentReturnCollection); }
public override void LoadContent() { base.LoadContent(); HasCursor = false; World.Gravity = new Vector2(0, 9.82f); _border = new Border(World, Lines, Framework.GraphicsDevice); CircleShape shape = new CircleShape(0.25f, 1); _grain = new Sprite(ContentWrapper.CircleTexture(0.25f, ContentWrapper.Gold, ContentWrapper.Grey)); _circles = new Body[48]; for (int i = 0; i < 48; i++) { _circles[i] = BodyFactory.CreateBody(World); _circles[i].BodyType = BodyType.Dynamic; _circles[i].Position = new Vector2(-24f + 1f * i, 10f); _circles[i].CreateFixture(shape); } _walker = new TheoJansenWalker(World, Vector2.Zero); }
public IActionResult Post([FromBody] ContentWrapper filetext) { var textbytes = Encoding.ASCII.GetBytes(filetext.Content); var request = WebRequest.Create($"https://file_service/api/files"); request.Credentials = CredentialCache.DefaultCredentials; request.Method = "POST"; request.ContentLength = textbytes.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(textbytes, 0, textbytes.Length); requestStream.Close(); var response = request.GetResponse(); Console.WriteLine(((HttpWebResponse)response).StatusDescription); string responseFromServer = null; using (var responseStream = response.GetResponseStream()) { StreamReader reader = new StreamReader(responseStream); responseFromServer = reader.ReadToEnd(); Console.WriteLine(responseFromServer); } response.Close(); return(Ok(responseFromServer)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, Lines, Framework.GraphicsDevice); _ragdoll = new Ragdoll(World, new Vector2(-20f, -10f)); _obstacles = new Body[9]; Vector2 stairStart = new Vector2(-23f, 0f); Vector2 stairDelta = new Vector2(2.5f, 1.65f); for (int i = 0; i < 9; i++) { _obstacles[i] = BodyFactory.CreateRectangle(World, 5f, 1.5f, 1f, stairStart + stairDelta * i); _obstacles[i].BodyType = BodyType.Static; } // create sprite based on body _obstacle = new Sprite(ContentWrapper.TextureFromShape(_obstacles[0].FixtureList[0].Shape, "Stripe", ContentWrapper.Red, ContentWrapper.Black, ContentWrapper.Black, 1.5f)); SetUserAgent(_ragdoll.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, LineBatch, Framework.GraphicsDevice); List <Vertices> tracedObject = Framework.Content.Load <List <Vertices> >("Pipeline/Object"); //scale the vertices from graphics space to sim space Vector2 vertScale = new Vector2(1f / 24f); AABB aabb = new AABB(); foreach (Vertices vertices in tracedObject) { vertices.Scale(new Vector2(1f, -1f)); vertices.Translate(new Vector2(0f, 0f)); var vaabb = vertices.GetAABB(); aabb.Combine(ref vaabb); } _polygonSize = new Vector2(aabb.Width, aabb.Height); // Create a single body with multiple fixtures _compound = World.CreateCompoundPolygon(tracedObject, 1f, Vector2.Zero, 0, BodyType.Dynamic); SetUserAgent(_compound, 200f, 200f); _objectSprite = new Sprite(ContentWrapper.GetTexture("Logo"), ContentWrapper.CalculateOrigin(_compound, 24f)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, Lines, Framework.GraphicsDevice); for (int i = 0; i < 3; i++) { _breakableCookie[i] = Framework.Content.Load <BodyContainer>("Pipeline/BreakableBody")["Cookie"].CreateBreakable(World); _breakableCookie[i].Strength = 120f; _breakableCookie[i].MainBody.Position = new Vector2(-20.33f + 15f * i, -5.33f); } _breakableSprite = new List <Sprite>(); List <Texture2D> textures = ContentWrapper.BreakableTextureFragments(_breakableCookie[0], "Cookie"); for (int i = 0; i < _breakableCookie[0].Parts.Count; i++) { AABB bounds; Transform transform; _breakableCookie[0].Parts[i].Body.GetTransform(out transform); _breakableCookie[0].Parts[i].Shape.ComputeAABB(out bounds, ref transform, 0); Vector2 origin = ConvertUnits.ToDisplayUnits(_breakableCookie[0].Parts[i].Body.Position - bounds.LowerBound); _breakableSprite.Add(new Sprite(textures[i], origin)); } _completeSprite = new Sprite(ContentWrapper.GetTexture("Cookie"), Vector2.Zero); }
public Agent(World world, Vector2 position) { _collidesWith = Category.All; _collisionCategories = Category.All; Body = BodyFactory.CreateBody(world, position); Body.BodyType = BodyType.Dynamic; //Center FixtureFactory.AttachCircle(0.5f, 0.5f, Body); //Left arm FixtureFactory.AttachRectangle(1.5f, 0.4f, 1f, new Vector2(-1f, 0f), Body); FixtureFactory.AttachCircle(0.5f, 0.5f, Body, new Vector2(-2f, 0f)); //Right arm FixtureFactory.AttachRectangle(1.5f, 0.4f, 1f, new Vector2(1f, 0f), Body); FixtureFactory.AttachCircle(0.5f, 0.5f, Body, new Vector2(2f, 0f)); //Top arm FixtureFactory.AttachRectangle(0.4f, 1.5f, 1f, new Vector2(0f, 1f), Body); FixtureFactory.AttachCircle(0.5f, 0.5f, Body, new Vector2(0f, 2f)); //Bottom arm FixtureFactory.AttachRectangle(0.4f, 1.5f, 1f, new Vector2(0f, -1f), Body); FixtureFactory.AttachCircle(0.5f, 0.5f, Body, new Vector2(0f, -2f)); //GFX _box = new Sprite(ContentWrapper.PolygonTexture(PolygonUtils.CreateRectangle(1.75f, 0.2f), Color.White, ContentWrapper.Black)); _knob = new Sprite(ContentWrapper.CircleTexture(0.5f, "Square", ContentWrapper.Black, ContentWrapper.Gold, ContentWrapper.Black, 1f)); _offset = ConvertUnits.ToDisplayUnits(2f); }
public Pyramid(World world, Vector2 position, int count, float density) { Vertices rect = PolygonUtils.CreateRectangle(0.5f, 0.5f); PolygonShape shape = new PolygonShape(rect, density); Vector2 rowStart = position; rowStart.Y -= 0.5f + count * 1.1f; Vector2 deltaRow = new Vector2(-0.625f, 1.1f); const float spacing = 1.25f; // Physics _boxes = new List <Body>(); for (int i = 0; i < count; i++) { Vector2 pos = rowStart; for (int j = 0; j < i + 1; j++) { Body body = BodyFactory.CreateBody(world); body.BodyType = BodyType.Dynamic; body.Position = pos; body.CreateFixture(shape); _boxes.Add(body); pos.X += spacing; } rowStart += deltaRow; } //GFX _box = new Sprite(ContentWrapper.PolygonTexture(rect, "Square", ContentWrapper.Blue, ContentWrapper.Gold, ContentWrapper.Black, 1f)); }
public override void LoadContent() { base.LoadContent(); LoadOptions(); Viewport viewport = Framework.GraphicsDevice.Viewport; _font = ContentWrapper.GetFont("MenuFont"); _checkmark = ContentWrapper.GetTexture("Checkmark"); _optionStart = (viewport.Height - (_optionEntries.Count - 1) * (_optionEntrySize.Y + EntrySpacer)) / 2f; _optionSpacing = _optionEntrySize.Y + EntrySpacer; for (int i = 0; i < _optionEntries.Count; i++) { _optionEntries[i].InitializePosition(new Vector2(viewport.Width / 2f, _optionStart + _optionSpacing * i)); } // The background includes a border somewhat larger than the text itself. _topLeft.X = viewport.Width / 2f - _optionEntrySize.X / 2f - HorizontalPadding; _topLeft.Y = _optionStart - _optionEntrySize.Y / 2f - VerticalPadding; _bottomRight.X = viewport.Width / 2f + _optionEntrySize.X / 2f + HorizontalPadding; _bottomRight.Y = _optionStart + (_optionEntries.Count - 1) * _optionSpacing + _optionEntrySize.Y / 2f + VerticalPadding; }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, LineBatch, Framework.GraphicsDevice); Vertices rectangle1 = PolygonTools.CreateRectangle(_rectangleSize.X / 2f, _rectangleSize.Y / 2f); Vertices rectangle2 = PolygonTools.CreateRectangle(_rectangleSize.X / 2f, _rectangleSize.Y / 2f); rectangle1.Translate(-_offset); rectangle2.Translate(_offset); List <Vertices> vertices = new List <Vertices>(2); vertices.Add(rectangle1); vertices.Add(rectangle2); _rectangles = World.CreateCompoundPolygon(vertices, 1f); _rectangles.BodyType = BodyType.Dynamic; SetUserAgent(_rectangles, 200f, 200f); // create sprite based on rectangle fixture _rectangleSprite = new Sprite(ContentWrapper.PolygonTexture(rectangle1, "Square", ContentWrapper.Blue, ContentWrapper.Gold, ContentWrapper.Black, 1f, 24f)); }
public Agent(World world, Vector2 position) { _collidesWith = Category.All; _collisionCategories = Category.All; _agentBody = world.CreateBody(position); _agentBody.BodyType = BodyType.Dynamic; //Center _agentBody.CreateCircle(0.5f, 0.5f); //Left arm _agentBody.CreateRectangle(1.5f, 0.4f, 1f, new Vector2(-1f, 0f)); _agentBody.CreateCircle(0.5f, 0.5f, new Vector2(-2f, 0f)); //Right arm _agentBody.CreateRectangle(1.5f, 0.4f, 1f, new Vector2(1f, 0f)); _agentBody.CreateCircle(0.5f, 0.5f, new Vector2(2f, 0f)); //Top arm _agentBody.CreateRectangle(0.4f, 1.5f, 1f, new Vector2(0f, 1f)); _agentBody.CreateCircle(0.5f, 0.5f, new Vector2(0f, 2f)); //Bottom arm _agentBody.CreateRectangle(0.4f, 1.5f, 1f, new Vector2(0f, -1f)); _agentBody.CreateCircle(0.5f, 0.5f, new Vector2(0f, -2f)); //GFX _box = new Sprite(ContentWrapper.PolygonTexture(PolygonTools.CreateRectangle(2.5f / 2f, 0.4f / 2f), Color.White, ContentWrapper.Black, 24f)); _knob = new Sprite(ContentWrapper.CircleTexture(0.5f, "Square", ContentWrapper.Black, ContentWrapper.Gold, ContentWrapper.Black, 1f, 24f)); _offset = 2f; }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, -20f); _border = new Border(World, LineBatch, Framework.GraphicsDevice); _ramps = World.CreateBody(); _ramps.CreateEdge(new Vector2(-20f, 11.2f), new Vector2(10f, 3.8f)); _ramps.CreateEdge(new Vector2(12f, 5.6f), new Vector2(12f, 3.2f)); _ramps.CreateEdge(new Vector2(-10f, -4.4f), new Vector2(20f, 1.4f)); _ramps.CreateEdge(new Vector2(-12f, -2.6f), new Vector2(-12f, -5f)); _ramps.CreateEdge(new Vector2(-20f, -6.8f), new Vector2(10f, -11.5f)); float[] friction = { 0.75f, 0.45f, 0.28f, 0.17f, 0.0f }; for (int i = 0; i < 5; i++) { _rectangle[i] = World.CreateRectangle(1.5f, 1.5f, 1f); _rectangle[i].BodyType = BodyType.Dynamic; _rectangle[i].Position = new Vector2(-18f + 5.2f * i, 13.0f - 1.282f * i); _rectangle[i].SetFriction(friction[i]); } // create sprite based on body _rectangleSprite = new Sprite(ContentWrapper.TextureFromShape(_rectangle[0].FixtureList[0].Shape, "Square", ContentWrapper.Green, ContentWrapper.Lime, ContentWrapper.Black, 1f, 24f)); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, Lines, Framework.GraphicsDevice); _agent = new Agent(World, new Vector2(-6.9f, -11f)); // Obstacles for (int i = 0; i < 5; i++) { _obstacles[i] = BodyFactory.CreateRectangle(World, 5f, 1f, 1f); _obstacles[i].BodyType = BodyType.Static; _obstacles[i].Restitution = 0.2f; _obstacles[i].Friction = 0.2f; } _obstacles[0].Position = new Vector2(-5f, 9f); _obstacles[1].Position = new Vector2(15f, 6f); _obstacles[2].Position = new Vector2(10f, -3f); _obstacles[3].Position = new Vector2(-10f, -9f); _obstacles[4].Position = new Vector2(-17f, 0f); // create sprite based on body _obstacle = new Sprite(ContentWrapper.TextureFromShape(_obstacles[0].FixtureList[0].Shape, "Stripe", ContentWrapper.Gold, ContentWrapper.Black, ContentWrapper.Black, 1.5f)); SetUserAgent(_agent.Body, 1000f, 400f); }
public override void LoadContent() { base.LoadContent(); World.Gravity = Vector2.Zero; _border = new Border(World, Lines, Framework.GraphicsDevice); Vertices rectangle1 = PolygonUtils.CreateRectangle(2f, 2f); Vertices rectangle2 = PolygonUtils.CreateRectangle(2f, 2f); Vector2 translation = new Vector2(-2f, 0f); rectangle1.Translate(ref translation); translation = new Vector2(2f, 0f); rectangle2.Translate(ref translation); List <Vertices> vertices = new List <Vertices>(2); vertices.Add(rectangle1); vertices.Add(rectangle2); _rectangles = BodyFactory.CreateCompoundPolygon(World, vertices, 1f); _rectangles.BodyType = BodyType.Dynamic; SetUserAgent(_rectangles, 200f, 200f); // create sprite based on rectangle fixture _rectangleSprite = new Sprite(ContentWrapper.PolygonTexture(rectangle1, "Square", ContentWrapper.Blue, ContentWrapper.Gold, ContentWrapper.Black, 1f)); _offset = new Vector2(ConvertUnits.ToDisplayUnits(2f), 0f); }
/// <summary> /// Loads graphics content for this screen. The background texture is quite /// big, so we use our own local ContentManager to load it. This allows us /// to unload before going from the menus into the game itself, wheras if we /// used the shared ContentManager provided by the Game class, the content /// would remain loaded forever. /// </summary> public override void LoadContent() { _logoTexture = ContentWrapper.GetTexture("Logo"); Viewport viewport = Framework.GraphicsDevice.Viewport; _logoPosition = new Vector2((viewport.Width - _logoTexture.Width) / 2f - 100f, (viewport.Height - _logoTexture.Height) / 2f); }
private void PrintPageInfo( Page page, int index ) { // 1. Showing basic page information... Console.WriteLine(" Index (calculated): " + page.Index + " (should be " + index + ")"); Console.WriteLine(" ID: " + ((PdfReference)page.BaseObject).Id); PdfDictionary pageDictionary = page.BaseDataObject; Console.WriteLine(" Dictionary entries:"); foreach (KeyValuePair <PdfName, PdfDirectObject> entry in pageDictionary) { Console.WriteLine(" " + entry.Key.Value + " = " + entry.Value); } // 2. Showing page contents information... ContentWrapper contents = page.Contents; Console.WriteLine(" Content objects count: " + contents.Count); Console.WriteLine(" Content head:"); PrintContentObjects(contents, 0, 0); // 3. Showing page resources information... { Resources resources = page.Resources; Console.WriteLine(" Resources:"); try { Console.WriteLine(" Font count: " + resources.Fonts.Count); } catch { } try { Console.WriteLine(" XObjects count: " + resources.XObjects.Count); } catch { } try { Console.WriteLine(" ColorSpaces count: " + resources.ColorSpaces.Count); } catch { } } }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _ramps = BodyFactory.CreateBody(World); FixtureFactory.AttachEdge(new Vector2(-20f, -11.2f), new Vector2(10f, -3.8f), _ramps); FixtureFactory.AttachEdge(new Vector2(12f, -5.6f), new Vector2(12f, -3.2f), _ramps); FixtureFactory.AttachEdge(new Vector2(-10f, 4.4f), new Vector2(20f, -1.4f), _ramps); FixtureFactory.AttachEdge(new Vector2(-12f, 2.6f), new Vector2(-12f, 5f), _ramps); FixtureFactory.AttachEdge(new Vector2(-20f, 6.8f), new Vector2(10f, 11.5f), _ramps); float[] friction = { 0.75f, 0.45f, 0.28f, 0.17f, 0.0f }; for (int i = 0; i < 5; i++) { _rectangle[i] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _rectangle[i].BodyType = BodyType.Dynamic; _rectangle[i].Position = new Vector2(-18f + 5.2f * i, -13.0f + 1.282f * i); _rectangle[i].Friction = friction[i]; } // create sprite based on body _rectangleSprite = new Sprite(ContentWrapper.TextureFromShape(_rectangle[0].FixtureList[0].Shape, "Square", ContentWrapper.Green, ContentWrapper.Lime, ContentWrapper.Black, 1f)); }
private void CreateLegTextures() { Vector2 p1 = new Vector2(-5.4f, -6.1f); Vector2 p2 = new Vector2(-7.2f, -1.2f); Vector2 p3 = new Vector2(-4.3f, -1.9f); Vector2 p4 = Vector2.Zero; Vector2 p5 = new Vector2(-2.9f, 0.7f); Vector2 p6 = new Vector2(0.6f, 2.9f); _leftShoulder = new Sprite(ContentWrapper.PolygonTexture(new[] { p4, p5, p6 }, Color.White * 0.6f, ContentWrapper.Black, 24f)); _leftShoulder.Origin = ContentWrapper.CalculateOrigin(_leftShoulders[0], 24f); _leftLeg = new Sprite(ContentWrapper.PolygonTexture(new[] { p1, p3, p2 }, Color.White * 0.6f, ContentWrapper.Black, 24f)); _leftLeg.Origin = ContentWrapper.CalculateOrigin(_leftLegs[0], 24f); p1.X *= -1f; p2.X *= -1f; p3.X *= -1f; p5.X *= -1f; p6.X *= -1f; _rightShoulder = new Sprite(ContentWrapper.PolygonTexture(new[] { p4, p6, p5 }, Color.White * 0.6f, ContentWrapper.Black, 24f)); _rightShoulder.Origin = ContentWrapper.CalculateOrigin(_rightShoulders[0], 24f); _rightLeg = new Sprite(ContentWrapper.PolygonTexture(new[] { p1, p2, p3 }, Color.White * 0.6f, ContentWrapper.Black, 24f)); _rightLeg.Origin = ContentWrapper.CalculateOrigin(_rightLegs[0], 24f); }
public Objects(World world, Vector2 startPosition, Vector2 endPosition, int count, float radius, ObjectType type, float toothHeight = 1f) { _bodyRadius = radius; BodyList = new List <Body>(count); for (int i = 0; i < count; i++) { switch (type) { case ObjectType.Circle: BodyList.Add(world.CreateCircle(radius, 1f)); break; case ObjectType.Rectangle: BodyList.Add(world.CreateRectangle(radius, radius, 1f)); _bodyRadius = radius / 2f; break; case ObjectType.Star: BodyList.Add(world.CreateGear(radius, 10, 0f, toothHeight, 1f)); _bodyRadius = radius * 2.7f; break; case ObjectType.Gear: BodyList.Add(world.CreateGear(radius, 10, 100f, toothHeight, 1f)); _bodyRadius = radius * 2.7f; break; } } for (int i = 0; i < BodyList.Count; i++) { Body body = BodyList[i]; body.BodyType = BodyType.Dynamic; body.Position = Vector2.Lerp(startPosition, endPosition, i / (float)(count - 1)); body.SetRestitution(0.7f); body.SetFriction(0.2f); } //GFX switch (type) { case ObjectType.Circle: _object = new Sprite(ContentWrapper.CircleTexture(radius, ContentWrapper.Gold, ContentWrapper.Grey, 24f)); break; case ObjectType.Rectangle: _object = new Sprite(ContentWrapper.PolygonTexture(PolygonTools.CreateRectangle(radius / 2f, radius / 2f), ContentWrapper.Red, ContentWrapper.Grey, 24f)); break; case ObjectType.Star: _object = new Sprite(ContentWrapper.PolygonTexture(PolygonTools.CreateGear(radius, 10, 0f, toothHeight), ContentWrapper.Brown, ContentWrapper.Black, 24f)); break; case ObjectType.Gear: _object = new Sprite(ContentWrapper.PolygonTexture(PolygonTools.CreateGear(radius, 10, 100f, toothHeight), ContentWrapper.Orange, ContentWrapper.Grey, 24f)); break; } }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _border = new Border(World, Lines, Framework.GraphicsDevice); _obstacles = new Body(World); FixtureFactory.AttachEdge(new Vector2(-16f, -1f), new Vector2(-14f, 1f), _obstacles); FixtureFactory.AttachEdge(new Vector2(-14f, 1f), new Vector2(-12f, -1f), _obstacles); FixtureFactory.AttachEdge(new Vector2(14f, -1f), new Vector2(12f, 5f), _obstacles); FixtureFactory.AttachEdge(new Vector2(14f, -1f), new Vector2(16f, 5f), _obstacles); _angleBody[0] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _angleBody[0].BodyType = BodyType.Dynamic; _angleBody[0].Friction = 0.7f; _angleBody[0].Position = new Vector2(-15f, -5f); _angleBody[1] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _angleBody[1].BodyType = BodyType.Dynamic; _angleBody[1].Friction = 0.7f; _angleBody[1].Position = new Vector2(-18f, 5f); _angleBody[2] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _angleBody[2].BodyType = BodyType.Dynamic; _angleBody[2].Friction = 0.7f; _angleBody[2].Position = new Vector2(-10f, 5f); World.AddJoint(new AngleJoint(_angleBody[0], _angleBody[1])); World.AddJoint(new AngleJoint(_angleBody[0], _angleBody[2])); _distanceBody[0] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[0].BodyType = BodyType.Dynamic; _distanceBody[0].Friction = 0.7f; _distanceBody[0].Position = new Vector2(11.5f, -4f); _distanceBody[1] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[1].BodyType = BodyType.Dynamic; _distanceBody[1].Friction = 0.7f; _distanceBody[1].Position = new Vector2(16.5f, -4f); _distanceBody[2] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[2].BodyType = BodyType.Dynamic; _distanceBody[2].Friction = 0.7f; _distanceBody[2].Position = new Vector2(11.5f, -6f); _distanceBody[3] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[3].BodyType = BodyType.Dynamic; _distanceBody[3].Friction = 0.7f; _distanceBody[3].Position = new Vector2(16.5f, -6f); DistanceJoint softDistance = new DistanceJoint(_distanceBody[0], _distanceBody[1], Vector2.Zero, Vector2.Zero, false); softDistance.DampingRatio = 0.3f; softDistance.Frequency = 5f; World.AddJoint(softDistance); World.AddJoint(new DistanceJoint(_distanceBody[2], _distanceBody[3], Vector2.Zero, Vector2.Zero, false)); // create sprites based on bodies _angleCube = new Sprite(ContentWrapper.TextureFromShape(_angleBody[0].FixtureList[0].Shape, "Square", ContentWrapper.Gold, ContentWrapper.Orange, ContentWrapper.Grey, 1f)); _distanceCube = new Sprite(ContentWrapper.TextureFromShape(_distanceBody[0].FixtureList[0].Shape, "Stripe", ContentWrapper.Red, ContentWrapper.Blue, ContentWrapper.Grey, 4f)); }
public void LoadContent(Viewport viewport) { Texture2D cursorTexture; cursorTexture = ContentWrapper.GetTexture("Cursor"); _cursorSprite = new Sprite(cursorTexture, Vector2.One); _viewport = viewport; }
private void RemoveContent(ContentWrapper contentWrapper) { Contract.Requires(contentWrapper != null); Util.ThrowUnless(!_content.Contains(contentWrapper), "The content wrapper should already be removed"); Util.ThrowUnless(_contentElement != null && _contentElement.Children.Contains(contentWrapper)); contentWrapper.ClearChild(); _contentElement.Children.Remove(contentWrapper); }
private void addContentWrapper(string txt, Texture image) { appearColor.a = 0; ContentWrapper wrapper = new ContentWrapper(txt, image, msgStyle, contentWidth); contents.Add(wrapper); contentHeight += wrapper.getContentHeight(); }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0f, 20f); _obstacles = BodyFactory.CreateBody(World); FixtureFactory.AttachEdge(new Vector2(-16f, -1f), new Vector2(-14f, 1f), _obstacles); FixtureFactory.AttachEdge(new Vector2(-14f, 1f), new Vector2(-12f, -1f), _obstacles); FixtureFactory.AttachEdge(new Vector2(14f, -1f), new Vector2(12f, 5f), _obstacles); FixtureFactory.AttachEdge(new Vector2(14f, -1f), new Vector2(16f, 5f), _obstacles); _angleBody[0] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _angleBody[0].BodyType = BodyType.Dynamic; _angleBody[0].Friction = 0.7f; _angleBody[0].Position = new Vector2(-15f, -5f); _angleBody[1] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _angleBody[1].BodyType = BodyType.Dynamic; _angleBody[1].Friction = 0.7f; _angleBody[1].Position = new Vector2(-18f, 5f); _angleBody[2] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _angleBody[2].BodyType = BodyType.Dynamic; _angleBody[2].Friction = 0.7f; _angleBody[2].Position = new Vector2(-10f, 5f); World.AddJoint(new AngleJoint(_angleBody[0], _angleBody[1])); World.AddJoint(new AngleJoint(_angleBody[0], _angleBody[2])); _distanceBody[0] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[0].BodyType = BodyType.Dynamic; _distanceBody[0].Friction = 0.7f; _distanceBody[0].Position = new Vector2(11.5f, -4f); _distanceBody[1] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[1].BodyType = BodyType.Dynamic; _distanceBody[1].Friction = 0.7f; _distanceBody[1].Position = new Vector2(16.5f, -4f); _distanceBody[2] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[2].BodyType = BodyType.Dynamic; _distanceBody[2].Friction = 0.7f; _distanceBody[2].Position = new Vector2(11.5f, -6f); _distanceBody[3] = BodyFactory.CreateRectangle(World, 1.5f, 1.5f, 1f); _distanceBody[3].BodyType = BodyType.Dynamic; _distanceBody[3].Friction = 0.7f; _distanceBody[3].Position = new Vector2(16.5f, -6f); DistanceJoint softDistance = new DistanceJoint(_distanceBody[0], _distanceBody[1], Vector2.Zero, Vector2.Zero); JointHelper.LinearStiffness(5f, 0.3f, softDistance.BodyA, softDistance.BodyB, out var stiffness, out var damping); softDistance.Damping = damping; softDistance.Stiffness = stiffness; World.AddJoint(softDistance); World.AddJoint(new DistanceJoint(_distanceBody[2], _distanceBody[3], Vector2.Zero, Vector2.Zero)); // create sprites based on bodies _angleCube = new Sprite(ContentWrapper.TextureFromShape(_angleBody[0].FixtureList[0].Shape, "Square", ContentWrapper.Gold, ContentWrapper.Orange, ContentWrapper.Grey, 1f)); _distanceCube = new Sprite(ContentWrapper.TextureFromShape(_distanceBody[0].FixtureList[0].Shape, "Stripe", ContentWrapper.Red, ContentWrapper.Blue, ContentWrapper.Grey, 4f)); }
public Objects(World world, Vector2 startPosition, Vector2 endPosition, int count, float radius, ObjectType type) { _bodies = new List <Body>(count); CollidesWith = Category.All; CollisionCategories = Category.All; // Physics for (int i = 0; i < count; i++) { switch (type) { case ObjectType.Circle: _bodies.Add(BodyFactory.CreateCircle(world, radius, 1f)); break; case ObjectType.Rectangle: _bodies.Add(BodyFactory.CreateRectangle(world, radius, radius, 1f)); break; case ObjectType.Star: _bodies.Add(BodyFactory.CreateGear(world, radius, 10, 0f, 1f, 1f)); break; case ObjectType.Gear: _bodies.Add(BodyFactory.CreateGear(world, radius, 10, 100f, 1f, 1f)); break; } } for (int i = 0; i < _bodies.Count; i++) { Body body = _bodies[i]; body.BodyType = BodyType.Dynamic; body.Position = Vector2.Lerp(startPosition, endPosition, i / (float)(count - 1)); body.Restitution = 0.7f; body.Friction = 0.2f; } //GFX switch (type) { case ObjectType.Circle: _object = new Sprite(ContentWrapper.CircleTexture(radius, ContentWrapper.Gold, ContentWrapper.Grey)); break; case ObjectType.Rectangle: _object = new Sprite(ContentWrapper.PolygonTexture(PolygonTools.CreateRectangle(radius / 2f, radius / 2f), ContentWrapper.Red, ContentWrapper.Grey)); break; case ObjectType.Star: _object = new Sprite(ContentWrapper.PolygonTexture(PolygonTools.CreateGear(radius, 10, 0f, 1f), ContentWrapper.Brown, ContentWrapper.Black)); break; case ObjectType.Gear: _object = new Sprite(ContentWrapper.PolygonTexture(PolygonTools.CreateGear(radius, 10, 100f, 1f), ContentWrapper.Orange, ContentWrapper.Grey)); break; } }
public override void LoadContent() { base.LoadContent(); World.Gravity = new Vector2(0, 9.82f); _border = new Border(World, Lines, Framework.GraphicsDevice); // Bridge // We make a path using 2 points. Path bridgePath = new Path(); bridgePath.Add(new Vector2(-15, 5)); bridgePath.Add(new Vector2(15, 5)); bridgePath.Closed = false; Vertices box = PolygonTools.CreateRectangle(0.125f, 0.5f); PolygonShape shape = new PolygonShape(box, 20); _bridgeBodies = PathManager.EvenlyDistributeShapesAlongPath(World, bridgePath, shape, BodyType.Dynamic, 29); // Attach the first and last fixtures to the world Body anchor = new Body(World, Vector2.Zero); anchor.BodyType = BodyType.Static; World.AddJoint(new RevoluteJoint(_bridgeBodies[0], anchor, _bridgeBodies[0].Position - new Vector2(0.5f, 0f), true)); World.AddJoint(new RevoluteJoint(_bridgeBodies[_bridgeBodies.Count - 1], anchor, _bridgeBodies[_bridgeBodies.Count - 1].Position + new Vector2(0.5f, 0f), true)); PathManager.AttachBodiesWithRevoluteJoint(World, _bridgeBodies, new Vector2(0f, -0.5f), new Vector2(0f, 0.5f), false, true); // Soft body // We make a rectangular path. Path rectanglePath = new Path(); rectanglePath.Add(new Vector2(-6, -11)); rectanglePath.Add(new Vector2(-6, 1)); rectanglePath.Add(new Vector2(6, 1)); rectanglePath.Add(new Vector2(6, -11)); rectanglePath.Closed = true; // Creating two shapes. A circle to form the circle and a rectangle to stabilize the soft body. Shape[] shapes = new Shape[2]; shapes[0] = new PolygonShape(PolygonTools.CreateRectangle(0.5f, 0.5f, new Vector2(-0.1f, 0f), 0f), 1f); shapes[1] = new CircleShape(0.5f, 1f); // We distribute the shapes in the rectangular path. _softBodies = PathManager.EvenlyDistributeShapesAlongPath(World, rectanglePath, shapes, BodyType.Dynamic, 30); // Attach the bodies together with revolute joints. The rectangular form will converge to a circular form. PathManager.AttachBodiesWithRevoluteJoint(World, _softBodies, new Vector2(0f, -0.5f), new Vector2(0f, 0.5f), true, true); // GFX _bridgeBox = new Sprite(ContentWrapper.TextureFromShape(shape, ContentWrapper.Orange, ContentWrapper.Brown)); _softBodyBox = new Sprite(ContentWrapper.TextureFromShape(shapes[0], ContentWrapper.Green, ContentWrapper.Black)); _softBodyBox.Origin += new Vector2(ConvertUnits.ToDisplayUnits(0.1f), 0f); _softBodyCircle = new Sprite(ContentWrapper.TextureFromShape(shapes[1], ContentWrapper.Lime, ContentWrapper.Grey)); }
public MeansSearchPage() { InitializeComponent(); _viewModel = new MeansSearchPageViewModel(); _viewModel.Navigation = Navigation; _viewModel.Description = Common.txt_SearchDescription; _viewModel.DescriptionIsVisible = true; BindingContext = _viewModel; ContentWrapper.TranslateTo(0, 100, 0); Image_Search.FadeTo(1, 0); }
private void maskMouseLeftButtonDown(ContentWrapper wrapper) { Debug.Assert(wrapper == _contentElement.Children.Last()); var lastContent = _content.LastOrDefault(); if (lastContent != null) { lastContent.OnMaskClicked(); } }
public JumpySpider(World world, Vector2 position) { // Body _circle = BodyFactory.CreateCircle(world, SpiderBodyRadius, 0.1f, position); _circle.BodyType = BodyType.Dynamic; // Left upper leg _leftUpper = BodyFactory.CreateRectangle(world, _upperLegSize.X, _upperLegSize.Y, 0.1f, _circle.Position - new Vector2(SpiderBodyRadius, 0f) - new Vector2(_upperLegSize.X / 2f, 0f)); _leftUpper.BodyType = BodyType.Dynamic; // Left lower leg _leftLower = BodyFactory.CreateRectangle(world, _lowerLegSize.X, _lowerLegSize.Y, 0.1f, _circle.Position - new Vector2(SpiderBodyRadius, 0f) - new Vector2(_upperLegSize.X, 0f) - new Vector2(_lowerLegSize.X / 2f, 0f)); _leftLower.BodyType = BodyType.Dynamic; // Right upper leg _rightUpper = BodyFactory.CreateRectangle(world, _upperLegSize.X, _upperLegSize.Y, 0.1f, _circle.Position + new Vector2(SpiderBodyRadius, 0f) + new Vector2(_upperLegSize.X / 2f, 0f)); _rightUpper.BodyType = BodyType.Dynamic; // Right lower leg _rightLower = BodyFactory.CreateRectangle(world, _lowerLegSize.X, _lowerLegSize.Y, 0.1f, _circle.Position + new Vector2(SpiderBodyRadius, 0f) + new Vector2(_upperLegSize.X, 0f) + new Vector2(_lowerLegSize.X / 2f, 0f)); _rightLower.BodyType = BodyType.Dynamic; //Create joints JointFactory.CreateRevoluteJoint(world, _circle, _leftUpper, new Vector2(_upperLegSize.X / 2f, 0f)); _leftShoulderAngleJoint = JointFactory.CreateAngleJoint(world, _circle, _leftUpper); _leftShoulderAngleJoint.MaxImpulse = 3f; JointFactory.CreateRevoluteJoint(world, _circle, _rightUpper, new Vector2(-_upperLegSize.X / 2f, 0f)); _rightShoulderAngleJoint = JointFactory.CreateAngleJoint(world, _circle, _rightUpper); _rightShoulderAngleJoint.MaxImpulse = 3f; JointFactory.CreateRevoluteJoint(world, _leftUpper, _leftLower, new Vector2(_lowerLegSize.X / 2f, 0f)); _leftKneeAngleJoint = JointFactory.CreateAngleJoint(world, _leftUpper, _leftLower); _leftKneeAngleJoint.MaxImpulse = 3f; JointFactory.CreateRevoluteJoint(world, _rightUpper, _rightLower, new Vector2(-_lowerLegSize.X / 2f, 0f)); _rightKneeAngleJoint = JointFactory.CreateAngleJoint(world, _rightUpper, _rightLower); _rightKneeAngleJoint.MaxImpulse = 3; //GFX _torso = new Sprite(ContentWrapper.CircleTexture(SpiderBodyRadius, "Square", ContentWrapper.Grey, ContentWrapper.Gold, ContentWrapper.Black, 1f)); _upperLeg = new Sprite(ContentWrapper.TextureFromShape(_leftUpper.FixtureList[0].Shape, ContentWrapper.Grey, ContentWrapper.Black)); _lowerLeg = new Sprite(ContentWrapper.TextureFromShape(_leftLower.FixtureList[0].Shape, ContentWrapper.Gold, ContentWrapper.Black)); _flexed = false; _timer = 0f; _leftShoulderAngleJoint.TargetAngle = ShoulderRelaxed; _leftKneeAngleJoint.TargetAngle = KneeRelaxed; _rightShoulderAngleJoint.TargetAngle = -ShoulderRelaxed; _rightKneeAngleJoint.TargetAngle = -KneeRelaxed; }
/// <summary> /// Constructs a new option entry with the specified text. /// </summary> public OptionEntry(string text, bool isChecked) { Text = text; IsChecked = isChecked; _hoverFade = 0.0; _checkedFade = 0.0; SpriteFont font = ContentWrapper.GetFont("MenuFont"); Size = font.MeasureString(text); }
public IModalToken Open(FrameworkElement content, ModalPosition position, Point? location) { Contract.Requires(content != null); var wrapper = new ContentWrapper(this, content, position, location); if (_content.Any()) { Debug.Assert(_content.Count(cw => cw.IsEnabled) == 1); Debug.Assert(_content.Last().IsEnabled); _content.Last().IsEnabled = false; } _content.Add(wrapper); updateContent(); updateState(); return wrapper; }