View distance settings
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@ public class Data
|
|||||||
{
|
{
|
||||||
public static int chunkWidth = 15, chunkHeight = 250;
|
public static int chunkWidth = 15, chunkHeight = 250;
|
||||||
public static int textureAtlasSize = 16;
|
public static int textureAtlasSize = 16;
|
||||||
public static int viewDistance = 9;
|
public static int viewDistance = 4;
|
||||||
|
|
||||||
public static readonly Vector3[] vertices =
|
public static readonly Vector3[] vertices =
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class Options : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private Text viewDistanceText;
|
||||||
|
[SerializeField] private Slider viewDistanceSlider;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
if (PlayerPrefs.HasKey("viewDistance"))
|
||||||
|
{
|
||||||
|
int value = PlayerPrefs.GetInt("viewDistance");
|
||||||
|
viewDistanceText.text = value.ToString();
|
||||||
|
viewDistanceSlider.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SliderViewDistanceChanged(float value)
|
||||||
|
{
|
||||||
|
viewDistanceText.text = ((int)value).ToString();
|
||||||
|
PlayerPrefs.SetInt("viewDistance", (int)value);
|
||||||
|
PlayerPrefs.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ab80d1e654833ae4f88450121509e895
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -24,6 +24,7 @@ public class World : MonoBehaviour
|
|||||||
[SerializeField] private Player player;
|
[SerializeField] private Player player;
|
||||||
[SerializeField] private GameObject deadScreen;
|
[SerializeField] private GameObject deadScreen;
|
||||||
[SerializeField] private GameObject pauseScreen;
|
[SerializeField] private GameObject pauseScreen;
|
||||||
|
[SerializeField] private GameObject optionsScreen;
|
||||||
private ChunkCoord lastPlayerChunkCoord = new ChunkCoord(0, 0);
|
private ChunkCoord lastPlayerChunkCoord = new ChunkCoord(0, 0);
|
||||||
|
|
||||||
//chunks
|
//chunks
|
||||||
@@ -124,6 +125,8 @@ public class World : MonoBehaviour
|
|||||||
{
|
{
|
||||||
List<Chunk> checkList = new List<Chunk>();
|
List<Chunk> checkList = new List<Chunk>();
|
||||||
|
|
||||||
|
chunksToUpdate.Clear();
|
||||||
|
|
||||||
for (int x = playerChunk.x - Data.viewDistance; x < playerChunk.x + Data.viewDistance; x++)
|
for (int x = playerChunk.x - Data.viewDistance; x < playerChunk.x + Data.viewDistance; x++)
|
||||||
{
|
{
|
||||||
for (int z = playerChunk.z - Data.viewDistance; z < playerChunk.z + Data.viewDistance; z++)
|
for (int z = playerChunk.z - Data.viewDistance; z < playerChunk.z + Data.viewDistance; z++)
|
||||||
@@ -346,8 +349,20 @@ public class World : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Cursor.visible = true;
|
Cursor.visible = true;
|
||||||
Cursor.lockState = CursorLockMode.None;
|
Cursor.lockState = CursorLockMode.None;
|
||||||
|
optionsScreen.SetActive(false);
|
||||||
pauseScreen.SetActive(true);
|
pauseScreen.SetActive(true);
|
||||||
Time.timeScale = 0;
|
Time.timeScale = 0;
|
||||||
|
|
||||||
|
if (PlayerPrefs.HasKey("viewDistance"))
|
||||||
|
{
|
||||||
|
int value = PlayerPrefs.GetInt("viewDistance");
|
||||||
|
if (value != Data.viewDistance)
|
||||||
|
{
|
||||||
|
Data.viewDistance = value;
|
||||||
|
LoadChunks(new ChunkCoord((int)(player.transform.position.x / Data.chunkWidth),
|
||||||
|
(int)(player.transform.position.z / Data.chunkWidth)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RespawnButton()
|
public void RespawnButton()
|
||||||
@@ -376,7 +391,13 @@ public class World : MonoBehaviour
|
|||||||
SceneManager.LoadScene("Login");
|
SceneManager.LoadScene("Login");
|
||||||
deadScreen.SetActive(false);
|
deadScreen.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShowOptionsScreen()
|
||||||
|
{
|
||||||
|
pauseScreen.SetActive(false);
|
||||||
|
optionsScreen.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
public void SaveButton()
|
public void SaveButton()
|
||||||
{
|
{
|
||||||
client.SaveWorld();
|
client.SaveWorld();
|
||||||
|
|||||||
Reference in New Issue
Block a user