This commit is contained in:
2022-09-07 20:19:22 +03:00
parent 2265202f59
commit 1e05c48ca6
15 changed files with 542 additions and 418 deletions

29
Assets/scripts/Timer.cs Normal file
View File

@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Timer : MonoBehaviour
{
// Start is called before the first frame update
public float StartFromTime = 0;
public bool IsCountdown = false;
public float Speed = 1;
float currentTime;
void Start()
{
if (StartFromTime != 0)
currentTime = StartFromTime;
}
// Update is called once per frame
void Update()
{
currentTime += IsCountdown ? -Time.deltaTime : Time.deltaTime;
currentTime = (float)System.Math.Round(currentTime, 2);
GetComponent<Text>().text = currentTime.ToString();
}
}

View File

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

View File

@@ -6,32 +6,29 @@ using UnityEngine.UI;
public class fireplace : MonoBehaviour
{
public Light bbb;
public Light firelight;
public float magnitude = 2;
public float timer = 0.5f;
private float time = 0;
public float dietime = 1;
public float AddFromStick = 0.3f;
public Slider Fuel;
private void Start()
{
//bbb = GetComponent<Light>();
}
private void OnDrawGizmos()
{
//StartCoroutine("bebra");
}
private void OnTriggerEnter(Collider other)
{
if(other.tag == "Player")
{
dietime += 0.3f * other.GetComponent<PlayerMovement>().stickCount;
dietime += AddFromStick * other.GetComponent<PlayerMovement>().stickCount;
other.GetComponent<PlayerMovement>().stickCount = 0;
}
}
@@ -42,8 +39,10 @@ public class fireplace : MonoBehaviour
dietime -= 0.001f;
time += Time.deltaTime * timer * Random.Range(1,4);
bbb.intensity = Mathf.Sin(time) * timer + 10 * dietime;
firelight.intensity = Mathf.Sin(time) * timer + 10 * dietime;
Fuel.value = dietime;
//Debug.Log(Fuel.value);
}
}

View File

@@ -9,21 +9,25 @@ public class CameraBob : MonoBehaviour
[Range(0, 30)] public float Frequency = 10;
public float YStrength = 1;
public float XStrength = 0.5f;
public Transform Camera;
public Transform CameraHolder;
public float ToggleSpeed = 3;
Vector3 StartPos;
CharacterController controller;
public bool IsRotating = false;
Vector3 StartPos;
Quaternion StartRot;
private void Update()
{
if (Enable)
{
CheckMotion();
ResetPosition();
CameraHolder.LookAt(FocusTarget());
if (!IsRotating)
{
ResetPosition();
CameraHolder.LookAt(FocusTarget());
}
}
}
@@ -31,6 +35,7 @@ public class CameraBob : MonoBehaviour
{
controller = GetComponent<CharacterController>();
StartPos = Camera.localPosition;
StartRot = Camera.localRotation;
}
void PlayMotion(Vector3 motion)
@@ -38,12 +43,21 @@ public class CameraBob : MonoBehaviour
Camera.localPosition += motion;
}
void PlayMotion(Quaternion motion)
{
Camera.localRotation *= motion;
}
void CheckMotion()
{
if (controller.GetComponent<PlayerMovement>().PlayerState != PlayerMovement.CurrentState.Walk) return;
if (!controller.isGrounded) return;
PlayMotion(FootStepMotion());
if (!IsRotating)
PlayMotion(FootStepMotion());
else
PlayMotion(FootStepRotation());
}
Vector3 FootStepMotion()
@@ -54,10 +68,25 @@ public class CameraBob : MonoBehaviour
return pos;
}
Quaternion FootStepRotation()
{
Quaternion pos = new Quaternion(0,0,0,0);
pos.y += Mathf.Sin(Time.time * Frequency) * Amplitude;
pos.x += Mathf.Cos(Time.time * Frequency / 2) * Amplitude * 2;
return pos;
}
void ResetPosition()
{
if (Camera.localPosition == StartPos) return;
Camera.localPosition = Vector3.Lerp(Camera.localPosition, StartPos, Time.deltaTime);
if (!IsRotating)
{
if (Camera.localPosition == StartPos) return;
Camera.localPosition = Vector3.Lerp(Camera.localPosition, StartPos, Time.deltaTime);
}
else
{
if (Camera.localRotation == StartRot) return;
}
}
Vector3 FocusTarget()
@@ -66,4 +95,6 @@ public class CameraBob : MonoBehaviour
pos += CameraHolder.forward * 15;
return pos;
}
}

View File

@@ -13,7 +13,7 @@ public class mainstick : MonoBehaviour
{
other.GetComponent<PlayerMovement>().stickCount += 1;
GameObject.Destroy(gameObject);
//Firething.dietime += 0.3f;
}
}
}