mirror of
https://github.com/celisej567/forest.git
synced 2026-09-21 20:15:21 +03:00
1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GameRules : MonoBehaviour
|
||||
{
|
||||
@@ -8,6 +9,20 @@ public class GameRules : MonoBehaviour
|
||||
[HideInInspector] public GameObject[] SticksInWorld;
|
||||
[HideInInspector] public GameObject[] stickSpawner;
|
||||
StickSpawner bebra;
|
||||
|
||||
public Fireplace fireplace;
|
||||
|
||||
[Space]
|
||||
public GameObject LoseImage;
|
||||
public Vector2 LoseImageStartScale;
|
||||
public Quaternion LoseImageStartRotation;
|
||||
|
||||
public bool LoseStarted = false;
|
||||
|
||||
|
||||
public Vector2 LoseImageStopScale;
|
||||
public Quaternion LoseImageStopRotation;
|
||||
|
||||
void Start()
|
||||
{
|
||||
stickSpawner = GameObject.FindGameObjectsWithTag("Spawner");
|
||||
@@ -16,10 +31,29 @@ public class GameRules : MonoBehaviour
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
//check if world have enough sticks
|
||||
SticksInWorld = GameObject.FindGameObjectsWithTag("stick");
|
||||
if (MaxLevelSticks > SticksInWorld.Length)
|
||||
{
|
||||
stickSpawner[Random.Range(0, stickSpawner.Length)].GetComponent<StickSpawner>().CreateStick();
|
||||
}
|
||||
}
|
||||
|
||||
//check if fireplace is die
|
||||
if(fireplace.dietime < 0)
|
||||
{
|
||||
if (!LoseStarted)
|
||||
{
|
||||
LoseStarted = true;
|
||||
LoseImage.SetActive(true);
|
||||
LoseImage.transform.localScale = LoseImageStartScale;
|
||||
LoseImage.transform.localRotation = LoseImageStartRotation;
|
||||
}
|
||||
}
|
||||
|
||||
if(LoseStarted)
|
||||
{
|
||||
LoseImage.transform.localScale = Vector2.Lerp(LoseImage.transform.localScale, LoseImageStopScale, Time.deltaTime);
|
||||
LoseImage.transform.localRotation = Quaternion.Lerp(LoseImage.transform.localRotation, LoseImageStopRotation, Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
public class fireplace : MonoBehaviour
|
||||
public class Fireplace : MonoBehaviour
|
||||
{
|
||||
public Light firelight;
|
||||
public float magnitude = 2;
|
||||
|
||||
@@ -15,8 +15,6 @@ public class CameraMovement : MonoBehaviour
|
||||
void Start()
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
@@ -35,6 +33,14 @@ public class CameraMovement : MonoBehaviour
|
||||
{
|
||||
if (Input.GetKeyUp(KeyCode.Escape))
|
||||
{
|
||||
GameRules gr = GameObject.FindObjectOfType<GameRules>();
|
||||
|
||||
if(gr.LoseStarted)
|
||||
{
|
||||
StartCoroutine("Restart");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pause)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Confined;
|
||||
@@ -50,19 +56,26 @@ public class CameraMovement : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable PauseGame()
|
||||
IEnumerator PauseGame()
|
||||
{
|
||||
SceneManager.LoadSceneAsync("pause", LoadSceneMode.Additive);
|
||||
Time.timeScale = 0;
|
||||
return null;
|
||||
}
|
||||
|
||||
IEnumerable UnPauseGame()
|
||||
IEnumerator UnPauseGame()
|
||||
{
|
||||
SceneManager.UnloadSceneAsync("pause");
|
||||
Time.timeScale = 1;
|
||||
return null;
|
||||
}
|
||||
|
||||
IEnumerator Restart()
|
||||
{
|
||||
SceneManager.UnloadSceneAsync("game");
|
||||
SceneManager.LoadSceneAsync("game");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
12
Assets/scripts/general/player/SpawnFuncs.cs
Normal file
12
Assets/scripts/general/player/SpawnFuncs.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SpawnFuncs : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
QualitySettings.SetQualityLevel(PlayerPrefs.GetInt("GraphicsLevel"));
|
||||
}
|
||||
}
|
||||
11
Assets/scripts/general/player/SpawnFuncs.cs.meta
Normal file
11
Assets/scripts/general/player/SpawnFuncs.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23b33987753308746b94905426f532e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,7 +5,7 @@ using UnityEngine.UI;
|
||||
|
||||
public class mainstick : MonoBehaviour
|
||||
{
|
||||
public fireplace Firething;
|
||||
public Fireplace Firething;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user