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]);
            }
        }
    }
Esempio n. 2
0
 public byte getAreaHeight()
 {
     return(simplePacket.getAreaHeight());
 }