game init

This commit is contained in:
2025-11-07 01:59:46 -08:00
parent a58defe364
commit 07f7eb1e2c
333 changed files with 88805 additions and 3 deletions

View File

@@ -0,0 +1,102 @@
using Unity.Cinemachine;
using UnityEngine;
using UnityEngine.UI;
public class CompassPointer : MonoBehaviour
{
public Transform playerTransform;
public bool rotateCompass;
public bool realisticCompass;
public bool opposite;
public Toggle compass;
public bool brainController;
public bool wasRotating;
public GameObject cinBrain;
void Start()
{
}
void Update()
{
rotateCompass = compass.isOn;
if (rotateCompass)
{
if (realisticCompass)
{
Vector3 northDirection = Vector3.forward;
Vector3 compassForward = playerTransform.forward;
compassForward.y = 0;
float angle = Vector3.SignedAngle(compassForward, northDirection, Vector3.up);
transform.localRotation = Quaternion.Euler(0, angle, 0);
}
else
{
Vector3 northDirection = Vector3.forward;
Vector3 compassForward = playerTransform.forward;
compassForward.y = 0;
float angle = Vector3.SignedAngle(northDirection, compassForward, Vector3.up);
transform.localRotation = Quaternion.Euler(0, angle, 0);
}
if (opposite)
{
if (!realisticCompass)
{
Vector3 northDirection = Vector3.forward;
Vector3 compassForward = playerTransform.forward;
compassForward.y = 0;
float angle = Vector3.SignedAngle(compassForward, northDirection, Vector3.up);
transform.localRotation = Quaternion.Euler(0, angle, 0);
}
else
{
Vector3 northDirection = Vector3.forward;
Vector3 compassForward = playerTransform.forward;
compassForward.y = 0;
float angle = Vector3.SignedAngle(northDirection, compassForward, Vector3.up);
transform.localRotation = Quaternion.Euler(0, angle, 0);
}
}
}
else if (!rotateCompass)
{
Vector3 northDirection = Vector3.forward;
Vector3 compassForward = playerTransform.forward;
compassForward.y = 0;
float angle = Vector3.SignedAngle(northDirection, northDirection, Vector3.up);
transform.localRotation = Quaternion.Euler(0, angle, 0);
}
if (brainController)
{
if (rotateCompass)
{
if (wasRotating)
{
//cinBrain.SetActive(false);
//cinBrain.transform.rotation = Quaternion.Euler(90, 0, 0);
cinBrain.GetComponent<CinemachineRotateWithFollowTarget>().enabled = rotateCompass;
//cinBrain.SetActive(true);
wasRotating = false;
}
}
else if (!rotateCompass)
{
if (!wasRotating)
{
cinBrain.SetActive(false);
cinBrain.transform.rotation = Quaternion.Euler(90, 0, 0);
cinBrain.GetComponent<CinemachineRotateWithFollowTarget>().enabled = rotateCompass;
cinBrain.SetActive(true);
wasRotating = true;
}
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 65ef68387275a3e46b7e5752f865b7c8

View File

@@ -0,0 +1,15 @@
using UnityEngine;
using UnityEngine.SceneManagement;
public class CreditScreenButton : MonoBehaviour
{
public void Close()
{
SceneManager.LoadScene(0);
}
public void Website()
{
Application.OpenURL("https://wiiirhung.com");
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ed082983e8988a54698b8677764580e6

View File

@@ -0,0 +1,36 @@
using UnityEngine;
using UnityEngine.Rendering;
public class FogDisabler : MonoBehaviour
{
private bool originalFogState;
void OnEnable()
{
RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;
RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
}
void OnDisable()
{
RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering;
RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
}
void OnBeginCameraRendering(ScriptableRenderContext context, Camera camera)
{
if (camera == this.GetComponent<Camera>())
{
originalFogState = RenderSettings.fog; // Store original state
RenderSettings.fog = false; // Disable fog for this camera
}
}
void OnEndCameraRendering(ScriptableRenderContext context, Camera camera)
{
if (camera == this.GetComponent<Camera>())
{
RenderSettings.fog = originalFogState; // Revert fog to original state
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e0cfce438623f6b489a70c20a15adc3d

View File

@@ -0,0 +1,61 @@
using UnityEngine;
using UnityEngine.AI;
public class InfectedEnemy : MonoBehaviour
{
public float hp;
public float hurtAmount;
public MeshRenderer MeshRenderer;
public Material def;
public Material hur;
public bool isInside;
private NavMeshAgent agent;
public Transform target;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
MeshRenderer = GetComponent<MeshRenderer>();
agent = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update()
{
agent.SetDestination(target.position);
if (hp < 0)
{
Destroy(gameObject);
}
if (!isInside && hp != 0)
MeshRenderer.material = def;
}
private void LateUpdate()
{
if (hp == 0)
hp -= 1;
isInside = false;
}
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Sword")
{
hp -= hurtAmount;
MeshRenderer.material = hur;
}
}
public void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == "Sword")
isInside = true;
}
public void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Sword" && hp != 0)
MeshRenderer.material = def;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 330739a9b5a09ed4aaec683246161b11

View File

@@ -0,0 +1,182 @@
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class IntroWagon : MonoBehaviour
{
public GameObject playerKeeper;
public GameObject player;
public GameObject playerCam;
public GameObject moveToPoint;
public float speed;
public GameObject visibleWagon;
public GameObject npcKeeper;
public GameObject npc;
float timer1;
float timer2;
float timer3;
public Image fadeInImg;
public float fadeInTimer = 1f;
private Quaternion previousSourceRotation;
private float yVelocity = 0.0f;
bool endDoDone;
public GameObject uiElement1;
public GameObject uiElement2;
public GameObject uiElement3;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
previousSourceRotation = transform.rotation;
}
IEnumerator FadeIn()
{
float timer = 0f;
Color currentColor = fadeInImg.color;
while (timer < fadeInTimer)
{
timer += Time.deltaTime;
float alpha = Mathf.Lerp(1f, 0f, timer / fadeInTimer);
currentColor.a = alpha;
fadeInImg.color = currentColor;
yield return null;
}
currentColor.a = 0f;
fadeInImg.color = currentColor;
fadeInImg.gameObject.SetActive(false);
}
// Update is called once per frame
void Update()
{
timer2 += Time.deltaTime;
if (timer2 > 1.1 && timer2 < 1.2)
{
StartCoroutine(FadeIn());
}
if (timer2 > 1.7 && timer2 < 1.8)
{
playerCam.GetComponent<PlayerCam>().canLook = true;
}
if (timer2 > 2.5 && timer2 < 2.6)
{
npc.gameObject.GetComponent<MouthOpenClose>().interacted = true;
npc.gameObject.GetComponent<MouthOpenClose>().prompt.SetActive(false);
npc.gameObject.GetComponent<MouthOpenClose>().text.SetActive(true);
npc.gameObject.GetComponent<MouthOpenClose>().text.GetComponent<TextMeshProUGUI>().text = npc.gameObject.GetComponent<MouthOpenClose>().whatToSay;
npc.gameObject.GetComponent<MouthOpenClose>().timerDeactivate = npc.gameObject.GetComponent<MouthOpenClose>().initialTimerDeactivate;
}
if (moveToPoint == null && GameObject.FindGameObjectsWithTag("WagonPoint").Length > 0)
{
var allPoints = GameObject.FindGameObjectsWithTag("WagonPoint");
var pos = transform.position;
float dist = float.PositiveInfinity;
GameObject nearest = null;
foreach (var point in allPoints)
{
var distprev = (point.transform.position - pos).sqrMagnitude;
if (distprev < dist)
{
nearest = point;
dist = distprev;
}
}
moveToPoint = nearest;
}
else if (GameObject.FindGameObjectsWithTag("WagonPoint").Length == 0)
{
moveToPoint = this.gameObject;
visibleWagon.gameObject.GetComponent<itemBob>().enabled = false;
}
if (GameObject.FindGameObjectsWithTag("WagonPoint").Length > 0)
{
Quaternion targetRotation = Quaternion.LookRotation(moveToPoint.transform.position - transform.position);
Vector3 currentEuler = transform.rotation.eulerAngles;
float targetYAngle = targetRotation.eulerAngles.y;
currentEuler.y = Mathf.SmoothDampAngle(currentEuler.y, targetYAngle, ref yVelocity, .7f);
transform.rotation = Quaternion.Euler(currentEuler);
transform.position += transform.forward * 2.25f * Time.deltaTime;
player.transform.position = Vector3.MoveTowards(player.transform.position, playerKeeper.transform.position, Mathf.Infinity * Time.deltaTime);
npc.transform.position = Vector3.MoveTowards(npc.transform.position, npcKeeper.transform.position, Mathf.Infinity * Time.deltaTime);
npc.transform.rotation = npcKeeper.transform.rotation;
player.GetComponent<PlayerMovement>().energy = 0;
player.GetComponent<PlayerMovement>().HP = 10;
if (npc.GetComponent<MouthOpenClose>().interacted == false && npc.GetComponent<MouthOpenClose>().whatToSay == "Hey, you. You're finally awake." && timer2 > 2.6)
{
timer3 += Time.deltaTime;
if (timer3 > .8 && timer3 < .9)
{
npc.GetComponent<MouthOpenClose>().whatToSay = "You had me scared for a moment there!";
npc.gameObject.GetComponent<MouthOpenClose>().interacted = true;
npc.gameObject.GetComponent<MouthOpenClose>().prompt.SetActive(false);
npc.gameObject.GetComponent<MouthOpenClose>().text.SetActive(true);
npc.gameObject.GetComponent<MouthOpenClose>().text.GetComponent<TextMeshProUGUI>().text = npc.gameObject.GetComponent<MouthOpenClose>().whatToSay;
npc.gameObject.GetComponent<MouthOpenClose>().timerDeactivate = npc.gameObject.GetComponent<MouthOpenClose>().initialTimerDeactivate;
}
}
}
else
{
npc.GetComponent<MouthOpenClose>().whatToSay = "Go on ahead, I'll catch up later.";
if (timer1 < .7)
{
player.transform.position = Vector3.MoveTowards(player.transform.position, playerKeeper.transform.position, Mathf.Infinity * Time.deltaTime);
}
timer1 += Time.deltaTime;
visibleWagon.GetComponent<BoxCollider>().enabled = true;
if (timer1 < 1.5)
{
player.GetComponent<PlayerMovement>().energy = 0;
}
}
}
private void LateUpdate()
{
if (GameObject.FindGameObjectsWithTag("WagonPoint").Length > 0)
{
if (Vector3.Distance(npc.transform.position, player.transform.position) < 5)
{
npc.gameObject.GetComponent<MouthOpenClose>().prompt.SetActive(false);
}
uiElement1.SetActive(false);
uiElement2.SetActive(false);
uiElement3.SetActive(false);
}
if (GameObject.FindGameObjectsWithTag("WagonPoint").Length == 0 && !endDoDone && timer1 > 1.1)
{
uiElement1.SetActive(true);
uiElement2.SetActive(true);
uiElement3.SetActive(true);
endDoDone = true;
}
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "WagonPoint")
{
Destroy(other.gameObject);
moveToPoint = null;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: dc63b26a5b4ca2746b2167fce8b14a90

View File

@@ -0,0 +1,193 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEditor;
public class MenuControls : MonoBehaviour
{
public TMP_Dropdown resSelect;
public Toggle fsToggle;
public Toggle compassRealistic;
Resolution[] resolutions;
bool isFullscreen;
int selectedResolution;
List<Resolution> selectedResolutionList = new List<Resolution>();
public Slider frSlider;
public TextMeshProUGUI frAmount;
public Slider Sensitivity;
public TextMeshProUGUI SensitvityShow;
public GameObject Sens;
public Canvas mainCanvas;
public Canvas settingsCanvas;
public Canvas creditsCanvas;
void Start()
{
Time.timeScale = 1;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
if (Application.targetFrameRate == -1 || Application.targetFrameRate > 240)
{
frSlider.value = 241;
}
else
{
frSlider.value = Application.targetFrameRate;
}
if (frSlider.value > 240)
{
frAmount.text = "FPS Limit: None";
Application.targetFrameRate = -1;
}
else
{
frAmount.text = "FPS Limit: " + frSlider.value.ToString();
Application.targetFrameRate = (int)frSlider.value;
}
if (GameObject.FindGameObjectsWithTag("Sens").Length == 0)
{
Instantiate<GameObject>(Sens);
Sensitivity.value = 1.75558f;//GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().cameraSens;
}
else
{
Sensitivity.value = GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().cameraSens;
compassRealistic.isOn = GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().compass;
}
if (GameObject.FindGameObjectsWithTag("Sens").Length != 0)
{
GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().cameraSens = Sensitivity.value;
GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().compass = compassRealistic.isOn;
var percent = ((Sensitivity.value - 0.5f) / (3f - 0.5f)) * 100;
SensitvityShow.text = "Sensitivity: " + ((int)percent).ToString();
}
isFullscreen = Screen.fullScreen;
resolutions = Screen.resolutions;
List<string> resolutionList = new List<string>();
string newRes;
foreach (Resolution res in resolutions)
{
newRes = res.width.ToString() + " x " + res.height.ToString();
if (!resolutionList.Contains(newRes))
{
resolutionList.Add(newRes);
selectedResolutionList.Add(res);
}
}
resSelect.AddOptions(resolutionList);
}
public void ChangeResolution()
{
selectedResolution = resSelect.value;
Screen.SetResolution(selectedResolutionList[selectedResolution].width, selectedResolutionList[selectedResolution].height, isFullscreen);
}
public void ChangeFullScreen()
{
isFullscreen = fsToggle.isOn;
Screen.SetResolution(selectedResolutionList[selectedResolution].width, selectedResolutionList[selectedResolution].height, isFullscreen);
}
public void ChangeFramerate()
{
if (frSlider.value > 240)
{
frAmount.text = "FPS Limit: None";
Application.targetFrameRate = -1;
}
else
{
frAmount.text = "FPS Limit: " + frSlider.value.ToString();
Application.targetFrameRate = (int)frSlider.value;
}
}
public void ChangeSensitivity()
{
if (GameObject.FindGameObjectsWithTag("Sens").Length != 0)
{
GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().cameraSens = Sensitivity.value;
var percent = ((Sensitivity.value - 0.5f) / (3f - 0.5f)) * 100;
SensitvityShow.text = "Sensitivity: " + ((int)percent).ToString();
}
}
public void ChangeCompass()
{
if (GameObject.FindGameObjectsWithTag("Sens").Length != 0)
{
GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().compass = compassRealistic.isOn;
}
}
public void PlayGame()
{
SceneManager.LoadScene(1);
}
public void QuitGame()
{
Application.Quit();
}
public void OpenSettings()
{
mainCanvas.enabled = false;
settingsCanvas.enabled = true;
}
public void CloseSettings()
{
settingsCanvas.enabled = false;
mainCanvas.enabled = true;
}
public void OpenCredits()
{
mainCanvas.enabled = false;
creditsCanvas.enabled = true;
}
public void CloseCredits()
{
creditsCanvas.enabled = false;
mainCanvas.enabled = true;
}
public void Website()
{
Application.OpenURL("https://wiiirhung.com");
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 744f11095ee32da46b7af4bdb345545f

View File

@@ -0,0 +1,129 @@
using TMPro;
using UnityEngine;
public class MouthOpenClose : MonoBehaviour
{
public bool npcAwakener;
public GameObject awakenerHead;
public Material openMouth;
public Material closeMouth;
public Material closedMouth;
public GameObject npc;
public GameObject player;
public GameObject prompt;
public GameObject text;
public bool interacted;
public bool entered;
public Animator animator;
public float timer;
public float timerDeactivate;
public float initialTimer;
public float initialTimerDeactivate;
public bool isClosed;
public string whatToSay;
private void Start()
{
player = GameObject.Find("Player");
npc.GetComponent<SkinnedMeshRenderer>().material = closedMouth;
isClosed = true;
timer = initialTimer;
}
void Update()
{
if (Vector3.Distance(transform.position, player.transform.position) < 5)
{
if (!npcAwakener)
{
animator.SetBool("playerNear", true);
Vector3 targetDirection = new Vector3(player.transform.position.x, transform.position.y, player.transform.position.z) - transform.position;
Vector3 newDirection = Vector3.RotateTowards(transform.forward, targetDirection, 3 * Time.deltaTime, 0);
transform.rotation = Quaternion.LookRotation(newDirection);
}
else
{
Vector3 targetDirection = new Vector3(player.transform.position.x, awakenerHead.transform.position.y, player.transform.position.z) - awakenerHead.transform.position;
Vector3 newDirection = Vector3.RotateTowards(awakenerHead.transform.forward, targetDirection, 3 * Time.deltaTime, 0);
awakenerHead.transform.rotation = Quaternion.LookRotation(newDirection);
}
}
else animator.SetBool("playerNear", false);
if (Vector3.Distance(transform.position, player.transform.position) < 3)
{
if (!interacted)
{
entered = true;
prompt.SetActive(true);
if (Input.GetKeyDown(KeyCode.E))
{
interacted = true;
prompt.SetActive(false);
text.SetActive(true);
text.GetComponent<TextMeshProUGUI>().text = whatToSay;
timerDeactivate = initialTimerDeactivate;
}
}
else
{
}
}
else
{
if (!text.activeSelf)
interacted = false;
if (entered)
{
entered = false;
prompt.SetActive(false);
}
//text.SetActive(false);
}
if (text.activeSelf && interacted)
{
timer -= Time.deltaTime;
if (timer <= 0)
{
timer = initialTimer;
if (isClosed)
{
npc.GetComponent<SkinnedMeshRenderer>().material = openMouth;
isClosed = false;
}
else
{
npc.GetComponent<SkinnedMeshRenderer>().material = closeMouth;
isClosed = true;
}
}
timerDeactivate -= Time.deltaTime;
if (timerDeactivate <= 0)
{
text.SetActive(false);
interacted = false;
}
}
else
{
npc.GetComponent<SkinnedMeshRenderer>().material = closedMouth;
isClosed = true;
}
if (text.GetComponent<TextMeshProUGUI>().text != whatToSay) interacted = false;
if (Input.GetKeyDown(KeyCode.C))
{
text.SetActive(false);
interacted = false;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f31d3ff8d72de4d4a839ab68347e5767

View File

@@ -0,0 +1,174 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEditor;
public class PauseMenuControls : MonoBehaviour
{
public TMP_Dropdown resSelect;
public Toggle fsToggle;
public Toggle compassRealistic;
Resolution[] resolutions;
bool isFullscreen;
int selectedResolution;
List<Resolution> selectedResolutionList = new List<Resolution>();
public Slider frSlider;
public TextMeshProUGUI frAmount;
public Slider Sensitivity;
public TextMeshProUGUI SensitvityShow;
public GameObject Sens;
public Canvas mainCanvas;
public Canvas pauseCanvas;
public Canvas settingsCanvas;
void Start()
{
if (Application.targetFrameRate == -1 || Application.targetFrameRate > 240)
{
frSlider.value = 241;
}
else
{
frSlider.value = Application.targetFrameRate;
}
if (frSlider.value > 240)
{
frAmount.text = "FPS Limit: None";
Application.targetFrameRate = -1;
}
else
{
frAmount.text = "FPS Limit: " + frSlider.value.ToString();
Application.targetFrameRate = (int)frSlider.value;
}
if (GameObject.FindGameObjectsWithTag("Sens").Length == 0)
{
Instantiate<GameObject>(Sens);
Sensitivity.value = 1.75558f;//GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().cameraSens;
}
else
{
Sensitivity.value = GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().cameraSens;
compassRealistic.isOn = GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().compass;
}
if (GameObject.FindGameObjectsWithTag("Sens").Length != 0)
{
GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().cameraSens = Sensitivity.value;
GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().compass = compassRealistic.isOn;
var percent = ((Sensitivity.value - 0.5f) / (3f - 0.5f)) * 100;
SensitvityShow.text = "Sensitivity: " + ((int)percent).ToString();
}
isFullscreen = Screen.fullScreen;
resolutions = Screen.resolutions;
List<string> resolutionList = new List<string>();
string newRes;
foreach (Resolution res in resolutions)
{
newRes = res.width.ToString() + " x " + res.height.ToString();
if (!resolutionList.Contains(newRes))
{
resolutionList.Add(newRes);
selectedResolutionList.Add(res);
}
}
resSelect.AddOptions(resolutionList);
}
public void ChangeResolution()
{
selectedResolution = resSelect.value;
Screen.SetResolution(selectedResolutionList[selectedResolution].width, selectedResolutionList[selectedResolution].height, isFullscreen);
}
public void ChangeFullScreen()
{
isFullscreen = fsToggle.isOn;
Screen.SetResolution(selectedResolutionList[selectedResolution].width, selectedResolutionList[selectedResolution].height, isFullscreen);
}
public void ChangeFramerate()
{
if (frSlider.value > 240)
{
frAmount.text = "FPS Limit: None";
Application.targetFrameRate = -1;
}
else
{
frAmount.text = "FPS Limit: " + frSlider.value.ToString();
Application.targetFrameRate = (int)frSlider.value;
}
}
public void ChangeSensitivity()
{
if (GameObject.FindGameObjectsWithTag("Sens").Length != 0)
{
GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().cameraSens = Sensitivity.value;
var percent = ((Sensitivity.value - 0.5f) / (3f - 0.5f)) * 100;
SensitvityShow.text = "Sensitivity: " + ((int)percent).ToString();
}
}
public void ChangeCompass()
{
if (GameObject.FindGameObjectsWithTag("Sens").Length != 0)
{
GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().compass = compassRealistic.isOn;
}
}
public void ResumeGame()
{
mainCanvas.enabled = true;
pauseCanvas.enabled = false;
settingsCanvas.enabled = false;
Time.timeScale = 1;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
public void QuitGame()
{
SceneManager.LoadScene(0);
}
public void OpenSettings()
{
pauseCanvas.enabled = false;
settingsCanvas.enabled = true;
}
public void CloseSettings()
{
settingsCanvas.enabled = false;
pauseCanvas.enabled = true;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f6cf1b200c9c7e943a6e1a518cc960b4

View File

@@ -0,0 +1,70 @@
using UnityEngine;
using UnityEngine.UI;
public class PlayerCam : MonoBehaviour
{
float sens;
public Transform orientation;
float xRotation;
float yRotation;
float mouseX;
float mouseY;
public Transform wagonRot;
private Quaternion previousSourceRotation;
public bool canLook;
public Slider Sensitivity;
private void Awake()
{
//if (GameObject.FindGameObjectsWithTag("Sens").Length != 0)
// sens = GameObject.FindGameObjectWithTag("Sens").GetComponent<SensitivityValue>().cameraSens;
//else
// sens = 1.75558f;
}
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
previousSourceRotation = wagonRot.rotation;
yRotation += 90;
xRotation += 20;
}
// Update is called once per frame
void Update()
{
if (Time.timeScale == 1)
{
if (wagonRot != null && GameObject.FindGameObjectsWithTag("WagonPoint").Length > 0)
{
Quaternion rotationDelta = wagonRot.rotation * Quaternion.Inverse(previousSourceRotation);
transform.rotation *= rotationDelta;
previousSourceRotation = wagonRot.rotation;
Vector3 deltaEuler = rotationDelta.eulerAngles;
yRotation += deltaEuler.y;
}
sens = Sensitivity.value;
if (canLook)
{
mouseX = Input.GetAxis("Mouse X") * sens;
mouseY = Input.GetAxis("Mouse Y") * sens;
}
yRotation += mouseX;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -87f, 87f);
transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
orientation.rotation = Quaternion.Euler(0, yRotation, 0);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5e17a974d7d0e5443922bb32c1f9e012

View File

@@ -0,0 +1,433 @@
using TMPro;
using Unity.Cinemachine;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed;
public float moveSpeedMultiplier;
public LayerMask whatIsGround;
public bool grounded;
public Collider groundedCollider;
public float airMultiplier;
public bool airCollided;
public bool groundCollided;
public float maxSlopeAngle;
private RaycastHit slopeHit;
private bool exitingSlope;
public Transform orientation;
public Transform cameraor;
public GameObject cinemachineCam;
float horizontalInput;
float verticalInput;
public GameObject sword;
public Transform swordSpawnPoint;
public Transform swordSpawnPoint2;
public Transform swordSpawnPoint3;
public int lastSwing;
public float timeSinceLastSwing;
public bool holdSwing;
public float holdSwingTimer;
public float dashDistanceTimer, dashDistance, dashDuration;
public Collider myCollider;
public LayerMask excludeEnemy;
public float HP = 10;
public float energy = 100;
public float swungTimer;
public bool swung;
public Slider energySlider;
public GameObject energyObj;
float energyObjTimer;
public GameObject energyFill;
Vector3 moveDirection;
Rigidbody rb;
public PhysicsMaterial walkingPhysics;
public PhysicsMaterial standingPhysics;
public PhysicsMaterial airColliding;
public GameObject particle1;
public GameObject particle2;
public VolumeProfile volumeProfile;
public RectTransform healthUI;
bool jumped;
bool jumping;
public GameObject uiController;
void Start()
{
cinemachineCam = GameObject.Find("CinemachineCamera");
rb = GetComponent<Rigidbody>();
rb.freezeRotation = true;
}
void Update()
{
MyInput();
SpeedControl();
if (energy == 100)
{
energyObjTimer += Time.deltaTime;
if (energyObjTimer > .4)
{
energyObj.SetActive(false);
}
}
else
{
energyObjTimer = 0;
energyObj.SetActive(true);
}
}
void FixedUpdate()
{
MovePlayer();
}
private void MyInput()
{
if (Input.GetKeyDown(KeyCode.Alpha7))
{
HP -= 1;
}
if (Input.GetKeyDown(KeyCode.Alpha8))
{
HP -= .5f;
}
if (Input.GetKey(KeyCode.Alpha9))
{
HP -= Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.Alpha6))
{
HP = 10;
}
if (Input.GetKeyDown(KeyCode.Escape))
{
if (Time.timeScale == 1)
{
uiController.GetComponent<PauseMenuControls>().mainCanvas.enabled = false;
uiController.GetComponent<PauseMenuControls>().pauseCanvas.enabled = true;
Time.timeScale = 0;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
uiController.GetComponent<PauseMenuControls>().mainCanvas.enabled = true;
uiController.GetComponent<PauseMenuControls>().pauseCanvas.enabled = false;
uiController.GetComponent<PauseMenuControls>().settingsCanvas.enabled = false;
Time.timeScale = 1;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
horizontalInput = Input.GetAxisRaw("Horizontal");
verticalInput = Input.GetAxisRaw("Vertical");
if (horizontalInput == 0 && verticalInput == 0 && grounded && !Input.GetKeyDown(KeyCode.Space))
{
rb.linearDamping = 7;
GetComponent<CapsuleCollider>().material = standingPhysics;
}
else if (horizontalInput != 0 || verticalInput != 0 || !grounded || Input.GetKeyDown(KeyCode.Space))
{
rb.linearDamping = 0;
GetComponent<CapsuleCollider>().material = walkingPhysics;
}
if (Input.GetKeyDown(KeyCode.Space) && grounded)
{
rb.linearDamping = 0;
GetComponent<CapsuleCollider>().material = walkingPhysics;
jumped = true;
jumping = true;
}
if (jumped)
{
rb.linearDamping = 0;
GetComponent<CapsuleCollider>().material = walkingPhysics;
if (jumping)
{
rb.AddForce(Vector3.up * 6, ForceMode.Impulse);
jumping = false;
}
}
if (airCollided && !grounded)
{
rb.linearDamping = 0;
GetComponent<CapsuleCollider>().material = airColliding;
//rb.AddForce(Vector3.down * 1, ForceMode.Force);
Debug.Log("ng, hs");
}
if (Time.timeScale == 1)
{
timeSinceLastSwing += Time.deltaTime;
if (timeSinceLastSwing > .5f)
lastSwing = 0;
holdSwingTimer += Time.deltaTime;
if (holdSwing && holdSwingTimer > .15f)
holdSwing = false;
else if (holdSwing && GameObject.FindGameObjectsWithTag("Sword").Length < 1)
{
holdSwing = false;
if (energy > 7)
SwingSword();
}
if (!holdSwing)
holdSwingTimer = 0;
if (swung)
{
swungTimer += Time.deltaTime;
}
if (swungTimer > 1f)
swung = false;
if (!swung)
{
swungTimer = 0;
energy += 70 * Time.deltaTime;
}
if (energy < 0)
energy = 0;
if (energy > 100)
energy = 100;
energySlider.value = energy;
healthUI.sizeDelta = new Vector2((Mathf.Ceil(HP)-1) + (9 * HP), healthUI.sizeDelta.y);
if (Input.GetMouseButtonDown(0))
{
if (GameObject.FindGameObjectsWithTag("Sword").Length < 1)
{
if (energy > 7)
SwingSword();
}
else
{
swung = true;
swungTimer = 0;
holdSwingTimer = 0;
holdSwing = true;
}
}
if (Input.GetMouseButton(0))
{
swung = true;
swungTimer = 0;
timeSinceLastSwing = 0;
energy -= 20 * Time.deltaTime;
dashDistanceTimer += Time.deltaTime;
if (dashDistanceTimer > 1)
energyFill.GetComponent<Image>().color = Color.deepPink;
if (energy <= 0)
{
if (dashDistanceTimer > 1)
{
dashDistance = Mathf.Floor(dashDistanceTimer * 8);
dashDuration = 15;
}
dashDistanceTimer = 0;
}
}
//if (!Input.GetMouseButton(0))
//energyFill.GetComponent<Image>().color = new Color(196, 3, 0, 255);
if (Input.GetMouseButtonUp(0))
{
energyFill.GetComponent<Image>().color = Color.darkRed;
if (dashDistanceTimer > 1)
{
dashDistance = Mathf.Floor(dashDistanceTimer * 8);
dashDuration = 15;
}
dashDistanceTimer = 0;
}
}
}
private void LateUpdate()
{
}
private void SwingSword()
{
swung = true;
swungTimer = 0;
energy -= 7;
if (lastSwing == 0 || lastSwing == 3)
{
GameObject newSword = Instantiate(sword, swordSpawnPoint);
lastSwing = 1;
timeSinceLastSwing = 0;
}
else if (lastSwing == 1)
{
GameObject newSword = Instantiate(sword, swordSpawnPoint2);
lastSwing = 2;
timeSinceLastSwing = 0;
}
else if (lastSwing == 2)
{
GameObject newSword = Instantiate(sword, swordSpawnPoint3);
lastSwing = 3;
timeSinceLastSwing = 0;
}
}
private void MovePlayer()
{
moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;
if (grounded)
rb.AddForce(moveDirection.normalized * moveSpeed * moveSpeedMultiplier * 3, ForceMode.Force);
else if (!grounded)
rb.AddForce(moveDirection.normalized * moveSpeed * moveSpeedMultiplier * airMultiplier, ForceMode.Force);
if (rb.linearVelocity.y < -1)
{
rb.AddForce(transform.up * -5, ForceMode.Force);
}
if (dashDuration > 0)
{
SwordDash();
dashDuration--;
}
if (dashDuration == 1)
{
rb.linearVelocity = Vector3.zero;
dashDuration--;
}
}
private void SwordDash()
{
myCollider.excludeLayers = excludeEnemy;
rb.AddForce(Camera.main.transform.forward * dashDistance, ForceMode.Impulse);
swung = true;
swungTimer = 0;
timeSinceLastSwing = 0;
}
private void SpeedControl()
{
{
Vector3 flatVel = new Vector3(rb.linearVelocity.x, 0f, rb.linearVelocity.z);
if (flatVel.magnitude > moveSpeed)
{
Vector3 limitedVel = flatVel.normalized * moveSpeed;
rb.linearVelocity = new Vector3(limitedVel.x, rb.linearVelocity.y, limitedVel.z);
}
}
}
private bool OnSlope()
{
if (Physics.Raycast(transform.position, Vector3.down, out slopeHit, 2 * 0.5f + 0.3f))
{
float angle = Vector3.Angle(Vector3.up, slopeHit.normal);
return angle < maxSlopeAngle && angle != 0;
}
return false;
}
private Vector3 GetSlopeDirection()
{
return Vector3.ProjectOnPlane(moveDirection, slopeHit.normal).normalized;
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Enemy")
{
HP--;
}
if (!other.isTrigger/* && other.gameObject.tag == "Ground"*/)
{
grounded = true;
if (jumped)
jumped = false;
}
}
private void OnTriggerStay(Collider other)
{
if (!other.isTrigger/* && other.gameObject.tag == "Ground"*/)
{
grounded = true;
}
}
private void OnTriggerExit(Collider other)
{
if (!other.isTrigger/* && other.gameObject.tag == "Ground"*/)
{
grounded = false;
}
}
private void OnCollisionEnter(Collision collision)
{
if (!grounded)
{
}
}
private void OnCollisionStay(Collision collision)
{
if (!grounded)
{
airCollided = true;
}
}
private void OnCollisionExit(Collision collision)
{
if (!grounded)
{
airCollided = false;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 37494bcaed8719f4bad2c63c305bc58c

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SensitivityValue : MonoBehaviour
{
public float cameraSens;
public bool compass;
void Start()
{
DontDestroyOnLoad(this.gameObject);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7e9e0cffbce012243a1290df70438789

View File

@@ -0,0 +1,28 @@
using System.Threading;
using UnityEngine;
public class SwordSlash : MonoBehaviour
{
public float timer1;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
timer1 -= Time.deltaTime;
if (timer1 <= 0)
{
Destroy(gameObject);
}
transform.Rotate(Vector3.right * 850 * Time.deltaTime, Space.Self);
}
//public void OnTriggerEnter(Collider other)
//{
// Debug.Log("hit");
//}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 789056675dc7b68439f36a72e0c451aa

View File

@@ -0,0 +1,62 @@
using System.Linq;
using UnityEngine;
public class TerrainTreeColider : MonoBehaviour
{
[SerializeField]
private Terrain terrain;
private void Reset()
{
terrain = GetComponent<Terrain>();
Extract();
}
[ContextMenu("Extract")]
public void Extract()
{
Collider[] colliders = terrain.GetComponentsInChildren<Collider>();
//Skip the first, since its the Terrain Collider
for (int i = 1; i < colliders.Length; i++)
{
//Delete all previously created colliders first
DestroyImmediate(colliders[i].gameObject);
}
for (int i = 0; i < terrain.terrainData.treePrototypes.Length; i++)
{
TreePrototype tree = terrain.terrainData.treePrototypes[i];
//Get all instances matching the prefab index
TreeInstance[] instances = terrain.terrainData.treeInstances.Where(x => x.prototypeIndex == i).ToArray();
for (int j = 0; j < instances.Length; j++)
{
//Un-normalize positions so they're in world-space
instances[j].position = Vector3.Scale(instances[j].position, terrain.terrainData.size);
instances[j].position += terrain.GetPosition();
//Fetch the collider from the prefab object parent
CapsuleCollider prefabCollider = tree.prefab.GetComponent<CapsuleCollider>();
if (!prefabCollider) continue;
GameObject obj = new GameObject();
obj.name = tree.prefab.name + j;
CapsuleCollider objCollider = obj.AddComponent<CapsuleCollider>();
objCollider.center = prefabCollider.center;
objCollider.height = prefabCollider.height;
objCollider.radius = prefabCollider.radius;
if (terrain.preserveTreePrototypeLayers) obj.layer = tree.prefab.layer;
else obj.layer = terrain.gameObject.layer;
obj.transform.position = instances[j].position;
obj.transform.parent = terrain.transform;
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 132f317f0462390469d96b783cea9abe

View File

@@ -0,0 +1,40 @@
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
public class asyncLoad : MonoBehaviour
{
public float timer = 3;
public bool go;
public bool go1;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
StartCoroutine(LoadScene());
}
private void Update()
{
if (go)
{
timer -= Time.deltaTime;
if (timer <= 0) go1 = true;
}
}
IEnumerator LoadScene()
{
AsyncOperation loadScene = SceneManager.LoadSceneAsync(1);
loadScene.allowSceneActivation = false;
while (!loadScene.isDone)
{
if (loadScene.progress >= 0.9f)
{
go = true;
if (go1) loadScene.allowSceneActivation=true;
}
yield return null;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ae7af5ad071235e4dae4ed07b7cfee71

56
Assets/Scripts/itemBob.cs Normal file
View File

@@ -0,0 +1,56 @@
using UnityEngine;
public class itemBob : MonoBehaviour
{
public float xFrequency;
public float xAmplitude;
public float yFrequency;
public float yAmplitude;
public float zFrequency;
public float zAmplitude;
public GameObject player;
public float vel;
public float vel2;
public bool swapped;
public bool wagon;
private Vector3 initialLocalPosition;
void Start()
{
initialLocalPosition = transform.localPosition;
}
void Update()
{
//Debug.Log(player.GetComponent<Rigidbody>().linearVelocity.magnitude);
vel = Mathf.Clamp(player.GetComponent<Rigidbody>().linearVelocity.magnitude, 0, 10);
if (wagon)
{
float offsetX = Mathf.Sin(Time.time * xFrequency) * xAmplitude * vel2;
float offsetY = Mathf.Sin(Time.time * yFrequency) * yAmplitude * vel2;
float offsetZ = Mathf.Sin(Time.time * zFrequency) * zAmplitude * vel2;
transform.localPosition = initialLocalPosition + new Vector3(offsetX, offsetY, offsetZ);
}
else if (swapped)
{
float offsetX = Mathf.Sin(Time.time * xFrequency*-1) * xAmplitude * vel;
float offsetY = Mathf.Sin(Time.time * yFrequency*-1) * yAmplitude * vel;
float offsetZ = Mathf.Sin(Time.time * zFrequency*-1) * zAmplitude * vel;
transform.localPosition = initialLocalPosition + new Vector3(offsetX, offsetY, offsetZ);
}
else
{
float offsetX = Mathf.Sin(Time.time * xFrequency) * xAmplitude * vel;
float offsetY = Mathf.Sin(Time.time * yFrequency) * yAmplitude * vel;
float offsetZ = Mathf.Sin(Time.time * zFrequency) * zAmplitude * vel;
transform.localPosition = initialLocalPosition + new Vector3(offsetX, offsetY, offsetZ);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0033ea7283aaa8f4c9921e483d1271c1

View File

@@ -0,0 +1,16 @@
using UnityEngine;
public class treeFadeOut : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5ec0c33ae1a35054eae7d1c043a6833c