Beispiel #1
0
            public void Movement()
            {
                if (!EnableMovement || CurrentPath.Count == 0)
                {
                    StopMovement();
                    return;
                }
                Vector2 position = MainMotor.GetWorldPosition();

                if ((position - CurrentPath[CurrentPath.Count - 1]).Length() <= 1 || RailJoint == null)
                {
                    CurrentPath.RemoveAt(CurrentPath.Count - 1);
                    if (CurrentPath.Count == 0)
                    {
                        StopMovement();
                        return;
                    }
                    else
                    {
                        StopMovement(false);
                    }
                    RailJoint      = (IObjectRailJoint)GlobalGame.CreateObject("RailJoint", position);
                    TargetObject   = (IObjectTargetObjectJoint)GlobalGame.CreateObject("TargetObjectJoint", CurrentPath[CurrentPath.Count - 1]);
                    RailAttachment = (IObjectRailAttachmentJoint)GlobalGame.CreateObject("RailAttachmentJoint", position);
                    RailJoint.SetTargetObjectJoint(TargetObject);
                    RailAttachment.SetRailJoint(RailJoint);
                    RailAttachment.SetTargetObject(Hull);
                    RailAttachment.SetMotorEnabled(true);
                    RailAttachment.SetMaxMotorTorque(10);
                    RailAttachment.SetMotorSpeed(Speed);
                    Hull.SetBodyType(BodyType.Dynamic);
                }
            }
Beispiel #2
0
 public void StopMovement(bool makeStatic = true)
 {
     if (RailJoint == null)
     {
         return;
     }
     RailAttachment.SetTargetObject(null);
     RailAttachment.SetRailJoint(null);
     if (makeStatic)
     {
         Hull.SetBodyType(BodyType.Static);
     }
     RailJoint.Remove();
     TargetObject.Remove();
     RailAttachment.Remove();
     RailJoint = null;
 }