Init
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
# Modified from:
|
||||
# https://github.com/github/gitignore/blob/master/Unity.gitignore
|
||||
|
||||
/[Ll]ibrary/
|
||||
/[Uu]serSettings/
|
||||
[Tt]emp/
|
||||
[Oo]bj/
|
||||
/[Bb]uild/
|
||||
/[Bb]uilds/
|
||||
/[Ll]ogs/
|
||||
/[Mm]emoryCaptures/
|
||||
|
||||
# Uncomment this line if you wish to ignore the asset store tools plugin
|
||||
# [Aa]ssets/AssetStoreTools*
|
||||
|
||||
# Visual Studio cache directory
|
||||
.vs/
|
||||
|
||||
# Gradle cache directory
|
||||
.gradle/
|
||||
|
||||
# Autogenerated VS/MD/Consulo solution and project files
|
||||
ExportedObj/
|
||||
.consulo/
|
||||
*.csproj
|
||||
*.unityproj
|
||||
*.sln
|
||||
*.suo
|
||||
*.tmp
|
||||
*.user
|
||||
*.userprefs
|
||||
*.pidb
|
||||
*.booproj
|
||||
*.svd
|
||||
*.pdb
|
||||
*.mdb
|
||||
*.opendb
|
||||
*.VC.db
|
||||
|
||||
# Unity3D generated meta files
|
||||
*.pidb.meta
|
||||
*.pdb.meta
|
||||
*.mdb.meta
|
||||
|
||||
# Unity3D generated file on crash reports
|
||||
sysinfo.txt
|
||||
|
||||
# Builds
|
||||
*.apk
|
||||
*.unitypackage
|
||||
|
||||
# Crashlytics generated file
|
||||
crashlytics-build.properties
|
||||
|
||||
# Windows
|
||||
Thumbs.db
|
||||
Thumbs.db.meta
|
||||
|
||||
# MacOS
|
||||
*.DS_Store
|
||||
|
||||
# VS Code
|
||||
*.vscode
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 958ba5cd973c5fd4d99641ffd183759a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
+108
@@ -0,0 +1,108 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a3615b75cf066041a8f172f87970606
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04e1845e087de6144ad3e4f0879cbfb0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using UnityEngine;
|
||||
|
||||
public class Chunk
|
||||
{
|
||||
//basic
|
||||
private ChunkCoord chunkPosition;
|
||||
private World world;
|
||||
|
||||
//rendering
|
||||
public GameObject gameObject;
|
||||
|
||||
//data
|
||||
public byte[,,] blocks = new byte[Data.chunkWidth, Data.chunkHeight, Data.chunkWidth];
|
||||
|
||||
public Chunk(ChunkCoord chunkPosition, World world)
|
||||
{
|
||||
this.chunkPosition = chunkPosition;
|
||||
this.world = world;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
||||
//initializes the chunks components
|
||||
private void Initialize()
|
||||
{
|
||||
gameObject = new GameObject(chunkPosition.x + ", " + chunkPosition.z);
|
||||
gameObject.transform.position =
|
||||
new Vector3(chunkPosition.x * Data.chunkWidth, 0, chunkPosition.z * Data.chunkWidth);
|
||||
}
|
||||
|
||||
//writes the block data
|
||||
public void PopulateBlocks()
|
||||
{
|
||||
for (int y = 0; y < Data.chunkHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < Data.chunkWidth; x++)
|
||||
{
|
||||
for (int z = 0; z < Data.chunkWidth; z++)
|
||||
{
|
||||
blocks[x, y, z] = world.GetBlockID(new Vector3(x + chunkPosition.x * Data.chunkWidth,
|
||||
y, z + chunkPosition.z * Data.chunkWidth));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(byte x, byte y, byte z, byte blockID)
|
||||
{
|
||||
blocks[x, y, z] = blockID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5d27935c6d501a41a2d972b8ff6cc7c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class ChunkCoord
|
||||
{
|
||||
public ChunkCoord(int x, int z)
|
||||
{
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int x;
|
||||
public int z;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b0ff680cf7becd4a905cd0f219efa91
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Data
|
||||
{
|
||||
public static int chunkWidth = 15, chunkHeight = 250;
|
||||
public static int textureAtlasSize = 16;
|
||||
|
||||
public static readonly Vector3[] vertices =
|
||||
{
|
||||
new Vector3(0, 0, 0),
|
||||
new Vector3(1, 0, 0),
|
||||
new Vector3(1, 1, 0),
|
||||
new Vector3(0, 1, 0),
|
||||
new Vector3(1, 0, 1),
|
||||
new Vector3(0, 0, 1),
|
||||
new Vector3(0, 1, 1),
|
||||
new Vector3(1, 1, 1)
|
||||
};
|
||||
|
||||
public static readonly int[,] triangles =
|
||||
{
|
||||
//front
|
||||
{0, 3, 1, 1, 3, 2},
|
||||
//back
|
||||
{4, 7, 5, 5, 7, 6},
|
||||
//top
|
||||
{3, 6, 2, 2, 6, 7},
|
||||
//bottom
|
||||
{5, 0, 4, 4, 0, 1},
|
||||
//left
|
||||
{5, 6, 0, 0, 6, 3},
|
||||
//right
|
||||
{1, 2, 4, 4, 2, 7},
|
||||
};
|
||||
|
||||
public static readonly Vector3[] faceChecks =
|
||||
{
|
||||
//front
|
||||
new Vector3(0, 0, -1),
|
||||
//back
|
||||
new Vector3(0, 0, 1),
|
||||
//top
|
||||
new Vector3(0, 1, 0),
|
||||
//bottom
|
||||
new Vector3(0, -1, 0),
|
||||
//left
|
||||
new Vector3(-1, 0, 0),
|
||||
//right
|
||||
new Vector3(1, 0, 0),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 643914e5a873de34baea75d649800005
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,213 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
public class Server
|
||||
{
|
||||
//game
|
||||
private World world;
|
||||
|
||||
//network
|
||||
private UdpClient client;
|
||||
private int transferDelay;
|
||||
private List<IPEndPoint> players = new List<IPEndPoint>();
|
||||
private List<string> playerNames = new List<string>();
|
||||
private List<bool> nextTransfer = new List<bool>();
|
||||
private Thread receiveThread;
|
||||
private List<Thread> transferThreads = new List<Thread>();
|
||||
|
||||
public Server(World world, int transferDelay)
|
||||
{
|
||||
this.transferDelay = transferDelay;
|
||||
this.world = world;
|
||||
|
||||
//setup client
|
||||
client = new UdpClient(8051);
|
||||
client.DontFragment = false;
|
||||
|
||||
//start listening
|
||||
receiveThread = new Thread(Receive); //info:
|
||||
receiveThread.Start();
|
||||
//0: init message
|
||||
}
|
||||
|
||||
//info:
|
||||
//[0] = 0: init message
|
||||
//[0] = 1: world transfer [1] = 1: finished
|
||||
//[0] = 2: world size
|
||||
//[0] = 3: edit block
|
||||
//[0] = 4: disconnect player
|
||||
//[0] = 5: next transfer
|
||||
|
||||
private void Receive()
|
||||
{
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0);
|
||||
byte[] data = client.Receive(ref endPoint);
|
||||
|
||||
if (data[0] == 5)
|
||||
{
|
||||
int id = GetPlayerID(endPoint);
|
||||
nextTransfer[id] = true;
|
||||
}
|
||||
|
||||
if (data[0] == 4)
|
||||
{
|
||||
IPEndPoint tempEndPoint = null;
|
||||
int i = 0;
|
||||
foreach (IPEndPoint e in players)
|
||||
{
|
||||
if (e.Address.GetHashCode() == endPoint.Address.GetHashCode())
|
||||
{
|
||||
Send(new byte[] { 4 }, e);
|
||||
tempEndPoint = e;
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (tempEndPoint != null)
|
||||
{
|
||||
players.Remove(tempEndPoint);
|
||||
Console.WriteLine(playerNames[i] + " left the game");
|
||||
playerNames.RemoveAt(i);
|
||||
nextTransfer.RemoveAt(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (data[0] == 0)
|
||||
{
|
||||
Thread t = new Thread(TransferWorld);
|
||||
transferThreads.Add(t);
|
||||
t.Start(endPoint);
|
||||
}
|
||||
|
||||
if (data[0] == 2)
|
||||
{
|
||||
Send(new byte[] { 2, (byte)world.worldSize }, endPoint);
|
||||
|
||||
List<byte> asciiName = new List<byte>();
|
||||
for (int i = 1; i < data.Length; i++)
|
||||
{
|
||||
asciiName.Add(data[i]);
|
||||
}
|
||||
|
||||
string name = Encoding.ASCII.GetString(asciiName.ToArray());
|
||||
//add player
|
||||
players.Add(endPoint);
|
||||
playerNames.Add(name);
|
||||
nextTransfer.Add(false);
|
||||
Console.WriteLine(name + " joined the game");
|
||||
}
|
||||
|
||||
if (data[0] == 3)
|
||||
{
|
||||
ChunkCoord chunk = new ChunkCoord(data[1], data[2]);
|
||||
Vector3 positionInChunk = new Vector3(data[3], data[4], data[5]);
|
||||
byte blockID = data[6];
|
||||
|
||||
world.EditBlock(chunk, positionInChunk, blockID);
|
||||
|
||||
foreach (IPEndPoint e in players)
|
||||
{
|
||||
Send(new byte[]
|
||||
{
|
||||
3, (byte)chunk.x, (byte)chunk.z,
|
||||
(byte)positionInChunk.x, (byte)positionInChunk.y, (byte)positionInChunk.z, blockID
|
||||
}, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private int GetPlayerID(IPEndPoint endPoint)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (IPEndPoint e in players)
|
||||
{
|
||||
if (e.Address.GetHashCode() == endPoint.Address.GetHashCode())
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void TransferWorld(object o)
|
||||
{
|
||||
IPEndPoint endPoint = (IPEndPoint)o;
|
||||
int id = GetPlayerID(endPoint);
|
||||
|
||||
Console.WriteLine("begin world transfer for " + playerNames[id]);
|
||||
for (int xChunk = 0; xChunk < world.worldSize; xChunk++)
|
||||
{
|
||||
for (int zChunk = 0; zChunk < world.worldSize; zChunk++)
|
||||
{
|
||||
nextTransfer[id] = false;
|
||||
|
||||
byte[] send = new byte[Data.chunkWidth * Data.chunkWidth * Data.chunkHeight + 2];
|
||||
send[0] = 1;
|
||||
send[1] = 0;
|
||||
int i = 2;
|
||||
|
||||
for (int y = 0; y < Data.chunkHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < Data.chunkWidth; x++)
|
||||
{
|
||||
for (int z = 0; z < Data.chunkWidth; z++)
|
||||
{
|
||||
send[i] = world.chunks[xChunk, zChunk].blocks[x, y, z];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Send(send, endPoint);
|
||||
|
||||
while (!nextTransfer[id])
|
||||
{
|
||||
}
|
||||
|
||||
nextTransfer[id] = false;
|
||||
}
|
||||
}
|
||||
|
||||
Send(new byte[] { 1, 1 }, endPoint);
|
||||
Console.WriteLine("world transfer finished for " + playerNames[id]);
|
||||
}
|
||||
|
||||
private void Send(byte[] data, IPEndPoint endPoint)
|
||||
{
|
||||
client.Send(data, data.Length, endPoint);
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
receiveThread.Abort();
|
||||
for (int i = 0; i < transferThreads.Count; i++)
|
||||
{
|
||||
if (transferThreads[i] != null)
|
||||
{
|
||||
transferThreads[i].Abort();
|
||||
}
|
||||
}
|
||||
client.Close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40d9d5a5030b4944ea8c79b350ed5a0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class World : MonoBehaviour
|
||||
{
|
||||
//basic
|
||||
[SerializeField] public int worldSize;
|
||||
|
||||
//chunks
|
||||
public Chunk[,] chunks;
|
||||
|
||||
//network
|
||||
private Server server;
|
||||
[SerializeField] private int transferDelay;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
CreateChunks();
|
||||
server = new Server(this, transferDelay);
|
||||
}
|
||||
|
||||
//creates an array of chunks
|
||||
private void CreateChunks()
|
||||
{
|
||||
chunks = new Chunk[worldSize, worldSize];
|
||||
for (int x = 0; x < worldSize; x++)
|
||||
{
|
||||
for (int z = 0; z < worldSize; z++)
|
||||
{
|
||||
chunks[x, z] = new Chunk(new ChunkCoord(x, z), this);
|
||||
chunks[x, z].gameObject.transform.SetParent(gameObject.transform);
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < worldSize; x++)
|
||||
{
|
||||
for (int z = 0; z < worldSize; z++)
|
||||
{
|
||||
chunks[x, z].PopulateBlocks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//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
|
||||
public bool CheckBlock(Vector3 positionInWorld)
|
||||
{
|
||||
if (positionInWorld.x < -1 || positionInWorld.z < -1 ||
|
||||
positionInWorld.x > worldSize * Data.chunkWidth ||
|
||||
positionInWorld.z > worldSize * Data.chunkWidth)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (positionInWorld.x < 0 || positionInWorld.y < 0 || positionInWorld.z < 0 ||
|
||||
positionInWorld.x >= worldSize * Data.chunkWidth || positionInWorld.y >= Data.chunkHeight ||
|
||||
positionInWorld.z >= worldSize * Data.chunkWidth)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
ChunkCoord chunk = new ChunkCoord((int)(positionInWorld.x / Data.chunkWidth),
|
||||
(int)(positionInWorld.z / Data.chunkWidth));
|
||||
|
||||
int xInChunk = (int)(positionInWorld.x - chunk.x * Data.chunkWidth);
|
||||
int yInChunk = (int)positionInWorld.y;
|
||||
int zInChunk = (int)(positionInWorld.z - chunk.z * Data.chunkWidth);
|
||||
|
||||
if (chunks[chunk.x, chunk.z] != null)
|
||||
{
|
||||
if (chunks[chunk.x, chunk.z].blocks[xInChunk, yInChunk, zInChunk] == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private byte GetHeight(int x, int z)
|
||||
{
|
||||
float scale = 0.025f;
|
||||
byte perlinHeight = 10;
|
||||
byte groundHeight = 10;
|
||||
|
||||
byte height = (byte)(Mathf.PerlinNoise((x) * scale + 0.1f, (z) * scale + 0.1f) * perlinHeight + groundHeight);
|
||||
return height;
|
||||
}
|
||||
|
||||
public void EditBlock(ChunkCoord chunk, Vector3 positionInChunk, byte blockID)
|
||||
{
|
||||
byte xInChunk = (byte)(positionInChunk.x);
|
||||
byte yInChunk = (byte)positionInChunk.y;
|
||||
byte zInChunk = (byte)(positionInChunk.z);
|
||||
|
||||
//edit block in chunk
|
||||
if(chunks[chunk.x, chunk.z].blocks[xInChunk, yInChunk, zInChunk] != 1)
|
||||
{
|
||||
chunks[chunk.x, chunk.z].Update(xInChunk, yInChunk, zInChunk, blockID);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
server.Disconnect();
|
||||
}
|
||||
|
||||
|
||||
private void SaveWorld()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5457f26f725053d46bffb9885acfd7d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72762c29ca3bd154aacf38b08963b8d9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,170 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_LightingSettings: {fileID: 0}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &1102427346
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1102427347}
|
||||
- component: {fileID: 1102427348}
|
||||
m_Layer: 0
|
||||
m_Name: World
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1102427347
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1102427346}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1102427348
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1102427346}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5457f26f725053d46bffb9885acfd7d8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
worldSize: 20
|
||||
transferDelay: 5
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fc0d4010bbf28b4594072e72b8655ab
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user