public void InitialiseRoomObjects() { if (RoomObjects.Count == 0) { Logger.Warning("Found 0 Room objects for room {0}. Possibly the room objects need to be added to the container.", Room.Id); } for (int i = 0; i < RoomObjects.Count; i++) { if (RoomObjects[i].RoomObject == null) { Logger.Warning("Could not find a scriptable room object for the object {0}", RoomObjects[i].gameObject.name); continue; } RoomObjectBlueprint roomObjectBlueprint = RoomObjectBlueprint.Create(RoomObjects[i].RoomObject.RoomObjectName); RoomObjects[i].Initialise(roomObjectBlueprint, Room.RoomRotation, Room); } }
// Used when player builds a new object. Not used for the default objects that already are part of the room, as they do not need a separate GO instantiation. public void BuildRoomObject(RoomObjectBlueprint roomObjectBlueprint, GridLocation roomObjectLocation, Room parentRoom) { Logger.Log("Trying to put a {0} in the room", roomObjectBlueprint.Name); GridLocation rotationTranslatedObjectLocation = TranslateObjectLocationForRoomRotation(roomObjectLocation, parentRoom); Vector2 roomObjectLocalLocation = GridHelper.GridToVectorLocation(rotationTranslatedObjectLocation); Vector2 roomObjectWorldPosition = new Vector2(parentRoom.RoomCorners[Direction.Down].x + roomObjectLocalLocation.x, parentRoom.RoomCorners[Direction.Down].y + roomObjectLocalLocation.y); GameObject roomObjectGO = GameManager.Instance.InstantiatePrefab( BuilderManager.Instance.PlaceableRoomObjectPrefabs[roomObjectBlueprint.RoomObjectName][ObjectRotation.Rotation0], parentRoom.RoomObjectsContainer.transform, roomObjectWorldPosition); RoomObjectGO roomObject = roomObjectGO.GetComponent <RoomObjectGO>(); roomObject.Initialise(roomObjectBlueprint, parentRoom.RoomRotation, parentRoom); parentRoom.RoomObjectsContainer.AddRoomObject(roomObject); }
public RoomObjectBlueprintForRoom(RoomObjectBlueprint roomObjectBlueprint, GridLocation roomObjectLocation) { RoomObjectBlueprint = roomObjectBlueprint; RoomObjectLocation = roomObjectLocation; }
public void Initialise(RoomObjectBlueprint roomObjectBlueprint, ObjectRotation roomObjectRotation, Room parentRoom) { RoomObjectBlueprint = roomObjectBlueprint; RoomObjectRotation = roomObjectRotation; ParentRoom = parentRoom; }
public void BuildRoomObject(RoomObjectBlueprint roomObjectBlueprint, GridLocation roomObjectLocation, Room parentRoom) { _roomObjectBuilder.BuildRoomObject(roomObjectBlueprint, roomObjectLocation, parentRoom); }