Esempio n. 1
0
 public void FreeObject(Segment entity)
 {
     foreach (Joint joint in joints)
     {
         game.world.RemoveJoint(joint);
     }
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 public void SetSegmentLock(Point offset, Segment segment)
 {
 }
Esempio n. 6
0
 private void SetSelectedSegment(Segment segment)
 {
     selectedSegment = segment;
     selectedSegment.selected = true;
     selectedSegment.RemoveSensors();
 }
Esempio n. 7
0
 protected void ReleaseSegment()
 {
     //Todo:direction selection code
     selectedSegment.selected = false;
     selectedSegment = null;
 }
Esempio n. 8
0
 public void Follow(Segment entity, float magnification)
 {
     cameraMode = CameraMode.FixedFollow;
     entityToFollow = entity;
     Magnification = magnification;
 }