public static Doorway getInitDoorway() { BetterList<Map> maps = allMaps; for(int i = 0;i<maps.size;i++) { if(_mapList[i].entryMap) { Doorway ret = new Doorway(_mapList[i].name,_mapList[i].defaultStart); return ret; } } return null; }
public DoorNode(Doorway doorway, bool isCorridor) { this.doorway = doorway; this.isCorridor = isCorridor; }
public void SelfDestroy() { Destroy(gameObject); Doorway.DecrementEnemyCount(); }
// AABB with some slight shrinkage of the box on the top side for perspective. public virtual bool Collides(Doorway doorway) { return(!(X + Width < doorway.X || X > doorway.X + doorway.Width || Y + Height < doorway.Y || Y > doorway.Y + doorway.Height)); }
/// <summary> /// Determines what is behind a door. /// </summary> /// <param name="level"></param> /// <param name="door"></param> /// <returns></returns> /// <remarks>For now this just calls the RoomGenerator, but once I've added chambers and passageways it will be a bit more complicated.</remarks> private bool ExpandDungeonLevel(DungeonLevel level, Doorway door) { return(_RoomGenerator.GenerateComponent(level, door)); }
public void OnDoorwayEnter(Doorway doorway) { var enterTarget = doorway.EnterTarget; _move.LeaveArena(enterTarget.transform.position); SoundManager.Instance.PlayWinTrack(); StartCoroutine(MainSessionManager.Instance.LevelComplete()); }
public override void SetupRoom(Doorway doorway, int story) { base.SetupRoom(doorway, story); GenerateStartingStairways(); }
/// <summary> /// Removes all doorways /// </summary> public void ClearDoorways() { left = right = top = bottom = null; }
// Delegate for the "go to" command. private void HandleGoto(string firstEntity) { // Attempt a split on the entity by whitespace char[] whitespace = { ' ' }; string[] words = firstEntity.Split(whitespace); string keyword = words[words.Length - 1]; // Get the parameters for the logical action. string room1 = stateManager.PositionToLocation(stateManager.Player.transform.position); // the room the player is in string target = keyword; // where the player wishes to go string agent = stateManager.PlayerName; // Setup the action string. action = ""; // If the target is an entrance at the room, if (stateManager.IsEntranceAt(target, room1)) { // and that entrance leads somewhere, setup the action. string room2 = stateManager.EntranceLeadsTo(target); if (!room2.Equals("")) { action = "(move-through-entrance " + agent + " " + room1 + " " + target + " " + room2 + ")"; } } // If the target and the room have a door between them, else if (stateManager.DoorBetween(room1, target)) { string door = stateManager.DoorName(room1, target); action = "(move-through-door " + agent + " " + room1 + " " + door + " " + target + ")"; } // Otherwise, the target should be a room with no door between. else { action = "(move-through-doorway " + agent + " " + room1 + " " + target + ")"; } // Test if the action is possible. bool actionIsPossible = mediator.IsApplicable(action); bool actionSucceeded = false; if (actionIsPossible) { // Great! Check the physics of the world to see if I can actually do that. // Assume we can't do it. command.text = CommandBuilder.PROXIMITY_ERROR; // Search the list of colliding objects, foreach (GameObject collided in colliding) { // If the collided object is a door, if (collided.tag.Equals("Door")) { Door door = collided.GetComponent <Door>(); // if the door we're colliding with is the one we've input to the command, if (door.ConnectsTo.Equals(target)) { // Attempt to execute the logical action! actionSucceeded = mediator.PlayerUpdate(action); if (actionSucceeded) { // Remove player from this room. stateManager.RemoveObject(stateManager.PlayerName, room1); Destroy(stateManager.Player.gameObject); // Update camera cameraController.LerpCamera(door.Direction); // Record the new spawn position for the player. SetFutureSpawnLocation(stateManager.PlayerGameObject.transform.position, door.Direction); // Clear the command. command.text = ""; // Exit the loop. break; } else { command.text = CommandBuilder.MEDIATION_ERROR; } } } // If the collided object is a doorway, else if (collided.tag.Equals("Doorway")) { Doorway doorway = collided.GetComponent <Doorway>(); // if the doorway we're colliding with is the one we've input to the command, if (doorway.ConnectsTo.Equals(target)) { // Attempt to execute the logical action! actionSucceeded = mediator.PlayerUpdate(action); if (actionSucceeded) { // Remove player from this room. stateManager.RemoveObject(stateManager.PlayerName, room1); Destroy(stateManager.Player.gameObject); // Update camera cameraController.LerpCamera(doorway.Direction); // Record the new spawn position for the player. SetFutureSpawnLocation(stateManager.PlayerGameObject.transform.position, doorway.Direction); // Clear the command. command.text = ""; // Break the loop. break; } else { command.text = CommandBuilder.MEDIATION_ERROR; } } } // If the collided object is an entrance, else if (collided.tag.Equals("Entrance")) { // If the entrance we're colliding is the one we've input, if (collided.name.Equals(target)) { // Attempt to execute the logical action! actionSucceeded = mediator.PlayerUpdate(action); if (actionSucceeded) { // Remove player from this room. stateManager.RemoveObject(stateManager.PlayerName, room1); Destroy(stateManager.Player.gameObject); // Update camera string room2 = stateManager.EntranceLeadsTo(target); GameObject room2gameObject = GameObject.Find(room2); cameraController.FadeOutCamera(room2gameObject.gameObject.transform.position); // Check if there's a symmetric exit where the player is going string symmetricExit = stateManager.SymmetricExitName(room1, room2); if (!symmetricExit.Equals("")) { // If there is such a symmetry, then the player will spawn at that exit. // It is more consistent with the real world. GameObject exit = GameObject.Find(symmetricExit); // if the exit is null, it means we haven't yet created the exit // (we're entering for the first time). if (exit == null) { // therefore, set the spawn location for the exit first. // if the location we're building this entrance at is outside, // then we need to get a special tile if (stateManager.IsOutdoors(room2)) { exit = stateManager.GetOutdoorLotTile(room2gameObject); } else { exit = stateManager.GetOpenTile(room2gameObject, false); } blackboard.Put(symmetricExit, exit.transform.position); } Vector3 exitLocation = exit.gameObject.transform.position; // Record the new spawn position for the player. SetFutureSpawnLocation(exitLocation); } // Clear the command. command.text = ""; // Break the loop. break; } } } if (actionSucceeded) // clear the list of colliding objects { colliding.Clear(); } } } else { // I don't think I'm able to do that. command.text = CommandBuilder.ACTION_ERROR; } }
public void SetParentDoorway(int doorwayIndex) { parent = doorways[doorwayIndex]; parent.SetActiveWithoutDoor(); }
void AddRoomsToDepth(Room startingRoom, int depth) { foreach (var currentRoomConnection in startingRoom.GetConnections()) { Room exitRoom; if (currentRoomConnection.isConnected) { exitRoom = currentRoomConnection.connectedTo; } else { // instance the next room exitRoom = (Room)Instantiate(GetRoom()); exitRoom.gameObject.SetActive(true); // need to find the connection point var cps = exitRoom.GetConnections(); Doorway newRoomConnectionPoint = cps[Random.Range(0, cps.Length)]; // rotate / translate the new room and connector to match the transform of the existing exit Transform newRoomConnectionTransform = newRoomConnectionPoint.transform; currentRoomConnection.transform.Rotate(0, 180, 0); // need to do this a few times to make sure all the axis line up // end with the up axis, as that is the most important one. I can't help but feel like there is a better way to handle this exitRoom.transform.rotation *= Quaternion.FromToRotation(newRoomConnectionTransform.forward, currentRoomConnection.transform.forward); exitRoom.transform.rotation *= Quaternion.FromToRotation(newRoomConnectionTransform.right, currentRoomConnection.transform.right); exitRoom.transform.rotation *= Quaternion.FromToRotation(newRoomConnectionTransform.up, currentRoomConnection.transform.up); // move the new room such that the transform matches with the last connection point exitRoom.transform.position += (currentRoomConnection.transform.position - newRoomConnectionTransform.position); // get a connector, sometimes Connector connector = null; if (Random.value < .5f) { connector = (Connector)Instantiate(GetConnector()); bool startEnd1 = Random.value < .5f; Transform connectorEndTransform = startEnd1 ? connector.end1 : connector.end2; Transform connectorOtherEndTransform = startEnd1 ? connector.end2 : connector.end1; connector.transform.rotation *= Quaternion.FromToRotation(connectorEndTransform.forward, currentRoomConnection.transform.forward); connector.transform.rotation *= Quaternion.FromToRotation(connectorEndTransform.right, currentRoomConnection.transform.right); connector.transform.rotation *= Quaternion.FromToRotation(connectorEndTransform.up, currentRoomConnection.transform.up); connector.transform.position += (currentRoomConnection.transform.position - connectorEndTransform.position); exitRoom.transform.position += (connectorOtherEndTransform.position - newRoomConnectionTransform.position); } exitRoom.CalcBounds(); // unrotate the point currentRoomConnection.transform.Rotate(0, 180, 0); // newRoomConnectionPoint.renderer.enabled = false; // link up the rooms in the room tree startingRoom.ConnectRoom(currentRoomConnection, connector, exitRoom); exitRoom.ConnectRoom(newRoomConnectionPoint, connector, startingRoom); } if (depth > 0) { AddRoomsToDepth(exitRoom, depth - 1); } } }
public PlayerBase () { if(_futureDoorway==null) { _futureDoorway = MapLibrary.getInitDoorway(); } }
public static void MakeRoom(Doorway door) { }
void Start() { door = transform.parent.transform.parent.GetComponent<Doorway>(); }
public override void SetupRoom(Doorway doorway, int story) { base.SetupRoom(doorway, story); SetKitchenPantryDimensions(); }
void PlaceConnectorRoom() { // Instantiate Room Room currentRoom = Instantiate(roomPrefabs[Random.Range(0, roomPrefabs.Count)]) as Room; currentRoom.transform.parent = this.transform; // Create doorway lists to loop over List <Doorway> currentAvailableDoorways = new List <Doorway>(allAvailableDoorways); List <Doorway> currentRoomDoorways = new List <Doorway>(); AddDoorwayToList(currentRoom, ref currentRoomDoorways); // Get doorways from current room and add them // randomly to the list of available doorways. AddDoorwayToList(currentRoom, ref allAvailableDoorways); bool roomPlaced = false; // Try all available doorways foreach (Doorway availableDoorway in currentAvailableDoorways) { Doorway currentDoorway = currentRoomDoorways[Random.Range(0, currentRoomDoorways.Count)]; // Position room PositionRoomAtDoorway(ref currentRoom, currentDoorway, availableDoorway); // Check room overlaps if (CheckRoomOverlap(currentRoom)) { // If overlap detected - skip to next iteration of the loop continue; } // No overlap, set this to true and... roomPlaced = true; // ...add room to list of placed rooms placedRooms.Add(currentRoom); // Remove occupied doorways currentDoorway.gameObject.SetActive(false); allAvailableDoorways.Remove(currentDoorway); availableDoorway.gameObject.SetActive(false); allAvailableDoorways.Remove(availableDoorway); // Exit loop if room has been placed. if (roomPlaced) { break; } } // Room couldn't be placed. Restart generator and try again if (!roomPlaced) { Destroy(currentRoom.gameObject); ResetLevelGenerator(); } }