public void FreeObject(Segment entity) { foreach (Joint joint in joints) { game.world.RemoveJoint(joint); } }
public ConstructElement(ScrapGame game, Segment entity, Construct construct, Point offSet, Joint rootJoint) { branchJoints = new List<Joint>(); this.rootJoint = rootJoint; this.segment = entity; this.game = game; this.construct = construct; this.offSet = offSet; }
public void JoinEntities(Segment entityA, Segment entityB, Scrap.GameElements.Entities.Direction direction) { entities.Add(entityB); Point gridOffset = entityA.constructElement.offSet; Vector2 anchorOffset; Joint joint; switch (direction) { case Direction.Right: gridOffset += new Point(1, 0); anchorOffset=new Vector2(-1.2f, 0); break; case Direction.Left: gridOffset += new Point(-1, 0); anchorOffset= new Vector2(1.2f, 0); break; case Direction.Up: gridOffset += new Point(0, 1); anchorOffset= new Vector2(0, 1.2f); break; case Direction.Down://ToDo: possible bug gridOffset += new Point(0, -1); anchorOffset= new Vector2(0, -1.2f); break; default: gridOffset += new Point(0, 1); anchorOffset=new Vector2(0, -1.2f); break; } if (!buildElements.ContainsKey(gridOffset)) { joint = AddJoint(entityA, entityB, direction, anchorOffset); entityB.constructElement = new ConstructElement(this.game, entityB, this, gridOffset, joint); entityA.constructElement.branchJoints.Add(joint); buildElements.Add(gridOffset, entityB.constructElement); entityB.AddSensors(); } }
private Joint AddJoint(Segment entityA, Segment entityB, Scrap.GameElements.Entities.Direction direction, Vector2 anchorOffset) { Joint joint; joint = JointFactory.CreateWeldJoint(game.world, entityA.GetJointAnchor(direction), entityB.GetJointAnchor(direction), new Vector2(0, 0), anchorOffset); joints.Add(joint); return joint; }
public void SetSegmentLock(Point offset, Segment segment) { }
private void SetSelectedSegment(Segment segment) { selectedSegment = segment; selectedSegment.selected = true; selectedSegment.RemoveSensors(); }
protected void ReleaseSegment() { //Todo:direction selection code selectedSegment.selected = false; selectedSegment = null; }
public void Follow(Segment entity, float magnification) { cameraMode = CameraMode.FixedFollow; entityToFollow = entity; Magnification = magnification; }