Example #1
0
        // Delete the current door and its mirror.
        public void DeleteDoor()
        {
            if (lblDoorID.Text != "")
            {
                // Populate a Door Object with data from the Form.
                classes.door oDoor = new classes.door();
                oDoor = classes.door.GetDoorByID(Convert.ToInt32(lblDoorID.Text));

                // Populate the Door Mirror Object with data from the Door.
                classes.door oDoorMirror = new classes.door();
                oDoorMirror = classes.door.GetDoorMirror(oDoor, iCurrentRoom);
                oDoorMirror.doorID = classes.door.GetDoorMirrorID(oDoorMirror, iCurrentRoom);

                // Delete Doors.
                oDoor.DeleteDoor();
                oDoorMirror.DeleteDoor();
            }
            else
                MessageBox.Show("You don't have a door selected!", strErrorHeaderMsg, MessageBoxButtons.OK);

            // Get the Current Room in Zoom View.
            Control[] ctrlRoom = this.Controls.Find("room" + iCurrentRoom.ToString(), true);
            Button btnRoom = new Button();
            btnRoom = (Button)ctrlRoom[0];

            // Redraw the Panel and refresh Zoom View to reflect the Door Save.
            ClearDoorSection();
            DisplayPanelRooms(iCurrentArea, iCurrentX, iCurrentY, iCurrentZ);
            UpdateZoomView(btnRoom);
        }
Example #2
0
 // Display All Doors for a Room.
 private void DisplayRoomDoors()
 {
     // Display Room Doors.
     classes.door[] doors = new classes.door[6];
     doors = classes.door.GetRoomDoors(iCurrentArea, iCurrentRoom, iCurrentX, iCurrentY, iCurrentZ);
     // Loop through doors and display on the zoom view map.
     foreach (classes.door oDoor in doors)
     {
         if (oDoor != null)
         {
             DisplayDoor(oDoor.direction);
         }
     }
 }
