This commit is contained in:
Noah
2022-05-15 21:00:56 +02:00
7 changed files with 115 additions and 72 deletions
@@ -0,0 +1,78 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Invisible
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: be5ce586e1f1d9a43aea5965b6e5ea02, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.995
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 1
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 204bd9a43c6ebf6489beeea547931033
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
+2 -2
View File
@@ -1338,7 +1338,7 @@ MeshRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7035241573763573916} m_GameObject: {fileID: 7035241573763573916}
m_Enabled: 1 m_Enabled: 1
m_CastShadows: 1 m_CastShadows: 2
m_ReceiveShadows: 1 m_ReceiveShadows: 1
m_DynamicOccludee: 1 m_DynamicOccludee: 1
m_MotionVectors: 1 m_MotionVectors: 1
@@ -1349,7 +1349,7 @@ MeshRenderer:
m_RenderingLayerMask: 1 m_RenderingLayerMask: 1
m_RendererPriority: 0 m_RendererPriority: 0
m_Materials: m_Materials:
- {fileID: 2100000, guid: bb9f295792e17a541ac256536656b256, type: 2} - {fileID: 2100000, guid: 204bd9a43c6ebf6489beeea547931033, type: 2}
m_StaticBatchInfo: m_StaticBatchInfo:
firstSubMesh: 0 firstSubMesh: 0
subMeshCount: 0 subMeshCount: 0
@@ -1,5 +1,7 @@
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
@@ -258,6 +260,7 @@ public class Client
client.Send(data, data.Length); client.Send(data, data.Length);
} }
public void Disconnect() public void Disconnect()
{ {
Send(new byte[] { 4 }); Send(new byte[] { 4 });
+12 -65
View File
@@ -4,8 +4,6 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
public class World : MonoBehaviour public class World : MonoBehaviour
{ {
//basic //basic
@@ -20,8 +18,7 @@ public class World : MonoBehaviour
private Queue<Player.PlayerRotationsUpdateData> playersRotationsToUpdate = private Queue<Player.PlayerRotationsUpdateData> playersRotationsToUpdate =
new Queue<Player.PlayerRotationsUpdateData>(); new Queue<Player.PlayerRotationsUpdateData>();
[SerializeField] private Player player; private bool backToMenuRequest = false;
[SerializeField] private GameObject deadScreen;
//chunks //chunks
private Chunk[,] chunks; private Chunk[,] chunks;
@@ -97,6 +94,12 @@ public class World : MonoBehaviour
g.transform.rotation = data.rotation; g.transform.rotation = data.rotation;
} }
} }
//go bock to menu
if (backToMenuRequest)
{
SceneManager.LoadScene("Scenes/Login", LoadSceneMode.Single);
}
} }
//enqueue player position update to list //enqueue player position update to list
@@ -144,43 +147,6 @@ public class World : MonoBehaviour
} }
} }
//return the ID of a block
public byte GetBlockID(Vector3 positionInWorld)
{
byte height = GetHeight((int)positionInWorld.x, (int)positionInWorld.z);
//world pass
if (positionInWorld.x < 0 || positionInWorld.y < 0 || positionInWorld.z < 0 ||
positionInWorld.x >= worldSize * Data.chunkWidth || positionInWorld.y > height ||
positionInWorld.z >= worldSize * Data.chunkWidth)
{
return 0;
}
//chunk pass
if ((int)positionInWorld.y == height)
{
return 3;
}
if ((int)positionInWorld.y == 0)
{
return 1;
}
if ((int)positionInWorld.y > height - 3)
{
return 2;
}
if ((int)positionInWorld.y < height)
{
return 4;
}
return 0;
}
//returns if a block is on the position //returns if a block is on the position
public bool CheckBlock(Vector3 positionInWorld) public bool CheckBlock(Vector3 positionInWorld)
{ {
@@ -286,6 +252,11 @@ public class World : MonoBehaviour
} }
public void BackToMenu()
{
SceneManager.LoadScene("Scenes/Login", LoadSceneMode.Single);
}
public Client GetClient() public Client GetClient()
{ {
return client; return client;
@@ -298,28 +269,4 @@ public class World : MonoBehaviour
public string name; public string name;
public byte[] textures = new byte[6]; public byte[] textures = new byte[6];
} }
public void ShowDeadScreen()
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
deadScreen.SetActive(true);
Time.timeScale = 0;
}
public void RespawnButton()
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Confined;
Time.timeScale = 1;
player.transform.position = player.GetDefaultPlayerPosition();
deadScreen.SetActive(false);
}
public void QuitButton()
{
client.Disconnect();
SceneManager.LoadScene("Login");
deadScreen.SetActive(false);
}
} }
+8 -1
View File
@@ -4,11 +4,14 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using Random = UnityEngine.Random;
public class World : MonoBehaviour public class World : MonoBehaviour
{ {
//basic //basic
[SerializeField] public int worldSize; [SerializeField] public int worldSize;
private int randomOffsetX, randomOffsetZ;
private int seed = 0;
//chunks //chunks
public Chunk[,] chunks; public Chunk[,] chunks;
@@ -18,6 +21,10 @@ public class World : MonoBehaviour
[SerializeField] private int transferDelay; [SerializeField] private int transferDelay;
private void Start() private void Start()
{ {
Random.InitState(seed);
randomOffsetX = Random.Range(0, 10000);
randomOffsetZ = Random.Range(0, 10000);
if (File.Exists(Application.dataPath + "\\save.world")) if (File.Exists(Application.dataPath + "\\save.world"))
{ {
chunks = new Chunk[worldSize, worldSize]; chunks = new Chunk[worldSize, worldSize];
@@ -88,7 +95,7 @@ public class World : MonoBehaviour
//return the ID of a block //return the ID of a block
public byte GetBlockID(Vector3 positionInWorld) public byte GetBlockID(Vector3 positionInWorld)
{ {
byte height = GetHeight((int)positionInWorld.x, (int)positionInWorld.z); byte height = GetHeight((int)positionInWorld.x + randomOffsetX, (int)positionInWorld.z + randomOffsetZ);
//world pass //world pass
if (positionInWorld.x < 0 || positionInWorld.y < 0 || positionInWorld.z < 0 || if (positionInWorld.x < 0 || positionInWorld.y < 0 || positionInWorld.z < 0 ||
Binary file not shown.