Esempio n. 1
0
        private static PortTownIndividualPacket createNewPortTownAtLocation(SimplifiedLayoutReturnPacket simplifiedLayout, UpscaledLayoutReturnPacket upscaledLayout,
                                                                            byte roomX, byte roomY, float roomWidthHeight, int numOfVertsPerEdge, System.Random random_forThread)
        {
            PortTownIndividualPacket portTownIndividual = new PortTownIndividualPacket();

            portTownIndividual.setPortTownPierCoords_simple(roomX, roomY);

            Vector2 waterPosition = new Vector2((roomX + 0.5f) * roomWidthHeight, (roomY + 0.5f) * -roomWidthHeight);
            Vector2 landPosition  = findPortTownPierLandPoint(simplifiedLayout.getSimplifiedRoomArray()[roomX, roomY], waterPosition, roomWidthHeight, random_forThread);

            portTownIndividual.setPortTownYRotation(Vector2.SignedAngle(waterPosition - landPosition, Vector2.up));

            Vector2 stepAmount = (landPosition - waterPosition).normalized * Constants.shipMoveSpeed;

            do
            {
                waterPosition += stepAmount;
            } while (BoolArrayManager.checkForConflict_V2_noDoors(upscaledLayout.getBoolArray(), waterPosition));

            stepAmount     = stepAmount / Constants.shipMoveSpeed * Constants.portTownDistanceFromLand;
            waterPosition -= stepAmount;

            portTownIndividual.setPortTownPierCoords_upscaled(waterPosition.x, waterPosition.y);

            addHousesAroundPier(portTownIndividual, upscaledLayout.getLandVertexHeights(), random_forThread);

            return(portTownIndividual);
        }
Esempio n. 2
0
        public static PortTownReturnPacket generatePortTownInformation_DemoVer(SimplifiedLayoutReturnPacket simplifiedLayout, UpscaledLayoutReturnPacket upscaledLayout,
                                                                               float roomWidthHeight, int numOfVertsPerEdge)
        {
            PortTownReturnPacket portTownPacket = new PortTownReturnPacket(1);

            PortTownIndividualPacket portTownIndividual = new PortTownIndividualPacket();

            portTownIndividual.setAllData_forDemo();

            portTownPacket.addNewPortTownData(portTownIndividual);

            return(portTownPacket);
        }
Esempio n. 3
0
        public static TerrainBuilderReturnPacket generateTerrain_shipSelectionVer(float roomWidthHeight, int numOfVertsPerEdge)
        {
            System.Random random_forThread = new System.Random();

            SimplifiedLayoutReturnPacket simplifiedLayout = SimplifiedLayoutTemplates.generateLayout_ShipSelectionScreen();

            UpscaledLayoutReturnPacket upscaledLayout = UpscaledLayoutBuilder.upscaleLayout_Title(simplifiedLayout, roomWidthHeight, numOfVertsPerEdge, random_forThread);

            // Mesh[,] returnMeshes = sliceHeightArrayIntoMultipleMeshes(upscaledLayout.getLandVertexHeights(), roomWidthHeight, numOfVertsPerEdge);
            TerrainMeshDataPacket[,] meshData = sliceHeightArrayIntoMultipleMeshes_2(upscaledLayout.getLandVertexHeights(), roomWidthHeight, numOfVertsPerEdge);

            // return new TerrainBuilderReturnPacket(simplifiedLayout, upscaledLayout, returnMeshes);
            return(new TerrainBuilderReturnPacket(simplifiedLayout, upscaledLayout, meshData, null));
        }
Esempio n. 4
0
        public static TerrainBuilderReturnPacket generateTerrain_DemoVer(float roomWidthHeight, int numOfVertsPerEdge)
        {
            // System.Random random_forThread = new System.Random();

            SimplifiedLayoutReturnPacket simplifiedLayout = SimplifiedLayoutTemplates.generateLayout_Demo();

            UpscaledLayoutReturnPacket upscaledLayout = UpscaledLayoutBuilder.upscaleLayout_Demo(simplifiedLayout, roomWidthHeight, numOfVertsPerEdge);

            // Mesh[,] returnMeshes = sliceHeightArrayIntoMultipleMeshes(upscaledLayout.getLandVertexHeights(), roomWidthHeight, numOfVertsPerEdge);
            TerrainMeshDataPacket[,] meshData = sliceHeightArrayIntoMultipleMeshes_2(upscaledLayout.getLandVertexHeights(), roomWidthHeight, numOfVertsPerEdge);

            PortTownReturnPacket portTownPacket = PortTownPlacementGenerator.generatePortTownInformation_DemoVer(simplifiedLayout, upscaledLayout, roomWidthHeight, numOfVertsPerEdge);

            // return new TerrainBuilderReturnPacket(simplifiedLayout, upscaledLayout, returnMeshes);
            return(new TerrainBuilderReturnPacket(simplifiedLayout, upscaledLayout, meshData, portTownPacket));
        }
