Initial commit

This commit is contained in:
2022-09-04 11:34:51 +03:00
commit 2265202f59
219 changed files with 69345 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameRules : MonoBehaviour
{
public int MaxLevelSticks;
[HideInInspector] public GameObject[] SticksInWorld;
[HideInInspector] public GameObject[] stickSpawner;
StickSpawner bebra;
void Start()
{
stickSpawner = GameObject.FindGameObjectsWithTag("Spawner");
}
private void FixedUpdate()
{
SticksInWorld = GameObject.FindGameObjectsWithTag("stick");
if (MaxLevelSticks > SticksInWorld.Length)
{
stickSpawner[Random.Range(0, stickSpawner.Length)].GetComponent<StickSpawner>().CreateStick();
}
}
}

View File

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

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StickSpawner : MonoBehaviour
{
public GameObject StickPrefab;
public void CreateStick()
{
GameObject.Instantiate(StickPrefab, transform);
}
}

View File

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

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class fireplace : MonoBehaviour
{
public Light bbb;
public float magnitude = 2;
public float timer = 0.5f;
private float time = 0;
public float dietime = 1;
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;
other.GetComponent<PlayerMovement>().stickCount = 0;
}
}
void FixedUpdate()
{
dietime -= 0.001f;
time += Time.deltaTime * timer * Random.Range(1,4);
bbb.intensity = Mathf.Sin(time) * timer + 10 * dietime;
Fuel.value = dietime;
//Debug.Log(Fuel.value);
}
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,69 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraBob : MonoBehaviour
{
public bool Enable = true;
[Range(0, 0.1f)] public float Amplitude = 0.015f;
[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;
private void Update()
{
if (Enable)
{
CheckMotion();
ResetPosition();
CameraHolder.LookAt(FocusTarget());
}
}
private void Awake()
{
controller = GetComponent<CharacterController>();
StartPos = Camera.localPosition;
}
void PlayMotion(Vector3 motion)
{
Camera.localPosition += motion;
}
void CheckMotion()
{
if (controller.GetComponent<PlayerMovement>().PlayerState != PlayerMovement.CurrentState.Walk) return;
if (!controller.isGrounded) return;
PlayMotion(FootStepMotion());
}
Vector3 FootStepMotion()
{
Vector3 pos = Vector3.zero;
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);
}
Vector3 FocusTarget()
{
Vector3 pos = new Vector3(transform.position.x, transform.position.y + CameraHolder.localPosition.y, transform.position.z);
pos += CameraHolder.forward * 15;
return pos;
}
}

View File

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

View File

@@ -0,0 +1,68 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class CameraMovement : MonoBehaviour
{
[Header("Main")]
public float MouseSens = 200f;
float xRot;
public GameObject PlayerBody;
public int MaxCameraAngle = 80;
bool pause = false;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
private void FixedUpdate()
{
float mouseX = Input.GetAxis("Mouse X") * MouseSens * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * MouseSens * Time.deltaTime;
xRot -= mouseY;
xRot = Mathf.Clamp(xRot, -MaxCameraAngle, MaxCameraAngle);
transform.localRotation = Quaternion.Euler(xRot, 0, 0);
PlayerBody.transform.Rotate(Vector3.up * mouseX);
}
private void Update()
{
if (Input.GetKeyUp(KeyCode.Escape))
{
if (!pause)
{
Cursor.lockState = CursorLockMode.Confined;
pause = true;
StartCoroutine("PauseGame");
}
else
{
Cursor.lockState = CursorLockMode.Locked;
pause = false;
StartCoroutine("UnPauseGame");
}
}
}
IEnumerator PauseGame()
{
SceneManager.LoadSceneAsync("pause", LoadSceneMode.Additive);
Time.timeScale = 0;
return null;
}
IEnumerator UnPauseGame()
{
SceneManager.UnloadSceneAsync("pause" );
Time.timeScale = 1;
return null;
}
}

View File

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

View File

