Beispiel #1
0
    public void DrawAvailablePlots()
    {
        if (BuilderManager.InDeleteObjectMode)
        {
            _builderManager.DeactivateDeleteRoomMode();
        }

        RoomBlueprint selectedRoomBlueprint = _builderManager.SelectedRoom;

        BuildMenuWorldSpaceContainer.Instance.DestroyBuildingPlots();

        for (int i = 0; i < RoomManager.Rooms.Count; i++)
        {
            Room existingRoom = RoomManager.Rooms[i];
            //Logger.Log("*********************");
            //Logger.Log("");
            //Logger.Log("Start looking at next room at {0}, {1}", existingRoom.RoomCorners[Direction.Down].x, existingRoom.RoomCorners[Direction.Down].y);
            //Logger.Log("");
            //Logger.Log("*********************");
            // for each door, check if it aligns with the doors of the selected room
            for (int j = 0; j < existingRoom.Doors.Count; j++)
            {
                Door existingDoor = existingRoom.Doors[j];
                if (existingDoor.DoorConnection != null)
                {
                    continue;                                      // if the door is already activated, no need to check for new connections
                }
                bool createdPlotForDoor = false;

                // the doors that are already on the map
                GridLocation doorPositionOnExistingRoom = GridHelper.VectorToGridLocation(existingDoor.transform.position);

                createdPlotForDoor = TryBuildPlot(ObjectRotation.Rotation0, selectedRoomBlueprint, doorPositionOnExistingRoom);
                if (!createdPlotForDoor)
                {
                    createdPlotForDoor = TryBuildPlot(ObjectRotation.Rotation90, selectedRoomBlueprint, doorPositionOnExistingRoom);
                }
                if (!createdPlotForDoor)
                {
                    createdPlotForDoor = TryBuildPlot(ObjectRotation.Rotation180, selectedRoomBlueprint, doorPositionOnExistingRoom);
                }
                if (!createdPlotForDoor)
                {
                    TryBuildPlot(ObjectRotation.Rotation270, selectedRoomBlueprint, doorPositionOnExistingRoom);
                }
            }
        }

        //Initial room space to avoid an empty map.
        if (RoomManager.Rooms.Count == 0)
        {
            BuildMenuWorldSpaceContainer.Instance.CreateBuildingPlot(_builderManager.BuildPlotPrefab, selectedRoomBlueprint, new Vector2(0, 0), ObjectRotation.Rotation0);
        }
    }
    public void DeactivateBuildMenuMode()
    {
        InBuildMode = false;
        BuildMenuContainer.Instance.IsOpen     = false;
        BuildMenuContainer.Instance.IsBuilding = false;

        BuildMenuContainer.Instance.RemoveBuildMenuContent(0.5f);
        MainCanvas.Instance.UnsetPointerImage();
        DeleteAllTriggers();

        BuildMenuWorldSpaceContainer.Instance.DestroyBuildingPlots();
        BuildMenuTabContainer.Instance.ResetCurrentBuildMenuTab();

        if (InDeleteObjectMode)
        {
            Instance.DeactivateDeleteRoomMode();
        }
    }