Esempio n. 5
0
        public static TerrainBuilderReturnPacket generateTerrain(float roomWidthHeight, int numOfVertsPerEdge, byte sizeOfExplorableArea, byte numberOfKeys)
        {
            System.Random random_forThread = new System.Random();

            // SimplifiedLayoutReturnPacket simplifiedLayout = SimplifiedLayoutTemplates.generateLayout_DebugRoom();
            Debug.Log("Size of area: " + sizeOfExplorableArea);
            SimplifiedLayoutReturnPacket simplifiedLayout = SimplifiedLayoutBuilder.generateLayout_Normal(sizeOfExplorableArea, numberOfKeys, random_forThread);

            UpscaledLayoutReturnPacket upscaledLayout = UpscaledLayoutBuilder.upscaleLayout_Game(simplifiedLayout, roomWidthHeight, numOfVertsPerEdge, random_forThread);

            // Mesh[,] returnMeshes = sliceHeightArrayIntoMultipleMeshes(upscaledLayout.getLandVertexHeights(), roomWidthHeight, numOfVertsPerEdge);
            TerrainMeshDataPacket[,] meshData = sliceHeightArrayIntoMultipleMeshes_2(upscaledLayout.getLandVertexHeights(), roomWidthHeight, numOfVertsPerEdge);

            PortTownReturnPacket portTownPacket = PortTownPlacementGenerator.generatePortTownInformation(simplifiedLayout, upscaledLayout, roomWidthHeight, numOfVertsPerEdge, sizeOfExplorableArea, random_forThread);

            // return new TerrainBuilderReturnPacket(simplifiedLayout, upscaledLayout, returnMeshes);
            return(new TerrainBuilderReturnPacket(simplifiedLayout, upscaledLayout, meshData, portTownPacket));
        }
Esempio n. 6
0
        // public TerrainBuilderReturnPacket(SimplifiedLayoutReturnPacket simplePacket, UpscaledLayoutReturnPacket upscaledPacket, Mesh[,] terrainMeshes)
        public TerrainBuilderReturnPacket(SimplifiedLayoutReturnPacket simplePacket, UpscaledLayoutReturnPacket upscaledPacket, TerrainMeshDataPacket[,] meshData, PortTownReturnPacket portTownPacket)
        {
            // this.terrainMeshes = terrainMeshes;
            boolArray           = upscaledPacket.getBoolArray();
            boolArray_noNoise   = upscaledPacket.getBoolArray_noNoise();
            this.meshData       = meshData;
            this.simplePacket   = simplePacket;
            this.portTownPacket = portTownPacket;

            numOfKeys = 0;
            for (int index = 0; index < 6; index++)
            {
                if (simplePacket.getHasKey()[index])
                {
                    numOfKeys++;
                }
            }
        }