@@ -0,0 +1,127 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerMovement : MonoBehaviour
{
CharacterController PlayerController;
public float PlayerWalkSpeed = 5;
public float PlayerRunSpeed = 7;
public float CrouchWalkSpeed = 2;
public GameObject PlayerCamera;
public GameObject CameraHolder;
Vector3 Velocity;
[HideInInspector] public CurrentState PlayerState;
public bool isCrouch;
public float CrouchHeight = 0.4f;
float StartCameraPos;
public float CrouchCameraHeight = 0.1f;
public int stickCount = 0;
public Text TextStickCount;
public enum CurrentState
{
Idle = 0,
Walk,
Run,
Crouch,
CrouchWalk
}
// Start is called before the first frame update
void Start()
{
PlayerController = GetComponent<CharacterController>();
StartCameraPos = PlayerCamera.transform.localPosition.y;
}
// Update is called once per frame
private void FixedUpdate()
{
float xAxies = Input.GetAxis("Horizontal");
float zAxies = Input.GetAxis("Vertical");
Vector3 move = transform.right * xAxies + transform.forward * zAxies;
if (isCrouch)
{
PlayerController.Move(move * CrouchWalkSpeed * Time.deltaTime);
}
else
{
PlayerController.Move(move * PlayerWalkSpeed * Time.deltaTime);
}
if(PlayerController.velocity.magnitude == 0)
{
if (!isCrouch)
{
PlayerState = CurrentState.Idle;
}
else
{
PlayerState = CurrentState.Crouch;
}
}
else
{
if (!isCrouch)
{
PlayerState = CurrentState.Walk;
}
else
{
PlayerState = CurrentState.CrouchWalk;
}
}
//Debug.Log(PlayerState);
if (!PlayerController.isGrounded)
{
Velocity = Physics.gravity + Physics.gravity;
PlayerController.Move(Physics.gravity * Time.deltaTime);
}
}
private void Update()
{
TextStickCount.text = stickCount.ToString();
if (Input.GetKeyDown(KeyCode.LeftShift))
{
if (isCrouch)
{
if (!Physics.Raycast(PlayerCamera.transform.position, Vector3.up, 1f))
{
PlayerCamera.transform.localPosition = new Vector3(0, StartCameraPos, 0);
PlayerController.height = 1.88f;
isCrouch = false;
PlayerState = CurrentState.Idle;
PlayerController.Move(Vector3.up * Time.deltaTime * 10);
//Debug.LogError("Now Not Crouch");
}
}
else
{
PlayerCamera.transform.localPosition = new Vector3(0, CrouchCameraHeight, 0);
PlayerController.height = CrouchHeight;
isCrouch = true;
PlayerState = CurrentState.Crouch;
//Debug.LogError("Now Crouch");
}
}
}
}

View File

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

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class mainstick : MonoBehaviour
{
public fireplace Firething;
private void OnTriggerEnter(Collider other)
{
if(other.tag == "Player")
{
other.GetComponent<PlayerMovement>().stickCount += 1;
GameObject.Destroy(gameObject);
//Firething.dietime += 0.3f;
}
}
}

View File

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

8
Assets/scripts/menu.meta Normal file
View File

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

View File

@@ -0,0 +1,83 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Rendering;
public class GraphicSlider : MonoBehaviour
{
int GLevel = 2;
public Text Handle;
public RenderPipelineAsset[] DetailLevel;
void Start()
{
if (PlayerPrefs.HasKey("GraphicsLevel"))
{
GLevel = PlayerPrefs.GetInt("GraphicsLevel");
GetComponent<Slider>().value = GLevel;
}
else
{
PlayerPrefs.SetInt("GraphicsLevel", 2);
}
GetComponent<Slider>().value = GLevel;
switch (GLevel)
{
case 0:
Handle.text = "low";
break;
case 1:
Handle.text = "medium";
break;
case 2:
Handle.text = "high";
break;
default:
break;
}
}
public void Changed()
{
GLevel = ((int)GetComponent<Slider>().value);
QualitySettings.SetQualityLevel(GLevel);
QualitySettings.renderPipeline = DetailLevel[GLevel];
Debug.Log(QualitySettings.renderPipeline.name);
PlayerPrefs.SetInt("GraphicsLevel", GLevel);
PlayerPrefs.Save();
switch (GLevel)
{
case 0:
Handle.text = "low";
break;
case 1:
Handle.text = "medium";
break;
case 2:
Handle.text = "high";
break;
default:
break;
}
}
}

View File

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

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class exit : MonoBehaviour
{
public void Exit()
{
Time.timeScale = 1;
Application.Quit();
}
}

View File

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

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class leave : MonoBehaviour
{
public string MenuName;
public void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>()
{
SceneManager.LoadScene(MenuName);
}
}

View File

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

View File

@@ -0,0 +1,18 @@
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
public class play : MonoBehaviour
{
public void Load()
{
StartCoroutine("load");
}
IEnumerable load()
{
SceneManager.LoadScene("game");
return null;
}
}

View File

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

View File

@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class settingsbutton : MonoBehaviour
{
public void Load()
{
Time.timeScale = 1;
StartCoroutine("load");
}
IEnumerable load()
{
SceneManager.LoadSceneAsync("settings");
return null;
}
}

View File

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