/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(InputState input) { //is an object being grabbed? if(input.Mouse.IsNewLeftMouseClick) { int count = 0; float mx = Camera1.Relative2Dto3D(input.Mouse.Position).X; float my = Camera1.Relative2Dto3D(input.Mouse.Position).Y; foreach (var piece in Level.Pieces) { float oRadius = piece.ObjectModel.Meshes[0].BoundingSphere.Radius; if(mx < piece.Position.X + oRadius && mx > piece.Position.X - oRadius && my < piece.Position.Y + oRadius && my > piece.Position.Y - oRadius) { ++count; objectGrabbed = piece; } } DisplayedMessages["levelEditor"] = "clicking on " + count + " number of objects. @ cur pos: " + mx + ", " + my; } //is an object being released? if(input.Mouse.IsNewLeftMouseRelease) objectGrabbed = null; //stick the object to the cursor if it's currently grabbed. if(objectGrabbed != null && input.Mouse.LeftMouseDown) { objectGrabbed.Position = input.Mouse.Position3DSpace; } }
public void RemoveObjectFromGame(VisualObject3D obj) { if (obj is isCollidable) GameScreen.Collisions.Collidables.Remove((isCollidable)obj); if (obj is hasPosition2D) GameScreen.ObjectsToBeWrapped.Remove((hasPosition2D)obj); GameScreen.Level.Pieces.Remove(obj); }