Exemplo n.º 1
0
    public void BuildRoom(RoomBlueprint roomBlueprint, BuildingTileBuilder buildingTileBuilder, BuildingPlotBuilder buildingPlotBuilder, Vector2 startingPoint, ObjectRotation roomRotation)
    {
        GameObject roomGO = GameManager.Instance.InstantiatePrefab(BuilderManager.Instance.RegisteredRoomPrefabs[roomBlueprint.RoomName][roomRotation], BuilderManager.Instance.RoomsContainer.transform, startingPoint);

        Room room = roomGO.GetComponent <Room>();

        room.RoomRotation  = roomRotation;
        room.RoomBlueprint = roomBlueprint;
        room.Initialise();
        room.RoomObjectsContainer.InitialiseRoomObjects();
        RoomManager.Instance.AddRoom(room);

        int rightUpAxisLength = roomRotation == ObjectRotation.Rotation0 || roomRotation == ObjectRotation.Rotation180 ?
                                roomBlueprint.RightUpAxisLength : roomBlueprint.LeftUpAxisLength;
        int leftUpAxisLength = roomRotation == ObjectRotation.Rotation0 || roomRotation == ObjectRotation.Rotation180 ?
                               roomBlueprint.LeftUpAxisLength : roomBlueprint.RightUpAxisLength;

        Vector2 point1 = GridHelper.GridToVectorLocation(startingPoint, rightUpAxisLength, 0);
        Vector2 point2 = GridHelper.GridToVectorLocation(point1, 0, -leftUpAxisLength);
        Vector2 point3 = GridHelper.GridToVectorLocation(point2, -rightUpAxisLength, 0);

        Dictionary <Direction, Vector2> roomCorners = new Dictionary <Direction, Vector2>()
        {
            { Direction.Down, startingPoint },
            { Direction.Right, point1 },
            { Direction.Up, point2 },
            { Direction.Left, point3 },
        };

        room.SetupCorners(roomCorners);
        room.SetupCollider();
        room.SetGraphUpdateScenePoints();

        // the sprites should already be part of the room prefab. The scripts should be on the sprites. But on start() of the room, all scripts should be initalised and added to the room's []
        //room.SetupRoomObjects();

        buildingTileBuilder.UpdateBuildingTiles(room);

        FollowUpRoomBuilding(roomBlueprint, roomCorners, buildingPlotBuilder);
        room.UpdateRoomNavhMesh();
    }
    void Awake()
    {
        Instance                 = this;
        InBuildMode              = false;
        InDeleteObjectMode       = false;
        PointerIsOnAvailablePlot = false;

        SelectedRoom = null;

        //Guard.CheckIsNull(Room1Prefab, "Room1Prefab");
        Guard.CheckIsNull(BuildPlotPrefab, "BuildPlotPrefab");
        Guard.CheckIsNull(RoomsContainer, "RoomsContainer");
        Guard.CheckIsNull(BuildHallwayTriggerPrefab, "BuildHallwayTriggerPrefab");
        Guard.CheckIsNull(DeleteRoomTriggerPrefab, "DeleteRoomTriggerPrefab");

        BuildingPlots.Clear();
        BuildingPlotLocations.Clear();

        //////////////////
        // Room prefabs
        //////////////////

        RegisterRooms();
        LoadRoomPrefabs();

        //////////////////
        // Room object prefabs
        //////////////////

        RegisterPlaceableRoomObjects();
        LoadPlaceableRoomObjects();



        _buildingPlotBuilder = new BuildingPlotBuilder();
        _buildingTileBuilder = new BuildingTileBuilder();
        _roomBuilder         = new RoomBuilder();
        _roomObjectBuilder   = new RoomObjectBuilder();
    }
Exemplo n.º 3
0
 public void BuildRoom(RoomBlueprint roomBlueprint, BuildingTileBuilder buildingTileBuilder, BuildingPlotBuilder buildingPlotBuilder, BuildingPlot buildingPlot)
 {
     BuildRoom(roomBlueprint, buildingTileBuilder, buildingPlotBuilder, buildingPlot.StartingPoint, buildingPlot.PlotRotation);
 }
Exemplo n.º 4
0
    public void BuildRoom(List <string> arguments)
    {
        if (arguments.Count == 1)
        {
            Console.Instance.PrintToReportText("Build scenario number needed as argument in order to build rooms.");
            return;
        }
        Logger.Log("Number of rooms : {0}", RoomManager.Rooms.Count);

        //prepare
        BuilderManager.Instance.DeactivateBuildMenuMode();

        // remove all existing rooms
        RoomManager.Instance.DeleteAllRooms();

        BuilderManager.Instance.BuildingTiles.Clear();
        BuilderManager.Instance.BuildingTileLocations.Clear();

        // build room scenario
        int buildScenario;

        if (int.TryParse(arguments[1], out buildScenario))
        {
            switch (buildScenario)
            {
            case 1:
                BuildingTileBuilder buildingTileBuilder = new BuildingTileBuilder();

                buildingTileBuilder.SetupInitialBuildingTiles();

                for (int i = 0; i < CharacterManager.Instance.Characters.Count; i++)
                {
                    CharacterManager.Instance.Characters[i].CurrentRoom = null;
                }

                RoomBlueprint room1   = RoomBlueprint.CreateBlueprint(RoomName.Room1);
                RoomBlueprint hallway = RoomBlueprint.CreateBlueprint(RoomName.Hallway);

                BuilderManager.Instance.BuildRoom(room1, new Vector2(0, 0), ObjectRotation.Rotation0);
                BuilderManager.Instance.BuildRoom(room1, new Vector2(45, -37.5f), ObjectRotation.Rotation180);
                BuilderManager.Instance.BuildRoom(room1, new Vector2(60, -75), ObjectRotation.Rotation180);
                BuilderManager.Instance.BuildRoom(room1, new Vector2(-15, -67.5f), ObjectRotation.Rotation270);

                BuilderManager.Instance.BuildRoom(hallway, new Vector2(30, 0), ObjectRotation.Rotation0);
                BuilderManager.Instance.BuildRoom(hallway, new Vector2(45, -7.5f), ObjectRotation.Rotation0);
                BuilderManager.Instance.BuildRoom(hallway, new Vector2(30, -15), ObjectRotation.Rotation0);
                BuilderManager.Instance.BuildRoom(hallway, new Vector2(15, -22.5f), ObjectRotation.Rotation0);
                BuilderManager.Instance.BuildRoom(hallway, new Vector2(0, -30), ObjectRotation.Rotation0);
                BuilderManager.Instance.BuildRoom(hallway, new Vector2(15, -37.5f), ObjectRotation.Rotation0);
                BuilderManager.Instance.BuildRoom(hallway, new Vector2(30, -45), ObjectRotation.Rotation0);
                BuilderManager.Instance.BuildRoom(hallway, new Vector2(45, -52.5f), ObjectRotation.Rotation0);
                BuilderManager.Instance.BuildRoom(hallway, new Vector2(0, -45), ObjectRotation.Rotation0);

                BuildHallwayTrigger.DeleteAllHallwayTriggers();

                // set current room characters?
                break;

            default:
                Console.Instance.PrintToReportText("Unknown build command to build " + arguments[0]);
                break;
            }
        }
        else
        {
            Console.Instance.PrintToReportText("Argument 1 for Build [room] should be an int. Could not parse argument #" + (2) + " (" + arguments[1] + ")");
            return;
        }

        Console.Instance.PrintToReportText("Built room");
    }