示例#1
0
        // Check to see if the simple room has one open door and one closed door.
        private static bool checkIfRoomCanHavePortTown(SimpleRoom_Output simpleRoom, PortTownReturnPacket portTownPacket, byte xCoord, byte yCoord, byte[] finalTreasureCoords)
        {
            // First, check if the space has water, and is not too close to another port town:
            if (simpleRoom.getIsNotEmpty() && !portTownPacket.checkIfCoordinateIsTooCloseToAnotherPortTown(xCoord, yCoord) &&
                Mathf.Abs(xCoord - finalTreasureCoords[0]) > 1 && Mathf.Abs(yCoord - finalTreasureCoords[1]) > 1)
            {
                for (byte index = 0; index < 4; index++)
                {
                    // If the room hasSomething (water), and has a wall that is closed...
                    // then there is space to place a port town:
                    if (!simpleRoom.getWallIsOpen(index))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#2
0
        private static Vector2 findPortTownPierLandPoint(SimpleRoom_Output simpleRoom, Vector2 centerPoint, float roomWidthHeight, System.Random random_forThread)
        {
            byte switchByte = 0;

            if (simpleRoom.getWallIsOpen(Constants.doorID_left))
            {
                switchByte += 1;
            }
            if (simpleRoom.getWallIsOpen(Constants.doorID_up))
            {
                switchByte += 2;
            }
            if (simpleRoom.getWallIsOpen(Constants.doorID_down))
            {
                switchByte += 4;
            }
            if (simpleRoom.getWallIsOpen(Constants.doorID_right))
            {
                switchByte += 8;
            }

            switch (switchByte)
            {
            case 1:     // l open
                switch (random_forThread.Next(0, 5))
                {
                case 0: return(centerPoint + new Vector2(0f, -0.5f * -roomWidthHeight));                            // u

                case 1: return(centerPoint + new Vector2(0.5f * roomWidthHeight, -0.5f * -roomWidthHeight));        // ur

                case 2: return(centerPoint + new Vector2(0.5f * roomWidthHeight, 0f));                              // r

                case 3: return(centerPoint + new Vector2(0.5f * roomWidthHeight, 0.5f * -roomWidthHeight));         // dr

                default: return(centerPoint + new Vector2(0f, 0.5f * -roomWidthHeight));                            // d
                }

            case 2:     // u open
                switch (random_forThread.Next(0, 5))
                {
                case 0: return(centerPoint + new Vector2(0.5f * roomWidthHeight, 0f));                              // r

                case 1: return(centerPoint + new Vector2(0.5f * roomWidthHeight, 0.5f * -roomWidthHeight));         // dr

                case 2: return(centerPoint + new Vector2(0f, 0.5f * -roomWidthHeight));                             // d

                case 3: return(centerPoint + new Vector2(-0.5f * roomWidthHeight, 0.5f * -roomWidthHeight));        // dl

                default: return(centerPoint + new Vector2(-0.5f * roomWidthHeight, 0f));                            // l
                }

            case 3:                                                                                 // lu open
                return(centerPoint + new Vector2(0.5f * roomWidthHeight, 0.5f * -roomWidthHeight)); // dr

            // switch(random_forThread.Next(0, 3))
            // {
            //     case 0: return centerPoint + new Vector2(0.5f * roomWidthHeight, 0f);                       // r
            //     case 1: return centerPoint + new Vector2(0.5f * roomWidthHeight, 0.5f * -roomWidthHeight);  // dr
            //     default: return centerPoint + new Vector2(0f, 0.5f * -roomWidthHeight);                      // d
            // }

            case 4:     // d open
                switch (random_forThread.Next(0, 5))
                {
                case 0: return(centerPoint + new Vector2(-0.5f * roomWidthHeight, -0.5f * -roomWidthHeight));       //ul

                case 1: return(centerPoint + new Vector2(0f, -0.5f * -roomWidthHeight));                            // u

                case 2: return(centerPoint + new Vector2(0.5f * roomWidthHeight, -0.5f * -roomWidthHeight));        // ur

                case 3: return(centerPoint + new Vector2(0.5f * roomWidthHeight, 0f));                              // r

                default: return(centerPoint + new Vector2(-0.5f * roomWidthHeight, 0f));                            // l
                }

            case 5:                                                                                  // ld open
                return(centerPoint + new Vector2(0.5f * roomWidthHeight, -0.5f * -roomWidthHeight)); // ur

            // switch(random_forThread.Next(0, 3))
            // {
            //     case 0: return centerPoint + new Vector2(0f, -0.5f * -roomWidthHeight);                     // u
            //     case 1: return centerPoint + new Vector2(0.5f * roomWidthHeight, -0.5f * -roomWidthHeight); // ur
            //     default: return centerPoint + new Vector2(0.5f * roomWidthHeight, 0f);                       // r
            // }

            case 6:     // ud open
                switch (random_forThread.Next(0, 2))
                {
                case 0: return(centerPoint + new Vector2(0.5f * roomWidthHeight, 0f));                              // r

                default: return(centerPoint + new Vector2(-0.5f * roomWidthHeight, 0f));                            // l
                }

            case 7:                                                            // lud open
                return(centerPoint + new Vector2(0.5f * roomWidthHeight, 0f)); // r

            case 8:                                                            // r open
                switch (random_forThread.Next(0, 5))
                {
                case 0: return(centerPoint + new Vector2(-0.5f * roomWidthHeight, -0.5f * -roomWidthHeight));       //ul

                case 1: return(centerPoint + new Vector2(0f, -0.5f * -roomWidthHeight));                            // u

                case 2: return(centerPoint + new Vector2(0f, 0.5f * -roomWidthHeight));                             // d

                case 3: return(centerPoint + new Vector2(-0.5f * roomWidthHeight, 0.5f * -roomWidthHeight));        // dl

                default: return(centerPoint + new Vector2(-0.5f * roomWidthHeight, 0f));                            // l
                }

            case 9:     // lr open
                switch (random_forThread.Next(0, 2))
                {
                case 0: return(centerPoint + new Vector2(0f, -0.5f * -roomWidthHeight));                            // u

                default: return(centerPoint + new Vector2(0f, 0.5f * -roomWidthHeight));                            // d
                }

            case 10:                                                                                 // ur open
                return(centerPoint + new Vector2(-0.5f * roomWidthHeight, 0.5f * -roomWidthHeight)); // dl

            // switch(random_forThread.Next(0, 3))
            // {
            //     case 0: return centerPoint + new Vector2(0f, 0.5f * -roomWidthHeight);                      // d
            //     case 1: return centerPoint + new Vector2(-0.5f * roomWidthHeight, 0.5f * -roomWidthHeight); // dl
            //     default: return centerPoint + new Vector2(-0.5f * roomWidthHeight, 0f);                     // l
            // }

            case 11:                                                                                  // lur open
                return(centerPoint + new Vector2(0f, 0.5f * -roomWidthHeight));                       // d

            case 12:                                                                                  // dr open
                return(centerPoint + new Vector2(-0.5f * roomWidthHeight, -0.5f * -roomWidthHeight)); //ul

            // switch(random_forThread.Next(0, 3))
            // {
            //     case 0: return centerPoint + new Vector2(-0.5f * roomWidthHeight, -0.5f * -roomWidthHeight); //ul
            //     case 1: return centerPoint + new Vector2(0f, -0.5f * -roomWidthHeight);                     // u
            //     default: return centerPoint + new Vector2(-0.5f * roomWidthHeight, 0f);                     // l
            // }

            case 13:                                                             // ldr open
                return(centerPoint + new Vector2(0f, -0.5f * -roomWidthHeight)); // u

            case 14:                                                             // udr open
                return(centerPoint + new Vector2(-0.5f * roomWidthHeight, 0f));  // l

            // case 0: // all doors closed... should never happen
            default:                                                             //case 15: // all doors open... should never happen
                return(centerPoint + new Vector2(0f, -0.5f * -roomWidthHeight)); // u
            }
        }