Example #3
0
        // Display all of the saved rooms on a Panel.
        public void DisplayPanelRooms(int iAreaID, int iCoordX, int iCoordY, int iCoordZ)
        {
            classes.room[] rooms = new classes.room[800];
            Button btnRoom = new Button();

            // Get a collection of the rooms on the current panel.
            rooms = classes.room.GetPanelRooms(iAreaID, iCoordX, iCoordY, iCoordZ);

            foreach (classes.room oRoom in rooms)
            {
                if (oRoom != null)
                {
                    // Get the Button at the specified location.
                    Control[] ctrlRoom = this.Controls.Find("room" + oRoom.roomNumber, true);
                    if (btnRoom != null)
                    {
                        btnRoom = (Button)ctrlRoom[0];
                        btnRoom.BackColor = clrCurrent;
                        btnRoom.FlatAppearance.BorderColor = clrBlankBorder;
                    }

                    // Color Exits where appropriate.
                    // ## North ##
                    if (oRoom.hasExitNorth)
                    {
                        // Get the Button at the specified location.
                        Control[] ctrlNorth = this.Controls.Find("vpath" + (oRoom.roomNumber - 1).ToString(), true);
                        Button btnNorth = new Button();
                        if (btnNorth != null)
                        {
                            btnNorth = (Button)ctrlNorth[0];
                            btnNorth.Visible = true;
                            btnNorth.BackColor = Color.Black;
                        }
                    }

                    // ## South ##
                    if (oRoom.hasExitSouth)
                    {
                        // Get the Button at the specified location.
                        Control[] ctrlSouth = this.Controls.Find("vpath" + (oRoom.roomNumber).ToString(), true);
                        Button btnSouth = new Button();
                        if (btnSouth != null)
                        {
                            btnSouth = (Button)ctrlSouth[0];
                            btnSouth.Visible = true;
                            btnSouth.BackColor = Color.Black;
                        }
                    }

                    // ## East ##
                    if (oRoom.hasExitEast)
                    {
                        // Get the Button at the specified location.
                        Control[] ctrlEast = this.Controls.Find("hpath" + (oRoom.roomNumber).ToString(), true);
                        Button btnEast = new Button();
                        if (btnEast != null)
                        {
                            btnEast = (Button)ctrlEast[0];
                            btnEast.Visible = true;
                            btnEast.BackColor = Color.Black;
                        }
                    }

                    // ## West ##
                    if (oRoom.hasExitWest)
                    {
                        // Get the Button at the specified location.
                        Control[] ctrlWest = this.Controls.Find("hpath" + (oRoom.roomNumber - 25).ToString(), true);
                        Button btnWest = new Button();
                        if (btnWest != null)
                        {
                            btnWest = (Button)ctrlWest[0];
                            btnWest.Visible = true;
                            btnWest.BackColor = Color.Black;
                        }
                    }
                }
            }

            // Display Up Rooms.
            classes.room[] RoomsUp = new classes.room[750];
            RoomsUp = classes.room.GetRoomsWithUpExit(iAreaID, iCoordX, iCoordY, iCoordZ);
            // Loop through Up Rooms and change border colors on map.
            foreach (classes.room RoomUp in RoomsUp)
            {
                if (RoomUp != null)
                {
                    Control[] ctrlUp = this.Controls.Find("room" + RoomUp.roomNumber.ToString(), true);
                    Button btnUp = new Button();
                    if (btnUp != null)
                    {
                        btnUp = (Button)ctrlUp[0];
                        btnUp.FlatAppearance.BorderColor = clrUp;
                    }
                }
            }

            // Display Down Rooms.
            classes.room[] RoomsDown = new classes.room[750];
            RoomsDown = classes.room.GetRoomsWithDownExit(iAreaID, iCoordX, iCoordY, iCoordZ);
            // Loop through Down Rooms and change border colors on map.
            foreach (classes.room RoomDown in RoomsDown)
            {
                if (RoomDown != null)
                {
                    Control[] ctrlDown = this.Controls.Find("room" + RoomDown.roomNumber.ToString(), true);
                    Button btnDown = new Button();
                    if (btnDown != null)
                    {
                        btnDown = (Button)ctrlDown[0];
                        btnDown.FlatAppearance.BorderColor = clrDown;
                    }
                }
            }

            // Display Doors.
            classes.door[] doors = new classes.door[250];
            doors = classes.door.GetPanelDoors(iCurrentArea, iCurrentX, iCurrentY, iCurrentZ);
            // Loop through Doors and Display on Panel.
            foreach (classes.door oDoor in doors)
            {
                if (oDoor != null)
                {
                    switch (oDoor.direction.ToLower())
                    {
                        case "north":
                            // Get the Button at the specified location.
                            Control[] ctrlNorth = this.Controls.Find("vpath" + (oDoor.roomNumber - 1).ToString(), true);
                            Button btnNorth = new Button();
                            if (btnNorth != null)
                            {
                                btnNorth = (Button)ctrlNorth[0];
                                btnNorth.Visible = true;
                                if (oDoor.doorType == "Not Pickable")
                                    btnNorth.BackColor = clrDoorLocked;
                                else
                                    btnNorth.BackColor = clrDoorDefault;
                            }
                            break;
                        case "south":
                            // Get the Button at the specified location.
                            Control[] ctrlSouth = this.Controls.Find("vpath" + (oDoor.roomNumber).ToString(), true);
                            Button btnSouth = new Button();
                            if (btnSouth != null)
                            {
                                btnSouth = (Button)ctrlSouth[0];
                                btnSouth.Visible = true;
                                if (oDoor.doorType == "Not Pickable")
                                    btnSouth.BackColor = clrDoorLocked;
                                else
                                    btnSouth.BackColor = clrDoorDefault;
                            }
                            break;
                        case "east":
                            // Get the Button at the specified location.
                            Control[] ctrlEast = this.Controls.Find("hpath" + (oDoor.roomNumber).ToString(), true);
                            Button btnEast = new Button();
                            if (btnEast != null)
                            {
                                btnEast = (Button)ctrlEast[0];
                                btnEast.Visible = true;
                                btnEast.BackColor = clrDoorDefault;
                                if (oDoor.doorType == "Not Pickable")
                                    btnEast.BackColor = clrDoorLocked;
                                else
                                    btnEast.BackColor = clrDoorDefault;
                            }
                            break;
                        case "west":
                            // Get the Button at the specified location.
                            Control[] ctrlWest = this.Controls.Find("hpath" + (oDoor.roomNumber - 25).ToString(), true);
                            Button btnWest = new Button();
                            if (btnWest != null)
                            {
                                btnWest = (Button)ctrlWest[0];
                                btnWest.Visible = true;
                                if (oDoor.doorType == "Not Pickable")
                                    btnWest.BackColor = clrDoorLocked;
                                else
                                    btnWest.BackColor = clrDoorDefault;
                            }
                            break;
                        default:
                            break;
                    }
                }
            }

            //Display Current Room.
            DisplayCurrentRoom(true);
        }
