add basic inventory, fading walls

This commit is contained in:
2026-02-17 15:26:34 -06:00
parent 6baa6956bf
commit 7123238daa
30 changed files with 6594 additions and 255 deletions
+55 -8
View File
@@ -1,12 +1,16 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class CameraController : MonoBehaviour
{
private float moveSpeed = 50.0f;
private float zoomSpeed = 20.0f;
private bool isTracking = false; // don't track when parented
private bool returningHome = false; // cam is on its way home
private float baseCamSize = 5; // this is how "zoomed" the ortho cam is
private float baseCamSize = 7; // this is how "zoomed" the ortho cam is
private float camMovementTime = 0.9f; // how much time to switch cam positions
private float moveSpeed;
private float zoomSpeed;
public Transform playerCamHome; // camera's home base
public GameObject cameraObj;
@@ -14,29 +18,72 @@ public class CameraController : MonoBehaviour
private Vector3 currentCamPosition;
private float desiredCamSize;
private int positionsSet = 0; // this keeps track of how many cam zones we're in
private List<StaticCamRoom> roomsActive;
public void SetCurrentPosition(Vector3 currentCamPosition, float desiredCamSize)
{
positionsSet++; // we have entered a cam zone
cameraObj.transform.parent = null;
float distanceToMove = Vector3.Distance(this.currentCamPosition, currentCamPosition);
float amountToZoom = Mathf.Abs(this.desiredCamSize - desiredCamSize);
moveSpeed = distanceToMove / camMovementTime;
zoomSpeed = amountToZoom / camMovementTime;
isTracking = true;
returningHome = false;
cameraObj.transform.parent = null;
this.currentCamPosition = currentCamPosition;
this.desiredCamSize = desiredCamSize;
}
public void ReturnCameraToHome()
{
isTracking = false;
returningHome = true;
positionsSet--; // we have exited a cam zone
// if this number is greater than 1, we have left a zone but are still in another
if (positionsSet <= 0)
{
positionsSet = 0;
currentCamPosition = playerCamHome.position;
desiredCamSize = baseCamSize;
float distanceToMove = Vector3.Distance(this.currentCamPosition, playerCamHome.position);
float amountToZoom = Mathf.Abs(this.desiredCamSize - baseCamSize);
moveSpeed = distanceToMove / camMovementTime;
zoomSpeed = amountToZoom / camMovementTime;
isTracking = false;
returningHome = true;
currentCamPosition = playerCamHome.position;
desiredCamSize = baseCamSize;
}
}
public void AddToRoomsActive(StaticCamRoom room)
{
roomsActive.Add(room);
room.RoomEnter();
}
public void RemoveFromRoomsActive(StaticCamRoom room)
{
List<Transform> wallsToKeep = new List<Transform>();
roomsActive.Remove(room);
foreach (StaticCamRoom staticCamRoom in roomsActive)
{
wallsToKeep.AddRange(staticCamRoom.objectsToHide);
}
room.RoomExit(wallsToKeep);
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
cameraComponent = cameraObj.GetComponent<Camera>();
roomsActive = new List<StaticCamRoom>();
ReturnCameraToHome();
}