private void OnAnyRoomCompleteEventHandler(RoomActivator room) { Performance previous = current; if (percentLoss >= damageThreshold) { current = Performance.BAD; } else if (percentLoss <= healthGoal) { current = Performance.GOOD; } else { current = Performance.NEUTRAL; } addLostHealth = false; performanceValue += performanceIndex[current]; OnPerformanceChange?.Invoke(performanceValue); Debug.Log("Last Performance: " + previous.ToString()); Debug.Log("Current Performance: " + current.ToString()); Performance final = Performance.NEUTRAL; if (currentHealth >= damageThreshold) { final = Performance.GOOD; } else if (currentHealth <= healthGoal) { final = Performance.BAD; } OnFinalPerformancChange?.Invoke(final); }
/// <summary> /// Sets the active state for the given room. /// </summary> /// <param name="y">The y coordinate of the player.</param> /// <param name="r">The room to be activated.</param> void SetActiveState(float y, RoomActivator r) { bool active = y <= r.top && y > r.bottom; if (active) { StartDialogue(); } r.gameObject.SetActive(active); foreach (NPCController n in r.characters) { bool nRoom = n.CurrentHours.location.y < r.top && n.CurrentHours.location.y >= r.bottom; if (nRoom) { if (n.PresentInOffice && active) { n.Fs.Show(); } else { n.Fs.Hide(); } } } }
protected void OnAnyRoomEnteredEventHandler(RoomActivator room) { if (activator.Equals(room)) { if (difficultyStage > 0) { AddEnemies(amountToChange); } else if (difficultyStage < 0) { RemoveEnemies(amountToChange); } } }
private void OnAnyRoomEnteredEventHandler(RoomActivator room) { if (activator.Equals(room)) { if (amountToAdd > 0) { AddTraps(); } else if (amountToAdd < 0) { RemoveTraps(); } } foreach (GameObject trap in currentTraps) { trap.SetActive(true); } }
void Start() { // Create dungeon shape Instantiate(layoutRoom, generatorPoint.position, generatorPoint.rotation); for (int i = 0; i < distanceToEnd; i++) { selectedDirection = (Direction)Random.Range(0, 4); MoveGenerationPoint(); while (Physics2D.OverlapCircle(generatorPoint.position, .2f, whatIsRoom)) { MoveGenerationPoint(); } GameObject newRoom = Instantiate(layoutRoom, generatorPoint.position, generatorPoint.rotation); layoutRoomObjects.Add(newRoom); if (i + 1 == distanceToEnd) { layoutRoomObjects.RemoveAt(layoutRoomObjects.Count - 1); endRoom = newRoom; } } // Place room frames CreateRoomOutline(Vector3.zero + zOffset); foreach (GameObject room in layoutRoomObjects) { CreateRoomOutline(room.transform.position); } CreateRoomOutline(endRoom.transform.position); // Place room centers foreach (GameObject outline in generatedOutlines) { Vector3 centerPosition = new Vector3(outline.transform.position.x, outline.transform.position.y, outline.transform.position.z + 1); RoomCenter currentCenter = null; if (outline.transform.position == Vector3.zero + zOffset) { currentCenter = Instantiate(centerStart, centerPosition, transform.rotation); } else if (outline.transform.position == endRoom.transform.position) { currentCenter = Instantiate(centerEnd, centerPosition, transform.rotation); endRoomCenter = currentCenter; } else { int centerSelect = Random.Range(0, potentialCenters.Length); currentCenter = Instantiate(potentialCenters[centerSelect], centerPosition, transform.rotation); } roomCenters.Add(centerPosition, currentCenter); currentCenter.theRoom = outline.GetComponent <Room>(); currentCenter.activator.doors = currentCenter.theRoom.doors; } foreach (KeyValuePair <Vector3, RoomCenter> entry in roomCenters) { // Store adjacent information Vector3 roomPosition = entry.Key; RoomActivator activator = entry.Value.activator; List <Vector3> adjacents = new List <Vector3>() { roomPosition + new Vector3(0f, yOffset, 0f), roomPosition + new Vector3(0f, -yOffset, 0f), roomPosition + new Vector3(-xOffset, 0f, 0f), roomPosition + new Vector3(xOffset, 0f, 0f) }; foreach (Vector3 roomPos in adjacents) { activator.adjacent.Add(roomCenters.ContainsKey(roomPos) ? roomCenters[roomPos].activator : null); } // Store information on normal and boss room(s) Vector3 endPos = endRoomCenter.transform.position; activator.endRoom = roomPosition != endPos ? roomCenters[endPos].activator : null; } }