public void Update2() { prevmouse = mouse; mouse = xna.Mouse.GetState(); if ( selected != null && currentTool == EditorTool.Selection ) { gameObjectBindingSource.DataSource = selected; if ( selected.m_body != null ) { if ( selected is Alien ) { alienBindingSource.DataSource = selected; } else if ( selected is Trigger ) { triggerBindingSource.DataSource = selected; if ( selected is ConditionTriggered ) { conditionTriggeredBindingSource.DataSource = selected; } } else if ( selected is TriggerableObject ) { triggerableObjectBindingSource.DataSource = selected; } if ( ( selected is PolygonObject ) ) { polygonObjectBindingSource.DataSource = selected; if ( selected is FloorTile ) { floorTileBindingSource.DataSource = selected; } } // If a new object is selected, create a new selectbox if ( selected != prior_selected ) { clearLine(); if ( !( selected is PolygonObject ) && !(selected is CompoundPolygonObject) ) { if ( selectbox == null ) { selectbox = new SelectBox( screen.m_current_world, TestWorld.floor_texture, selected.m_body.Position, selected.m_radius, target:selected); screen.m_current_world.add_queued_object( selectbox ); } else { if ( selected.m_radius != 0 ) { selectbox.m_radius = selected.m_radius; } else { selectbox.m_radius = 1; } selectbox.m_target = selected; selectbox.m_body.Position = selected.m_body.Position; } } else { if ( selectbox == null ) { selectbox = new SelectBox( screen.m_current_world, TestWorld.floor_texture, selected.m_body.Position, 0.25f, target: selected ); screen.m_current_world.add_queued_object( selectbox ); } else { selectbox.m_radius = 0.25f; //selectbox.m_draw_location = selected.m_body.Position; selectbox.m_target = selected; selectbox.m_body.Position = selected.m_body.Position; } } prior_selected = selected; } } // If the mouse is clicked and dragged, move the object the same distance if ( screen.m_current_world != null && selected.m_body != null && mouse.LeftButton == ButtonState.Pressed ) { Vector2 shift = screen.m_current_world.get_transform( new Vector2( mouse.X, mouse.Y ) ) - screen.m_current_world.get_transform( new Vector2( prevmouse.X, prevmouse.Y ) ); if ( shift != Vector2.Zero && selected != selectbox ) { selected.m_body.Position += shift; if ( selectbox != null ) { selectbox.m_draw_location = selected.m_body.Position; selectbox.m_body.Position = selected.m_body.Position; } if ( selected is PolygonObject ) { PolygonObject wall = (PolygonObject)selected; wall.pos += shift; } } } } }
/// <summary> /// Set all tool squares to "unchecked." /// </summary> public void ClearToolMenu() { tool_Insertion.Checked = false; tool_Selection.Checked = false; if (selectbox != null) { selectbox.destroy(); selectbox = null; } /* foreach ( Selector s in selector_list ) { if ( s != null ) { s.destroy(); s.remove_from_world(); } } selector_list = new List<Selector>();*/ }