Choose Block to build
This commit is contained in:
@@ -30,6 +30,7 @@ public class Player : MonoBehaviour
|
||||
private Vector3 lastPosition = new Vector3();
|
||||
private Quaternion lastRotation = new Quaternion();
|
||||
|
||||
private byte currentBlock = 0;
|
||||
|
||||
//network
|
||||
private Client client = null;
|
||||
@@ -137,13 +138,40 @@ public class Player : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
if (currentBlock == 1)
|
||||
{
|
||||
if (Input.GetAxisRaw("Mouse ScrollWheel") < 0)
|
||||
{
|
||||
currentBlock = (byte)(world.blockData.Length - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentBlock += (byte)(Input.GetAxisRaw("Mouse ScrollWheel") * 10);
|
||||
}
|
||||
}
|
||||
else if (currentBlock == world.blockData.Length - 1)
|
||||
{
|
||||
if (Input.GetAxisRaw("Mouse ScrollWheel") > 0)
|
||||
{
|
||||
currentBlock = (byte)(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentBlock += (byte)(Input.GetAxisRaw("Mouse ScrollWheel") * 10);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentBlock += (byte)(Input.GetAxisRaw("Mouse ScrollWheel") * 10);
|
||||
}
|
||||
|
||||
//send build block request to server
|
||||
if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit, 8))
|
||||
{
|
||||
hit.point -= camera.transform.forward / 10;
|
||||
client.EditBlock(hit.point, 6);
|
||||
client.EditBlock(hit.point, currentBlock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class World : MonoBehaviour
|
||||
private Queue<ChunkCoord> chunksToUpdate = new Queue<ChunkCoord>();
|
||||
|
||||
//blocks
|
||||
[SerializeField] private BlockData[] blockData;
|
||||
[SerializeField] public BlockData[] blockData;
|
||||
|
||||
//network
|
||||
private Client client;
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user