Esempio n. 7
0
        public static PortTownReturnPacket generatePortTownInformation(SimplifiedLayoutReturnPacket simplifiedLayout, UpscaledLayoutReturnPacket upscaledLayout,
                                                                       float roomWidthHeight, int numOfVertsPerEdge, byte sizeOfExplorableArea, System.Random random_forThread)
        {
            byte targetNumberOfPortTowns = getTargetNumberOfPortTownsByAreaSize(sizeOfExplorableArea, random_forThread);

            SimpleRoom_Output[,] simplifiedRoomArray = simplifiedLayout.getSimplifiedRoomArray();
            PortTownReturnPacket portTownPacket = new PortTownReturnPacket(targetNumberOfPortTowns);

            byte simpleLayoutWidth  = (byte)simplifiedRoomArray.GetLength(0);
            byte simpleLayoutHeight = (byte)simplifiedRoomArray.GetLength(1);

            byte roomX;
            byte roomY;
            byte breaker;

            // First, place a port town at the starting space:
            roomX = simplifiedLayout.getPlayerStartingLocation()[0];
            roomY = simplifiedLayout.getPlayerStartingLocation()[1];
            portTownPacket.addNewPortTownData(createNewPortTownAtLocation(simplifiedLayout, upscaledLayout, roomX, roomY, roomWidthHeight, numOfVertsPerEdge, random_forThread));

            // Then, build more as neccessary:
            for (byte index = 0; index < targetNumberOfPortTowns - 1; index++)
            {
                breaker = 50;

                do
                {
                    roomX = (byte)random_forThread.Next(0, simpleLayoutWidth);
                    roomY = (byte)random_forThread.Next(0, simpleLayoutHeight);

                    // If the town can't be placed in 50 attempts, chances are none of the later ones will either.
                    // So we give up and return the port towns before the target number is reached.
                    if (--breaker == 0 && index > 0)
                    {
                        return(portTownPacket);
                    }
                } while (!checkIfRoomCanHavePortTown(simplifiedRoomArray[roomX, roomY], portTownPacket, roomX, roomY, simplifiedLayout.getFinalTreasureLocation()));


                portTownPacket.addNewPortTownData(createNewPortTownAtLocation(simplifiedLayout, upscaledLayout, roomX, roomY, roomWidthHeight, numOfVertsPerEdge, random_forThread));
            }

            return(portTownPacket);
        }
    public void initializeMinimapData(SimplifiedLayoutReturnPacket simplePacket, bool[,] boolArray, PersistentData persistentData)
    {
        int simpleRoomArrayWidth  = simplePacket.getAreaWidth();
        int simpleRoomArrayHeight = simplePacket.getAreaHeight();
        int boolArrayWidth        = boolArray.GetLength(0);
        int boolArrayHeight       = boolArray.GetLength(1);

        roomExploredArray = new bool[simpleRoomArrayWidth, simpleRoomArrayHeight];

        // centerX = (simpleRoomArrayWidth-1) /2f;
        // centerY = (simpleRoomArrayHeight-1) /2f;
        centerCoords = new Vector2((simpleRoomArrayWidth - 1) / 2f, (simpleRoomArrayHeight - 1) / 2f);

        float parentScaler = 343.65f / Mathf.Max(simpleRoomArrayWidth, simpleRoomArrayHeight);

        ParentTransform_all.localScale       = new Vector3(parentScaler, parentScaler, 1f);
        ParentTransform_all.localEulerAngles = new Vector3(0f, 0f, -45f);


        borderThickness = findBorderThickness(boolArrayWidth, boolArrayHeight, 5f);


        // GameObject fullMap = createNewIcon(convertBoolArrayToMinimapSprite(boolArray, boolArrayWidth, boolArrayHeight), ParentTransform_tiles);
        GameObject fullMap = createNewIcon(applyColorArrayToMinimapSprite(persistentData.getMinimapColorArray(), boolArrayWidth, boolArrayHeight), ParentTransform_tiles);

        fullMap.GetComponent <RectTransform>().localScale = new Vector3(simpleRoomArrayWidth, -simpleRoomArrayHeight, 0f);

        // playerIcon = createNewIcon(drawCircleSprite_noBorder(playerIconRadius, color_playerIcon), ParentTransform_all);
        playerIcon = createNewIcon(drawCircleSprite_withBorder(playerIconRadius, borderThickness, color_playerIcon, color_walls), ParentTransform_all);
        //drawDoorSprite
        playerIconTransform = playerIcon.GetComponent <RectTransform>();

        itemOfInterestSprite = drawCircleSprite_noBorder(borderThickness, color_walls, color_invisible);
        doorSprite_red       = drawCircleSprite_withBorder(doorCenterRadius, borderThickness, color_doorRed, color_doorBorder);
        doorSprite_yellow    = drawCircleSprite_withBorder(doorCenterRadius, borderThickness, color_doorYellow, color_doorBorder);
        doorSprite_green     = drawCircleSprite_withBorder(doorCenterRadius, borderThickness, color_doorGreen, color_doorBorder);
        doorSprite_cyan      = drawCircleSprite_withBorder(doorCenterRadius, borderThickness, color_doorCyan, color_doorBorder);
        doorSprite_blue      = drawCircleSprite_withBorder(doorCenterRadius, borderThickness, color_doorBlue, color_doorBorder);
        doorSprite_magenta   = drawCircleSprite_withBorder(doorCenterRadius, borderThickness, color_doorMagenta, color_doorBorder);
        // portTownSprite = drawDiamondSprite_noBorder(color_explored);
        // portTownSprite = drawSquareSprite_noBorder(doorCenterRadius, color_playerIcon);
        portTownSprite = drawCircleSprite_noBorder(playerIconRadius, color_playerIcon, color_invisible2);


        // Initialize the final treasure icon:
        finalTreasureIcon = new MinimapIcon(createNewIcon(itemOfInterestSprite, ParentTransform_items),
                                            convertRoomCoordsToUICoords(simplePacket.getFinalTreasureLocation()[0], simplePacket.getFinalTreasureLocation()[1]),
                                            false);

        // Initialize all the key icons:
        bool[] hasKey = simplePacket.getHasKey();
        for (int index = 0; index < 6; index++)
        {
            if (hasKey[index])
            {
                keyIcons[index] = new MinimapIcon(createNewIcon(itemOfInterestSprite, ParentTransform_items),
                                                  convertRoomCoordsToUICoords(simplePacket.getKeyLocations()[index, 0], simplePacket.getKeyLocations()[index, 1]),
                                                  false);
            }
            else
            {
                keyIcons[index] = new MinimapIcon(createNewIcon(itemOfInterestSprite, ParentTransform_items),
                                                  convertRoomCoordsToUICoords(-2, -2),
                                                  false);
            }
        }

        // Initialize the door icons:
        numOfLockedDoors = simplePacket.getNumOfLockedDoors();
        doorIcons        = new MinimapIcon[numOfLockedDoors];
        for (int index = 0; index < numOfLockedDoors; index++)
        {
            doorIcons[index] = new MinimapIcon(createDoorIconFromID(simplePacket.getDoorColors()[index]),
                                               convertRoomCoordsToUICoords_forDoors(simplePacket.getDoorLocations()[index, 0], simplePacket.getDoorLocations()[index, 1], simplePacket.getDoorSides()[index]),
                                               false);
        }


        // exploreRoom(simplePacket.getPlayerStartingLocation()[0], simplePacket.getPlayerStartingLocation()[1]);
        // exploreRoom((byte)(simplePacket.getPlayerStartingLocation()[0]+1), simplePacket.getPlayerStartingLocation()[1]);
        // exploreRoom((byte)(simplePacket.getPlayerStartingLocation()[0]-1), simplePacket.getPlayerStartingLocation()[1]);
        // exploreRoom(simplePacket.getPlayerStartingLocation()[0], (byte)(simplePacket.getPlayerStartingLocation()[1]+1));
        // exploreRoom(simplePacket.getPlayerStartingLocation()[0], (byte)(simplePacket.getPlayerStartingLocation()[1]-1));


        byte[] startLocation = simplePacket.getPlayerStartingLocation();
        byte[] tempLocation  = new byte[2];

        exploreRoom(startLocation[0], startLocation[1]);

        if (startLocation[0] < simpleRoomArrayWidth - 1)
        {
            tempLocation[0] = (byte)(startLocation[0] + 1);
            tempLocation[1] = startLocation[1];
            if (simplePacket.getSimplifiedRoomArray()[tempLocation[0], tempLocation[1]].getIsNotEmpty())
            {
                exploreRoom(tempLocation[0], tempLocation[1]);
            }
        }

        if (startLocation[0] > 0)
        {
            tempLocation[0] = (byte)(startLocation[0] - 1);
            tempLocation[1] = startLocation[1];
            if (simplePacket.getSimplifiedRoomArray()[tempLocation[0], tempLocation[1]].getIsNotEmpty())
            {
                exploreRoom(tempLocation[0], tempLocation[1]);
            }
        }

        if (startLocation[1] < simpleRoomArrayHeight - 1)
        {
            tempLocation[0] = startLocation[0];
            tempLocation[1] = (byte)(startLocation[1] + 1);
            if (simplePacket.getSimplifiedRoomArray()[tempLocation[0], tempLocation[1]].getIsNotEmpty())
            {
                exploreRoom(tempLocation[0], tempLocation[1]);
            }
        }

        if (startLocation[1] > 0)
        {
            tempLocation[0] = startLocation[0];
            tempLocation[1] = (byte)(startLocation[1] - 1);
            if (simplePacket.getSimplifiedRoomArray()[tempLocation[0], tempLocation[1]].getIsNotEmpty())
            {
                exploreRoom(tempLocation[0], tempLocation[1]);
            }
        }
    }