Example #4
0
        // Save current room door.
        public void SaveDoor()
        {
            if (txtDoorVNUM.Text != "" && txtDoorKeywords.Text != "" && cboDirection.SelectedIndex > -1 && cboDoorType.SelectedIndex > -1)
            {
                // Populate a Door Object with data from the Form.
                classes.door oDoor = new classes.door();
                if (lblDoorID.Text != "")
                    oDoor.doorID = Convert.ToInt32(lblDoorID.Text);
                oDoor.areaID = iCurrentArea;
                oDoor.roomNumber = iCurrentRoom;
                oDoor.VNUM = Convert.ToInt32(txtDoorVNUM.Text);
                oDoor.keywords = txtDoorKeywords.Text;
                oDoor.direction = cboDirection.Items[cboDirection.SelectedIndex].ToString();
                oDoor.doorType = cboDoorType.Items[cboDoorType.SelectedIndex].ToString();
                if (cboDoorKey.SelectedIndex > 0)
                    oDoor.keyVNUM = Convert.ToInt32(cboDoorKey.SelectedValue.ToString());
                oDoor.coordX = iCurrentX;
                oDoor.coordY = iCurrentY;
                oDoor.coordZ = iCurrentZ;

                // Populate the Door Mirror Object with data from the Door.
                classes.door oDoorMirror = new classes.door();
                oDoorMirror = classes.door.GetDoorMirror(oDoor, iCurrentRoom);

                // Check if Door is a Duplicate (by Room and Direction)
                if (!oDoor.DoorIsDuplicate())
                {
                    // If Door is not a Duplicate, Insert/Update.
                    if (lblDoorID.Text != "")
                    {
                        // Update Door.
                        oDoor.doorID = Convert.ToInt32(lblDoorID.Text);
                        oDoor.UpdateDoor();

                        // Get Door Mirror.
                        int iDoorMirrorID = 0;
                        iDoorMirrorID = classes.door.GetDoorMirrorID(oDoorMirror, iCurrentRoom);
                        if (iDoorMirrorID > 0)
                        {
                            oDoorMirror.doorID = iDoorMirrorID;
                            oDoorMirror.UpdateDoor();
                        }
                    }
                    else
                    {
                        // Add Door.
                        oDoor.AddDoor();
                        // Add Door Mirror.
                        oDoorMirror.AddDoor();
                    }
                }
                else
                {
                    MessageBox.Show("A door already exists in that direction!", strErrorHeaderMsg, MessageBoxButtons.OK);
                }

                // Get the Current Room in Zoom View.
                Control[] ctrlRoom = this.Controls.Find("room" + iCurrentRoom.ToString(), true);
                Button btnRoom = new Button();
                btnRoom = (Button)ctrlRoom[0];

                // Redraw the Panel and refresh Zoom View to reflect the Door Save.
                ClearDoorSection();
                DisplayPanelRooms(iCurrentArea, iCurrentX, iCurrentY, iCurrentZ);
                UpdateZoomView(btnRoom);
            }
            else
                MessageBox.Show("The door needs more info!", strErrorHeaderMsg, MessageBoxButtons.OK);
        }