private void removeAllReflectionLinesToolStripMenuItem_Click(object sender, EventArgs e) { horizontal_lines = new SortedSet <int>(); vertical_lines = new SortedSet <int>(); diagonal_lines = new SortedSet <int>(); ref_orientation = ReflectionOrientation.NULL; rPos = null; pb_Level.Invalidate(pb_Level.ClientRectangle); }
public void RemoveDLine(int line) { if (this.ref_orientation == ReflectionOrientation.DIAGONAL && line == reflection_line_position) { reflection_line_position = -2; ref_orientation = ReflectionOrientation.NONE; } this.diagonal_lines.Remove(line); }
public void RemoveVRLine(int line) { if (this.ref_orientation == ReflectionOrientation.VERTICAL && line == reflection_line_position) { reflection_line_position = -2; ref_orientation = ReflectionOrientation.NONE; } this.vertical_lines.Remove(line); }
public void RemoveHRLine(int line) { if (this.ref_orientation == ReflectionOrientation.HORIZONTAL && line == reflection_line_position) { reflection_line_position = -2; ref_orientation = ReflectionOrientation.NONE; } this.horizontal_lines.Remove(line); }
public void SetReflectionOrientation(string orientation) { if (orientation.Equals("H", StringComparison.OrdinalIgnoreCase)) { ref_orientation = ReflectionOrientation.HORIZONTAL; } if (orientation.Equals("V", StringComparison.OrdinalIgnoreCase)) { ref_orientation = ReflectionOrientation.VERTICAL; } if (orientation.Equals("D", StringComparison.OrdinalIgnoreCase)) { ref_orientation = ReflectionOrientation.DIAGONAL; } }
public void ToggleDiagonalReflection() { if (canReflectDiagonal && diagonal_lines.Count > 0) { if (ref_orientation == ReflectionOrientation.DIAGONAL) { int next = (current_pos_in_list + 1) % diagonal_lines.Count; reflection_line_position = (int)(diagonal_lines.ToArray()[next]); current_pos_in_list = next; } else { ref_orientation = ReflectionOrientation.DIAGONAL; current_pos_in_list = 0; reflection_line_position = (int)(diagonal_lines.ToArray()[current_pos_in_list]); } } }
public void MoveReflectionLineDown() { if (canReflectHorizontal && horizontal_lines.Count > 0) { if (ref_orientation == ReflectionOrientation.HORIZONTAL) { int next = (current_pos_in_list + 1) % horizontal_lines.Count; reflection_line_position = (int)(horizontal_lines.ToArray()[next]); current_pos_in_list = next; } else { ref_orientation = ReflectionOrientation.HORIZONTAL; current_pos_in_list = horizontal_lines.Count / 2; reflection_line_position = (int)(horizontal_lines.ToArray()[current_pos_in_list]); } } }
public void MoveReflectionLineRight() { if (canReflectVertical && vertical_lines.Count > 0) { if (ref_orientation == ReflectionOrientation.VERTICAL) { int next = (current_pos_in_list + 1) % vertical_lines.Count; reflection_line_position = (int)(vertical_lines.ToArray()[next]); current_pos_in_list = next; } else { ref_orientation = ReflectionOrientation.VERTICAL; current_pos_in_list = vertical_lines.Count / 2; reflection_line_position = (int)(vertical_lines.ToArray()[current_pos_in_list]); } } }
//Used when the user clicks in the painting area while using the insert tool. // This will create a new object when the user left-clicks, and delete the object // it is currently on when it is right clicked. private void painting_clicked_insert(MouseEventArgs e) { Point mp = pb_Level.PointToClient(MousePosition); // Remove the object under the cursor. if (e.Button == MouseButtons.Right) { //XnaPoint mouse = new XnaPoint(pb_Level.PointToClient(MousePosition).X, pb_Level.PointToClient(MousePosition).Y); ; foreach (PhysicsObject obj in objects) { //XnaRectangle rect = new XnaRectangle(obj.DiscX * ROWSCALE, obj.DiscY * COLSCALE, ROWSCALE, COLSCALE); if (mp.X > (obj.DiscX * COLSCALE) && mp.X < (obj.DiscX * COLSCALE + COLSCALE) && mp.Y > (obj.DiscY * ROWSCALE) && mp.Y < (obj.DiscY * ROWSCALE + ROWSCALE)) { objects.Remove(obj); break; } } } // Add an object. if (e.Button == MouseButtons.Left) { PhysicsObject temp = null; if (WallButton.Checked) { temp = new PhysicsObject("Wall", "groundTexture", "", "", mp.X / COLSCALE, mp.Y / ROWSCALE, currentlySelectedObject.density, currentlySelectedObject.friction, currentlySelectedObject.restitution, currentlySelectedObject.is_reflectable, currentlySelectedObject.orientation); } else if (PlayerButton.Checked) { if (player != null) { objects.Remove(player); pb_Level.Invalidate(new Rectangle(player.DiscX * COLSCALE, player.DiscY * ROWSCALE, COLSCALE, ROWSCALE)); } temp = new PhysicsObject("Player", "playerTexture", "", "", mp.X / COLSCALE, mp.Y / ROWSCALE, currentlySelectedObject.density, currentlySelectedObject.friction, currentlySelectedObject.restitution, currentlySelectedObject.is_reflectable, currentlySelectedObject.orientation); player = temp; } else if (SpikeButton.Checked) { temp = new PhysicsObject("Spike", "spikesUpTexture", "", "", mp.X / COLSCALE, mp.Y / ROWSCALE, currentlySelectedObject.density, currentlySelectedObject.friction, currentlySelectedObject.restitution, currentlySelectedObject.is_reflectable, currentlySelectedObject.orientation); switch (temp.orientation) { case "U": temp.texture = "spikesUpTexture"; break; case "D": temp.texture = "spikesDownTexture"; break; case "L": temp.texture = "spikesLeftTexture"; break; case "R": temp.texture = "spikesRightTexture"; break; } } else if (DoorButton.Checked) { if (door != null) { objects.Remove(door); pb_Level.Invalidate(new Rectangle(door.DiscX * COLSCALE, door.DiscY * ROWSCALE, COLSCALE, ROWSCALE)); } temp = new PhysicsObject("Door", "closeDoorTexture", "openDoorTexture", "closeDoorTexture", mp.X / COLSCALE, mp.Y / ROWSCALE, currentlySelectedObject.density, currentlySelectedObject.friction, currentlySelectedObject.restitution, currentlySelectedObject.is_reflectable, currentlySelectedObject.orientation); door = temp; } else if (KeyButton.Checked) { temp = new PhysicsObject("Key", "keyTexture", "", "", mp.X / COLSCALE, mp.Y / ROWSCALE, currentlySelectedObject.density, currentlySelectedObject.friction, currentlySelectedObject.restitution, currentlySelectedObject.is_reflectable, currentlySelectedObject.orientation); } else if (BlockButton.Checked) { temp = new PhysicsObject("Block", "buddyBlock", "", "", mp.X / COLSCALE, mp.Y / ROWSCALE, currentlySelectedObject.density, currentlySelectedObject.friction, currentlySelectedObject.restitution, currentlySelectedObject.is_reflectable, currentlySelectedObject.orientation); } else if (SwitchButton.Checked) { temp = new PhysicsObject("Switch", "switchTexture", "", "", mp.X / COLSCALE, mp.Y / ROWSCALE, currentlySelectedObject.density, currentlySelectedObject.friction, currentlySelectedObject.restitution, currentlySelectedObject.is_reflectable, currentlySelectedObject.orientation); temp.hLines = currentlySelectedObject.hLines; temp.vLines = currentlySelectedObject.vLines; temp.dLines = currentlySelectedObject.dLines; } else if (lineButton.Checked) { int x = mp.X / COLSCALE; int y = mp.Y / ROWSCALE; switch (currentlySelectedObject.orientation) { case "H": if (CANREFLECTHORIZONTAL && y > 0 && y < NUM_ROWS) { if (!rPos.HasValue) { ref_orientation = ReflectionOrientation.HORIZONTAL; rPos = y; } horizontal_lines.Add(y); pb_Level.Invalidate(new Rectangle(0, y * ROWSCALE - 5, WIDTH, 10)); } break; case "V": if (CANREFLECTVERTICAL && x > 0 && x < NUM_COLS) { if (!rPos.HasValue) { ref_orientation = ReflectionOrientation.VERTICAL; rPos = x; } vertical_lines.Add(x); pb_Level.Invalidate(new Rectangle(x * COLSCALE - 5, 0, 10, HEIGHT)); } break; case "D": if (CANREFLECTDIAGONAL) { if ((x < NUM_COLS / 2 && y < NUM_ROWS / 2) || (x > NUM_COLS / 2 && y > NUM_ROWS / 2)) { if (!rPos.HasValue) { ref_orientation = ReflectionOrientation.DIAGONAL; rPos = 1; } diagonal_lines.Add(1); } else { if (!rPos.HasValue) { ref_orientation = ReflectionOrientation.DIAGONAL; rPos = -1; } diagonal_lines.Add(-1); } pb_Level.Invalidate(pb_Level.ClientRectangle); } break; default: break; } } if (!lineButton.Checked) { objects.Add(temp); } } if (!lineButton.Checked) { pb_Level.Invalidate(new Rectangle(mp.X / COLSCALE * COLSCALE, mp.Y / ROWSCALE * ROWSCALE, COLSCALE, ROWSCALE)); } //else //{ // pb_Level.Invalidate(pb_Level.ClientRectangle); //} pb_Level.Update(); }