fixed camera system and brightened recipticles

This commit is contained in:
2023-05-10 23:59:58 -04:00
parent d90419f579
commit aafb240391
181 changed files with 35174 additions and 2991 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e0ef4ce8a6c29c1488c4d1cfc6b0bb17
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EmissiveLightMatching : MonoBehaviour
{
[SerializeField]
private List<int> indexes;
private List<Color> colors= new List<Color>();
[SerializeField]
private Light reference;
private float initIntensity;
private void Awake()
{
initIntensity = reference.intensity;
}
// Start is called before the first frame update
void Start()
{
foreach(int index in indexes) {
colors.Add(this.gameObject.GetComponent<MeshRenderer>().materials[index].GetColor("_EmissiveColor"));
}
}
// Update is called once per frame
void Update()
{
int x = 0;
foreach(int i in indexes)
{
this.gameObject.GetComponent<MeshRenderer>().materials[i].SetColor("_EmissiveColor", colors[x] * ((10*reference.intensity / initIntensity)));
x++;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5121ccf5a359b594aa31296fd9902dfb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -18,7 +18,7 @@ public class DoorInteractable : HeavyItemReceiver
public bool Powered { get { return this.insertedCore!= null; } }
[SerializeField]
private Animator anim;
private Animator[] anims;
// Start is called before the first frame update
void Start()
{
@ -28,7 +28,11 @@ public class DoorInteractable : HeavyItemReceiver
// Update is called once per frame
void Update()
{
anim.SetBool("IsPowered", Powered);
foreach(Animator anim in anims)
{
anim.SetBool("IsPowered", Powered);
}
}
public override bool Interact()
{

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 06fbfed4d1ea81a41bbcde89f691be0d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1f02ae7c1e256284fb81278af2697803
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,233 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BasicLevelProgressionSystem : MonoBehaviour
{
[SerializeField]
private ObjectiveText objectiveGui;
[SerializeField]
private WaypointMarker marker;
[SerializeField]
private PlayerComponent player;
[SerializeField]
private float minDist = 3;
[SerializeField]
private List<ProgressionSection> sections;
public List<ProgressionSection> Sections { get { return sections; } }
//Fire1 is click or A
//Place is F or "Y" button
//Cycle is Tab or RB
//Siwtch is Shift or "X"
public enum InputType { FIRE1, PLACE, CYCLE, SWITCH, COLLISION, LOCATION,AIM,EXTERNAL};
private int progress = 0;
private bool transitioning = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
Transform cur = this.getCurrent().getActive();
if(cur != null)
{
if (!this.getCurrent().objectiveOneMet)
{
marker.target = cur;
objectiveGui.visualObjects[0].text.text = this.getCurrent().instruction1;
objectiveGui.visualObjects[1].text.text = this.getCurrent().istruction2;
}
else if(!this.getCurrent().objectiveTwoMet)
{
marker.target = cur;
}
}
if(Input.GetButtonDown("Fire1")||Input.GetAxis("Fire1")>0.5f&&!transitioning)
{
ProgressCurrentIfInput(InputType.FIRE1);
}
if (Input.GetButtonDown("TempPlace"))
{
ProgressCurrentIfInput(InputType.PLACE);
}
if (Input.GetButtonDown("CycleItems"))
{
ProgressCurrentIfInput(InputType.CYCLE);
}
if(Input.GetButtonDown("Fire3"))
{
ProgressCurrentIfInput(InputType.SWITCH);
}
if(Input.GetAxis("Aim")>.5f || Input.GetButtonDown("Aim"))
{
if(!transitioning)
ProgressCurrentIfInput(InputType.AIM);
}
if (Vector3.Distance(player.transform.position, this.getCurrent().getActive().position) < 3)
{
bool canIterate= this.getCurrent().Iterate();
if (!canIterate)
{
if (!this.getCurrent().objectiveOneMet && this.getCurrent().conditionalOne == InputType.LOCATION)
{
OnePassed();
}else if (this.getCurrent().objectiveOneMet && this.getCurrent().conditionalTwo == InputType.LOCATION && !this.getCurrent().objectiveTwoMet)
{
TwoPassed();
}
}
}
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.GetComponentInParent<PlayerComponent>() != null)
{
ProgressCurrentIfCollide();
}
}
void ProgressCurrentIfCollide()
{
}
private void OnePassed()
{
this.getCurrent().objectiveOneMet = true;
this.getCurrent().Progress();
this.objectiveGui.visualObjects[0].isComplete = true;
}
public void TwoPassed()
{
if (transitioning)
{
return;
}
this.getCurrent().objectiveTwoMet = true;
this.objectiveGui.visualObjects[1].isComplete = true;
this.objectiveGui.FadeOut();
transitioning = true;
StartCoroutine(waitForFadeIn());
}
public void ProgressCurrentIfInput(InputType type)
{
if (this.getCurrent().AtEnd() && this.getCurrent().conditionalOne == type&&!this.getCurrent().objectiveOneMet)
{
OnePassed();
}else if(this.getCurrent().AtEnd() && this.getCurrent().conditionalTwo == type)
{
TwoPassed();
}
}
public ProgressionSection getCurrent()
{
return this.sections[progress];
}
private IEnumerator waitForFadeIn()
{
yield return new WaitForSeconds(3);
if (this.sections.Count > this.progress+1)
{
this.progress++;
this.objectiveGui.FadeIn();
this.objectiveGui.visualObjects[0].isComplete = false;
this.objectiveGui.visualObjects[1].isComplete = false;
}
else
{
}
transitioning = false;
}
}
[System.Serializable]
public class ProgressionSection
{
[SerializeField]
public string instruction1;
[SerializeField]
public string istruction2;
[SerializeField]
public bool objectiveOneMet = false;
[SerializeField]
public BasicLevelProgressionSystem.InputType conditionalOne;
[SerializeField]
public bool objectiveTwoMet = false;
[SerializeField]
public BasicLevelProgressionSystem.InputType conditionalTwo;
[SerializeField]
public List<Transform> positionsOne= new List<Transform>();
[SerializeField]
public List<Transform> positionsTwo = new List<Transform>();
[HideInInspector]
public int activePosition = 0;
public Transform getActive()
{
if (!objectiveOneMet)
{
return positionsOne[activePosition];
}
else
{
return positionsTwo[activePosition];
}
}
public bool Iterate()
{
if (!objectiveOneMet && this.activePosition + 1 < positionsOne.Count)
{
this.activePosition += 1;
return true;
}else if (objectiveOneMet && !objectiveTwoMet && this.activePosition + 1 < positionsTwo.Count)
{
this.activePosition += 1;
return true;
}
return false;
}
public bool AtEnd()
{
if (!objectiveOneMet && this.activePosition + 1 < positionsOne.Count)
{
return false;
}
else if (objectiveOneMet && !objectiveTwoMet && this.activePosition + 1 < positionsTwo.Count)
{
return false;
}
return true;
}
public void Progress()
{
this.activePosition = 0;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b320804c8114b8e4b954e2f51b5b8083
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,125 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelZeroSpecial : MonoBehaviour
{
[SerializeField]
private int initalPlaceIndex = 0;
[SerializeField]
private DoorInteractable recepticleOne;
[SerializeField]
private BasicLevelProgressionSystem progression;
[SerializeField]
private int enabledOn = 4;
private bool isEnabled = false;
[SerializeField]
private List<HeavyInteractableItem> powercores;
[SerializeField]
private List<DoorInteractable> recepticals;
[SerializeField]
private WaypointMarker marker;
private List<WaypointMarker> markers=new List<WaypointMarker>();
private int countPowered = 0;
[SerializeField]
private Animator cover;
[SerializeField]
private Animator gate;
private bool transitioningOut = false;
[SerializeField]
private GameObject exitCollider;
[SerializeField]
private PlayerComponent player;
[SerializeField]
WaypointMarker marker2Ref;
[SerializeField]
WaypointMarker marker3Ref;
// Start is called before the first frame update
void Start()
{
marker2Ref.gameObject.SetActive(false);
marker3Ref.gameObject.SetActive(false);
}
// Update is called once per frame
void Update()
{
if (progression.Sections[0] == progression.getCurrent())
{
if (recepticleOne.Powered)
{
progression.TwoPassed();
//progression.ProgressCurrentIfInput(BasicLevelProgressionSystem.InputType.EXTERNAL);
}
}
countPowered = 0;
if (progression.Sections[enabledOn] == progression.getCurrent() && !isEnabled)
{
isEnabled = true;
marker2Ref.gameObject.SetActive(true);
marker3Ref.gameObject.SetActive(true);
marker2Ref.target = recepticals[1].transform;
marker3Ref.target = recepticals[2].transform;
markers.Add(marker2Ref);
markers.Add(marker3Ref);
}
if (isEnabled)
{
foreach (DoorInteractable recepitcal in recepticals)
{
if (recepitcal.Powered)
{
countPowered++;
for(int i = 0; i < markers.Count; i++)
{
WaypointMarker marker = markers[i];
if (marker.gameObject.activeInHierarchy)
{
if (marker.target = recepitcal.transform)
{
marker.gameObject.SetActive(true);
markers.Remove(marker);
}
}
}
}
}
}
if (countPowered == 3 && !transitioningOut)
{
//transition to cutscene
transitioningOut = true;
gate.Play("Open");
}
if (transitioningOut)
{
if (player.transform.position.z > exitCollider.transform.position.z)
{
StartCoroutine(transitionOut());
}
}
}
IEnumerator transitionOut()
{
cover.Play("Cover_load_out");
yield return new WaitForSeconds(1);
SceneManager.LoadScene(0);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a6ee2a8c2974b854f8f08c34f8414193
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -19,6 +19,9 @@ public class MainMenuManager : MonoBehaviour
private float initDilate;
[SerializeField]
float dilateSpeed = 0.1f;
[SerializeField]
private Animator cover;
private bool transitioning = false;
// Start is called before the first frame update
void Start()
@ -40,8 +43,20 @@ public class MainMenuManager : MonoBehaviour
}
void LoadFirstLevel()
{
if (!transitioning)
{
cover.Play("Cover_load_out");
transitioning = true;
StartCoroutine(_LoadFirstLevel());
}
}
private IEnumerator _LoadFirstLevel()
{
yield return new WaitForSeconds(4);
SceneManager.LoadScene(1);
}
void ExitApp()
{
Application.Quit();

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Xml;
using Unity.VisualScripting;
using Unity.VisualScripting.FullSerializer;
using UnityEngine;
[RequireComponent(typeof(Collider))]
@ -45,6 +46,9 @@ public class PlayerInteractionHandler : MonoBehaviour
public bool isDead = false;
//Check if button down
private AxisIsDown fireDown = new AxisIsDown("Fire1");
// Start is called before the first frame update
void Start()
{
@ -76,16 +80,36 @@ public class PlayerInteractionHandler : MonoBehaviour
index = -1;
return false;
}
private void DropHeavy()
{
if (heavyInvent != null)
{
heavyInvent.transform.parent = null;
heavyInvent.GetComponent<Rigidbody>().isKinematic = false;
heavyInvent.EnableAll();
heavyInvent = null;
}
}
// Update is called once per frame
void Update()
{
fireDown.Check();
if (this.isDead)
{
DropHeavy();
return;
}
if (manager.IsPaused||isDead)
{
return;
}
if(Input.GetButtonDown("Fire1"))
if(Input.GetButtonDown("Fire1")||fireDown.IsDown())
{
if (this.GunEnabled)
{
@ -173,10 +197,7 @@ public class PlayerInteractionHandler : MonoBehaviour
}
else
{
heavyInvent.transform.parent = null;
heavyInvent.GetComponent<Rigidbody>().isKinematic = false;
heavyInvent.EnableAll();
heavyInvent = null;
this.DropHeavy();
}
@ -233,6 +254,7 @@ public class PlayerInteractionHandler : MonoBehaviour
{
}
}
public void EnableFlashlight()
{
@ -292,3 +314,41 @@ public class PlayerInteractionHandler : MonoBehaviour
}
}
}
class AxisIsDown
{
private string axisName;
private bool isDown = false;
private bool pIsDown = false;
private float axis;
private bool down = false;
public void Check()
{
axis = Input.GetAxis(axisName);
isDown = axis > 0.5f;
if (isDown != pIsDown&&isDown)
{
down = true;
}
else
{
down = false;
}
pIsDown = isDown;
}
public bool IsDown()
{
return this.down;
}
public AxisIsDown(string axisName)
{
this.axisName = axisName;
}
}

View File

@ -69,9 +69,12 @@ public class PlayerMovementController : MonoBehaviour
private void MovePlayer()
{
Vector3 movement = Vector3.zero;
movement += transform.forward * Mathf.Abs(y) * Time.deltaTime * speed;//+(transform.right*x*Time.deltaTime*speed);
//movement += transform.right * Mathf.Abs(x) * Time.deltaTime * sideSpeed;
movement += transform.forward * Mathf.Abs(x) * Time.deltaTime * speed;
//movement += transform.forward * Mathf.Abs(y) * Time.deltaTime * speed;//+(transform.right*x*Time.deltaTime*speed);
movement += cam.transform.forward *y * Time.deltaTime * speed;
//movement += transform.forward * Mathf.Abs(x) * Time.deltaTime * speed;
movement += cam.transform.right * x * Time.deltaTime*speed;
movement += Vector3.down * 9.8f;
ccontroller.Move(movement);
}

8
Assets/Scripts/UI.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 17c091ad42d7a2044a46bed603538f3c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
[ExecuteAlways]
public class ObjectiveText : MonoBehaviour
{
[SerializeField]
public List<VisualObjectiveItemGUI> visualObjects;
[SerializeField]
private Color inCompleteColor = Color.white;
[SerializeField]
private Color completeColor = Color.yellow;
[SerializeField]
private float speed;
[SerializeField]
private Animator animator;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
foreach(VisualObjectiveItemGUI item in visualObjects)
{
if (item.isComplete){
item.icon.color = Color.Lerp(item.icon.color, completeColor, Time.deltaTime*speed);
}
else
{
item.icon.color = Color.Lerp(item.icon.color,inCompleteColor, Time.deltaTime*speed);
}
}
}
public void FadeOut()
{
animator.Play("FadeOut");
}
public void FadeIn()
{
animator.Play("FadeIn");
}
}
[System.Serializable]
public class VisualObjectiveItemGUI
{
public TMP_Text text;
public Image icon;
public bool isComplete = false;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 656ea18f8036d57408f6593b0ad3c9ec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class WaypointMarker : MonoBehaviour
{
public Image pointer;
public Transform target;
public TMP_Text distanceMarker;
private Vector2 offset;
// Start is called before the first frame update
void Start()
{
offset = distanceMarker.transform.position - pointer.transform.position;
}
// Update is called once per frame
void Update()
{
float minX = pointer.GetPixelAdjustedRect().width / 2;
float maxX = Screen.width - minX;
float minY = pointer.GetPixelAdjustedRect().height / 2;
float maxY = Screen.height - minY;
Vector2 pos = Camera.main.WorldToScreenPoint(target.position);
if (Vector3.Dot(target.position - Camera.main.transform.position, Camera.main.transform.forward) < 0)
{
//target is behind player
if(pos.x < Screen.width / 2)
{
pos.x = maxX;
}
else
{
pos.x = minX;
}
}
pos.x = Mathf.Clamp(pos.x, minX, maxX);
pos.y = Mathf.Clamp(pos.y, minY, maxY);
pointer.transform.position = pos;
distanceMarker.text = Mathf.RoundToInt(Vector3.Distance(Camera.main.transform.position, target.transform.position)).ToString() + " meters";
if (pos.x < Screen.width / 2)
{
distanceMarker.transform.position = pos + offset;
}
else
{
distanceMarker.transform.position = pos - offset;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 90cdebe649c6da74c91cb78e89dda81d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: