├── .gitattributes ├── .gitignore ├── Assets ├── Editor.meta ├── Materials.meta ├── Materials │ ├── terrain.mat │ └── terrain.mat.meta ├── Prefabs.meta ├── Prefabs │ ├── Chunk.prefab │ └── Chunk.prefab.meta ├── Scripts.meta ├── Scripts │ ├── CharacterMovement.cs │ ├── CharacterMovement.cs.meta │ ├── ItemDatabase.cs │ ├── ItemDatabase.cs.meta │ ├── Player.meta │ ├── Player │ │ ├── MouseLook.cs │ │ ├── MouseLook.cs.meta │ │ ├── PlayerInfo.cs │ │ ├── PlayerInfo.cs.meta │ │ ├── PlayerInput.cs │ │ └── PlayerInput.cs.meta │ ├── UI.meta │ ├── UI │ │ ├── TooltipUI.cs │ │ └── TooltipUI.cs.meta │ ├── World.meta │ └── World │ │ ├── Chunk.cs │ │ ├── Chunk.cs.meta │ │ ├── Noise.cs │ │ ├── Noise.cs.meta │ │ ├── World.cs │ │ └── World.cs.meta ├── Textures.meta ├── Textures │ ├── crosshair.png │ ├── crosshair.png.meta │ ├── terrain.png │ └── terrain.png.meta ├── scene.unity └── scene.unity.meta ├── LICENSE ├── Minecraft.apk ├── ProjectSettings ├── AudioManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset └── TimeManager.asset ├── README.md └── Web Build ├── Web Build.html └── Web Build.unity3d /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | 6 | # Autogenerated VS/MD solution and project files 7 | /*.csproj 8 | /*.unityproj 9 | /*.sln 10 | /*.suo 11 | /*.user 12 | /*.userprefs 13 | /*.pidb 14 | /*.booproj 15 | 16 | #Unity3D Generated File On Crash Reports 17 | sysinfo.txt 18 | 19 | # ========================= 20 | # Operating System Files 21 | # ========================= 22 | 23 | # OSX 24 | # ========================= 25 | 26 | .DS_Store 27 | .AppleDouble 28 | .LSOverride 29 | 30 | # Thumbnails 31 | ._* 32 | 33 | # Files that might appear on external disk 34 | .Spotlight-V100 35 | .Trashes 36 | 37 | # Directories potentially created on remote AFP share 38 | .AppleDB 39 | .AppleDesktop 40 | Network Trash Folder 41 | Temporary Items 42 | .apdisk 43 | 44 | # Windows 45 | # ========================= 46 | 47 | # Windows image file caches 48 | Thumbs.db 49 | ehthumbs.db 50 | 51 | # Folder config file 52 | Desktop.ini 53 | 54 | # Recycle Bin used on file shares 55 | $RECYCLE.BIN/ 56 | 57 | # Windows Installer files 58 | *.cab 59 | *.msi 60 | *.msm 61 | *.msp 62 | 63 | # Windows shortcuts 64 | *.lnk 65 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb10ff7f33b30474c99634825b6e992f 3 | folderAsset: yes 4 | timeCreated: 1439413244 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c11ad7a5ebe677b4e9e1645375e24f5a 3 | folderAsset: yes 4 | timeCreated: 1437133582 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Materials/terrain.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/Assets/Materials/terrain.mat -------------------------------------------------------------------------------- /Assets/Materials/terrain.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 383a54d29f8845e459c8ddff7a8fd2a3 3 | timeCreated: 1437076295 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea3415f872c863246992fc8c4feb7cfe 3 | folderAsset: yes 4 | timeCreated: 1437059776 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Prefabs/Chunk.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/Assets/Prefabs/Chunk.prefab -------------------------------------------------------------------------------- /Assets/Prefabs/Chunk.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 622247ab1b040474ea22238b8158238d 3 | timeCreated: 1435071431 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3092d62dc14ff514e87ceabe383e4354 3 | folderAsset: yes 4 | timeCreated: 1437059727 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/CharacterMovement.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Minecraft { 5 | public class CharacterMovement : MonoBehaviour { 6 | 7 | public float speed = 10f; 8 | 9 | Vector3 direction; 10 | 11 | bool isFlying = true; 12 | 13 | void Update () { 14 | 15 | } 16 | 17 | public void Move(Vector3 direction, bool jump, bool crouch) { 18 | if (isFlying) { 19 | HandleFlyingMovement(direction, jump, crouch); 20 | } 21 | } 22 | 23 | public void HandleFlyingMovement(Vector3 direction, bool jump, bool crouch) { 24 | float magnitude = direction.magnitude; 25 | if (magnitude > 0.01f) { 26 | direction = direction / magnitude; 27 | 28 | transform.position += transform.rotation * direction * speed * Time.deltaTime; 29 | } 30 | 31 | if (jump) { 32 | transform.position += Vector3.up * speed * Time.deltaTime; 33 | } else if (crouch) { 34 | transform.position += Vector3.down * speed * Time.deltaTime; 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/Scripts/CharacterMovement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8c730004755d104aa53404cb6907aef 3 | timeCreated: 1437135071 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/ItemDatabase.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace Minecraft { 6 | public class ItemDatabase : ScriptableObject { 7 | static List items_ ; 8 | 9 | public static void Init() { 10 | items_ = new List (); 11 | Add(new Item(1, "Grass", 64, ItemTexture.Grass)); 12 | Add(new Item(2, "Dirt", 64, ItemTexture.Dirt)); 13 | Add(new Item(3, "Stone", 64, ItemTexture.Stone)); 14 | Add(new Item(4, "Cobblestone", 64, ItemTexture.Cobblestone)); 15 | Add(new Item(5, "Bedrock", 64, ItemTexture.Bedrock)); 16 | Add(new Item(6, "Tree trunk", 64, ItemTexture.TreeTrunk)); 17 | Add(new Item(7, "Tree leaves", 64, ItemTexture.TreeLeaves)); 18 | } 19 | 20 | public static List GetItems() { 21 | return items_; 22 | } 23 | 24 | public static void Add(Item item) { 25 | items_.Add(item); 26 | } 27 | 28 | public static void Remove(Item item) { 29 | items_.Remove(item); 30 | } 31 | 32 | public static Item GetItemById(int id) { 33 | foreach (Item item in items_) { 34 | if (item.id == id) { 35 | return item; 36 | } 37 | } 38 | return null; 39 | } 40 | public static Item GetItemByName(string name) { 41 | foreach (Item item in items_) { 42 | if (item.name == name) { 43 | return item; 44 | } 45 | } 46 | return null; 47 | } 48 | } 49 | 50 | [System.Serializable] 51 | public class Item { 52 | public int id; 53 | public string name; 54 | public int maxStackSize; 55 | public ItemTexture texture; 56 | 57 | public Item(int id, string name, int maxStackSize, ItemTexture texture) { 58 | this.id = id; 59 | this.name = name; 60 | this.maxStackSize = maxStackSize; 61 | this.texture = texture; 62 | } 63 | } 64 | 65 | [System.Serializable] 66 | public class ItemTexture { 67 | public static float resoution = 0.0625f; 68 | public Vector2 front = Vector2.one * resoution, 69 | back = Vector2.one * resoution, 70 | left = Vector2.one * resoution, 71 | right = Vector2.one * resoution, 72 | top = Vector2.one * resoution, 73 | bottom = Vector2.one * resoution; 74 | 75 | public ItemTexture(Vector2 front, Vector2 back, Vector2 left, Vector2 right, Vector2 top, Vector2 bottom) { 76 | this.front = front * resoution; 77 | this.back = back * resoution; 78 | this.left = left * resoution; 79 | this.right = right * resoution; 80 | this.top = top * resoution; 81 | this.bottom = bottom * resoution; 82 | } 83 | 84 | public ItemTexture(Vector2 all) { 85 | this.front = all * resoution; 86 | this.back = all * resoution; 87 | this.left = all * resoution; 88 | this.right = all * resoution; 89 | this.top = all * resoution; 90 | this.bottom = all * resoution; 91 | } 92 | 93 | public static ItemTexture Grass = new ItemTexture(new Vector2(3f, 15f), new Vector2(3f, 15f), new Vector2(3f, 15f), new Vector2(3f, 15f), new Vector2(0f, 15f), new Vector2(2f, 15f)); 94 | public static ItemTexture Dirt = new ItemTexture(new Vector2(2f, 15f)); 95 | public static ItemTexture Stone = new ItemTexture(new Vector2(1f, 15f)); 96 | public static ItemTexture Cobblestone = new ItemTexture(new Vector2(0f, 14f)); 97 | public static ItemTexture Bedrock = new ItemTexture(new Vector2(1f, 14f)); 98 | public static ItemTexture TreeTrunk = new ItemTexture(new Vector2(4f, 14f), new Vector2(4f, 14f), new Vector2(4f, 14f), new Vector2(4f, 14f), new Vector2(5f, 14f), new Vector2(5f, 14f)); 99 | public static ItemTexture TreeLeaves = new ItemTexture(new Vector2(4f, 12f)); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Assets/Scripts/ItemDatabase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8b98735b449eb34aa24049120d0c0aa 3 | timeCreated: 1439585786 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/Player.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1c2208370dee094ba301c980a9dc6b8 3 | folderAsset: yes 4 | timeCreated: 1439657932 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/Player/MouseLook.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Minecraft { 5 | public class MouseLook : MonoBehaviour { 6 | 7 | float _sensitivityX = 15f; 8 | float _sensitivityY = 15f; 9 | 10 | float _minimumY = -90f; 11 | float _maximumY = 90f; 12 | 13 | float _rotationY = 0f; 14 | 15 | Camera _camera; 16 | 17 | void Start () { 18 | if (GetComponent()) { 19 | GetComponent().freezeRotation = true; 20 | } 21 | _camera = GetComponentInChildren (); 22 | } 23 | 24 | void Update () { 25 | transform.Rotate(0, Input.GetAxis("Mouse X") * _sensitivityX, 0); 26 | 27 | _rotationY += Input.GetAxis("Mouse Y") * _sensitivityY; 28 | _rotationY = Mathf.Clamp (_rotationY, _minimumY, _maximumY); 29 | _camera.transform.localEulerAngles = new Vector3(-_rotationY, _camera.transform.localEulerAngles.y, 0); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Assets/Scripts/Player/MouseLook.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28a7faf6508dc4645b0e3440934bf9c2 3 | timeCreated: 1439725256 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/Player/PlayerInfo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Minecraft { 5 | public class PlayerInfo : MonoBehaviour { 6 | 7 | // Use this for initialization 8 | void Start () { 9 | 10 | } 11 | 12 | // Update is called once per frame 13 | void Update () { 14 | 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/Scripts/Player/PlayerInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6f2e1f6f900c774c92680a017b35739 3 | timeCreated: 1437139377 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/Player/PlayerInput.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Minecraft { 5 | [RequireComponent(typeof(CharacterMovement))] 6 | public class PlayerInput : MonoBehaviour { 7 | CharacterMovement _characterMovement; 8 | Camera _camera; 9 | 10 | void Start () { 11 | _characterMovement = GetComponent (); 12 | _camera = GetComponentInChildren (); 13 | } 14 | 15 | void Update () { 16 | 17 | Vector3 movementDirection = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical")); 18 | bool jump = Input.GetButton("Jump"); 19 | bool crouch = Input.GetButton("Crouch"); 20 | 21 | _characterMovement.Move(movementDirection, jump, crouch); 22 | 23 | RaycastHit hit; 24 | if (Physics.Raycast(_camera.transform.position, _camera.transform.forward, out hit, 10f)) { 25 | if (Input.GetButtonDown("Fire1")) { 26 | BreakBlock(hit.point + (-0.1f * hit.normal)); 27 | } 28 | if (Input.GetButtonDown("Fire2")) { 29 | PlaceBlock(hit.point + (0.1f * hit.normal)); 30 | } 31 | 32 | TooltipUI.SetActive(true); 33 | int id = Chunk.GetWorldId(hit.point + (-0.1f * hit.normal)); 34 | Item item = ItemDatabase.GetItemById(id); 35 | if (item != null) { 36 | TooltipUI.text.text = "" + item.name; 37 | } 38 | } else { 39 | TooltipUI.SetActive(false); 40 | } 41 | } 42 | 43 | void PlaceBlock(Vector3 position) { 44 | Chunk.SetWorldId(position, 1); 45 | } 46 | 47 | void BreakBlock(Vector3 position) { 48 | Chunk.SetWorldId(position, 0); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Assets/Scripts/Player/PlayerInput.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c75f0ad83af2474c8cf96c3add8485c 3 | timeCreated: 1437134030 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/UI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b007f13bf150154085af229fcd0fadf 3 | folderAsset: yes 4 | timeCreated: 1439825523 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/UI/TooltipUI.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System.Collections; 4 | 5 | public class TooltipUI : MonoBehaviour { 6 | 7 | public static Text text; 8 | public static Image image; 9 | 10 | static bool active = true; 11 | 12 | void Start () { 13 | text = GetComponentInChildren (); 14 | image = GetComponent (); 15 | SetActive(false); 16 | } 17 | 18 | void Update () { 19 | if (active) { 20 | GetComponent().sizeDelta = new Vector2(text.preferredWidth + 10, text.preferredHeight); 21 | } 22 | } 23 | 24 | public static void SetActive(bool active) { 25 | TooltipUI.active = active; 26 | text.enabled = active; 27 | image.enabled = active; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/Scripts/UI/TooltipUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 352105db6413fab46949f00d52d04506 3 | timeCreated: 1439588160 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/World.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc396b9de6a02ed4fa66adfaff8641fe 3 | folderAsset: yes 4 | timeCreated: 1439825478 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/World/Chunk.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using SimplexNoise; 5 | 6 | namespace Minecraft { 7 | [RequireComponent(typeof(MeshFilter))] 8 | [RequireComponent(typeof(MeshRenderer))] 9 | [RequireComponent(typeof(MeshCollider))] 10 | public class Chunk : MonoBehaviour { 11 | 12 | public static int size = 16; 13 | public static int height = 64; 14 | 15 | static float frequency { 16 | get { return World.instance.frequency; } 17 | } 18 | static float amplitude { 19 | get { return World.instance.amplitude; } 20 | } 21 | static float baseHeight { 22 | get { return World.instance.baseHeight; } 23 | } 24 | 25 | public static List chunks = new List (); 26 | public static List unInitializedChunks = new List (); 27 | 28 | bool initialized = false; 29 | 30 | Mesh mesh; 31 | MeshFilter meshFilter; 32 | MeshCollider meshCollider; 33 | 34 | int[,,] map; 35 | int[,] heightMap; 36 | 37 | // HACK: these are initialized from World.cs move to world settings? 38 | public static Vector3 offset0, offset1, offset2; 39 | 40 | void Start() { 41 | chunks.Add(this); 42 | unInitializedChunks.Add(this); 43 | 44 | meshFilter = GetComponent (); 45 | meshCollider = GetComponent (); 46 | 47 | if (unInitializedChunks[0] == this) { 48 | Generate(); 49 | } 50 | } 51 | 52 | public void Generate() { 53 | 54 | map = new int[size, height, size]; 55 | heightMap = new int[size,size]; 56 | 57 | GenerateHeightMap(); 58 | 59 | if (World.instance.generateTerrain) GenerateTerrain(); 60 | if (World.instance.generateTrees) AddTrees(); 61 | 62 | initialized = true; 63 | unInitializedChunks.Remove(this); 64 | 65 | 66 | StartCoroutine(BuildMesh()); 67 | } 68 | 69 | 70 | public IEnumerator BuildMesh() { 71 | 72 | List vertices = new List (); 73 | List triangles = new List (); 74 | List uv = new List (); 75 | 76 | for (int y = 0; y < height; y++) { 77 | for (int x = 0; x < size; x++) { 78 | for (int z = 0; z < size; z++) { 79 | int id = map[x,y,z]; 80 | if (id != 0) 81 | Block.AddToMesh(this, x, y, z, id, vertices, triangles, uv); 82 | } 83 | } 84 | } 85 | 86 | 87 | mesh = new Mesh(); 88 | mesh.vertices = vertices.ToArray(); 89 | mesh.triangles = triangles.ToArray(); 90 | mesh.uv = uv.ToArray(); 91 | mesh.RecalculateBounds(); 92 | mesh.RecalculateNormals(); 93 | 94 | meshFilter.mesh = mesh; 95 | meshCollider.sharedMesh = mesh; 96 | 97 | yield return null; 98 | 99 | if (unInitializedChunks.Count > 0) { 100 | unInitializedChunks[0].Generate(); 101 | } 102 | } 103 | 104 | void GenerateHeightMap() { 105 | for (int x = 0; x < size; x++) { 106 | for (int z = 0; z < size; z++) { 107 | heightMap[x,z] = CalculateHeightMapValue(new Vector3(x,0f,z) + transform.position); 108 | } 109 | } 110 | } 111 | 112 | void GenerateTerrain() { 113 | for (int x = 0; x < size; x++) { 114 | for (int z = 0; z < size; z++) { 115 | for (int y = 0; y < height; y++) { 116 | int id = CalculateId(new Vector3(x,y,z) + transform.position); 117 | map[x,y,z] = id; 118 | } 119 | } 120 | } 121 | } 122 | 123 | void AddTrees(){ 124 | Tree.Place(this, new Vector3(8,heightMap[8,8]+1,8)); 125 | } 126 | 127 | private static int CalculateHeightMapValue(Vector3 position) { 128 | float x0 = (position.x + offset0.x) * frequency; 129 | float z0 = (position.z + offset0.z) * frequency; 130 | 131 | float x1 = (position.x + offset1.x) * frequency * 2f; 132 | float z1 = (position.z + offset1.z) * frequency * 2f; 133 | 134 | float x2 = (position.x + offset2.x) * frequency * 4f; 135 | float z2 = (position.z + offset2.z) * frequency * 4f; 136 | 137 | float noise0 = Noise.Generate(x0, z0) * amplitude; 138 | float noise1 = Noise.Generate(x1, z1) * amplitude / 4f; 139 | float noise2 = Noise.Generate(x2, z2) * amplitude / 8f; 140 | 141 | float noise = noise0 + noise1 + noise2; 142 | 143 | return Mathf.FloorToInt(noise + baseHeight); 144 | } 145 | 146 | private static int CalculateId(Vector3 position) { 147 | 148 | if (position.y < 0 || position.y > height - 1) { 149 | return 0; 150 | } 151 | 152 | float heightMapValue = CalculateHeightMapValue(position); 153 | 154 | if (position.y < 5) { 155 | return 5; // bedrock 156 | } 157 | 158 | if (position.y == heightMapValue) { 159 | return 1; // grass 160 | } else if (position.y < heightMapValue && position.y > heightMapValue - 5) { 161 | return 2; // dirt 162 | } else if (position.y > heightMapValue) { 163 | return 0; // air 164 | } else { 165 | return 3; // stone 166 | } 167 | } 168 | 169 | public int GetLocalId(int x, int y, int z) { 170 | 171 | if (y < 0 || y > height - 1) { 172 | return 0; 173 | } 174 | 175 | int id = 0; 176 | if (x < 0 || x > size - 1 || z < 0 || z > size - 1) { 177 | id = GetWorldId(new Vector3(x, y, z) + transform.position); 178 | return id; 179 | } 180 | 181 | if (initialized) { 182 | id = map[x,y,z]; 183 | } else { 184 | id = CalculateId(new Vector3(x, y, z) + transform.position); 185 | } 186 | return id; 187 | } 188 | 189 | public static int GetWorldId(Vector3 position) { 190 | if (position.y < 0f || position.y > height - 1) { 191 | return 0; 192 | } 193 | int id = 0; 194 | Chunk chunk = Find(position); 195 | if (chunk != null && chunk.initialized) { 196 | Vector3 chunkPosition = chunk.transform.position; 197 | 198 | int x = Mathf.FloorToInt(position.x - chunkPosition.x); 199 | int y = Mathf.FloorToInt(position.y - chunkPosition.y); 200 | int z = Mathf.FloorToInt(position.z - chunkPosition.z); 201 | 202 | id = chunk.GetLocalId(x, y, z); 203 | } else { 204 | id = CalculateId(position); 205 | } 206 | return id; 207 | } 208 | 209 | public void SetLocalId(int x, int y, int z, int id) { 210 | if (y < 0 || y > height - 1 || x < 0 || x > size - 1 || z < 0 || z > size - 1) return; 211 | 212 | map[x,y,z] = id; 213 | if (initialized) { 214 | StartCoroutine(BuildMesh()); 215 | } 216 | 217 | Chunk chunk = null; 218 | if (x == 0) { 219 | chunk = Find(new Vector3(x-1, y, z) + transform.position); 220 | } else if (x == size - 1) { 221 | chunk = Find(new Vector3(x+1, y, z) + transform.position); 222 | } 223 | if (chunk != null && chunk.initialized) StartCoroutine(chunk.BuildMesh()); 224 | 225 | if (z == 0) { 226 | chunk = Find(new Vector3(x, y, z-1) + transform.position); 227 | } else if (z == size - 1) { 228 | chunk = Find(new Vector3(x, y, z+1) + transform.position); 229 | } 230 | if (chunk != null && chunk.initialized) StartCoroutine(chunk.BuildMesh()); 231 | } 232 | 233 | public static void SetWorldId(Vector3 position, int id) { 234 | if (position.y < 0f || position.y > height - 1) { 235 | return; 236 | } 237 | 238 | Chunk chunk = Find(position); 239 | if (chunk != null && chunk.initialized) { 240 | Vector3 chunkPosition = chunk.transform.position; 241 | 242 | int x = Mathf.FloorToInt(position.x - chunkPosition.x); 243 | int y = Mathf.FloorToInt(position.y - chunkPosition.y); 244 | int z = Mathf.FloorToInt(position.z - chunkPosition.z); 245 | 246 | chunk.SetLocalId(x, y, z, id); 247 | } else { 248 | Debug.LogWarning("This chunk has not been initialized yet!"); 249 | } 250 | } 251 | 252 | public static Chunk Find(Vector3 position) { 253 | foreach (Chunk chunk in chunks) { 254 | Vector3 chunkPosition = chunk.transform.position; 255 | if (position.x >= chunkPosition.x && position.x < chunkPosition.x + size && 256 | position.y >= chunkPosition.y && position.y < chunkPosition.y + height && 257 | position.z >= chunkPosition.z && position.z < chunkPosition.z + size) { 258 | return chunk; 259 | } 260 | } 261 | return null; 262 | } 263 | 264 | public bool IsTransparent(int x, int y, int z) { 265 | if (y < 0) { 266 | return false; 267 | } 268 | int id = GetLocalId(x,y,z); 269 | return id == 0 || id == 7; 270 | } 271 | } 272 | 273 | public class Block { 274 | // DIRTY: this class can be done in a less confusing way! 275 | public static void AddToMesh(Chunk chunk, int x, int y, int z, int id, List vertices, List triangles, List uv) { 276 | // top 277 | if (chunk == null || chunk.IsTransparent(x, y + 1, z)) 278 | AddFace(new Vector3(x, y + 1, z), id, Vector3.up, vertices, triangles, uv); 279 | // bottom 280 | if (chunk == null || chunk.IsTransparent(x,y - 1,z)) 281 | AddFace(new Vector3(x, y, z), id, Vector3.down, vertices, triangles, uv); 282 | // left 283 | if (chunk == null || chunk.IsTransparent(x - 1, y, z)) 284 | AddFace(new Vector3(x, y, z + 1), id, Vector3.left, vertices, triangles, uv); 285 | // right 286 | if (chunk == null || chunk.IsTransparent(x + 1, y, z)) 287 | AddFace(new Vector3(x + 1, y, z + 1), id, Vector3.right, vertices, triangles, uv); 288 | // front 289 | if (chunk == null || chunk.IsTransparent(x, y, z + 1)) 290 | AddFace(new Vector3(x, y, z + 1), id, Vector3.forward, vertices, triangles, uv); 291 | // back 292 | if (chunk == null || chunk.IsTransparent(x, y, z - 1)) 293 | AddFace(new Vector3(x, y, z), id, Vector3.back, vertices, triangles, uv); 294 | } 295 | 296 | public static void AddFace(Vector3 corner, int id, Vector3 normal, List vertices, List triangles, List uv) { 297 | Vector3 right = Vector3.zero; 298 | Vector3 up = Vector3.zero; 299 | bool reversed = false; 300 | 301 | if (normal == Vector3.down || normal == Vector3.right || normal == Vector3.forward) { 302 | reversed = true; 303 | } 304 | 305 | int index = vertices.Count; 306 | 307 | if (normal == Vector3.up || normal == Vector3.down) { 308 | up = Vector3.forward; 309 | right = Vector3.right; 310 | } else if (normal == Vector3.left || normal == Vector3.right) { 311 | up = Vector3.up; 312 | right = Vector3.back; 313 | } else if (normal == Vector3.forward || normal == Vector3.back) { 314 | up = Vector3.up; 315 | right = Vector3.right; 316 | } 317 | 318 | vertices.Add(corner); 319 | vertices.Add(corner + up); 320 | vertices.Add(corner + up + right); 321 | vertices.Add(corner + right); 322 | 323 | if (reversed) { 324 | triangles.Add(index + 0); 325 | triangles.Add(index + 2); 326 | triangles.Add(index + 1); 327 | 328 | triangles.Add(index + 0); 329 | triangles.Add(index + 3); 330 | triangles.Add(index + 2); 331 | } else { 332 | triangles.Add(index + 0); 333 | triangles.Add(index + 1); 334 | triangles.Add(index + 2); 335 | 336 | triangles.Add(index + 0); 337 | triangles.Add(index + 2); 338 | triangles.Add(index + 3); 339 | } 340 | 341 | Vector2 offset = Vector3.zero; 342 | float resolution = 0.0625f; 343 | 344 | Vector2 _00 = new Vector2(0,0) * resolution; 345 | Vector2 _01 = new Vector2(0,1) * resolution; 346 | Vector2 _11 = new Vector2(1,1) * resolution; 347 | Vector2 _10 = new Vector2(1,0) * resolution; 348 | 349 | ItemTexture texture = ItemDatabase.GetItemById(id).texture; 350 | if (normal == Vector3.up) { 351 | offset = texture.top; 352 | } else if (normal == Vector3.down) { 353 | offset = texture.bottom; 354 | } else if (normal == Vector3.left) { 355 | offset = texture.left; 356 | } else if (normal == Vector3.right) { 357 | offset = texture.right; 358 | } else if (normal == Vector3.forward) { 359 | offset = texture.front; 360 | } else if (normal == Vector3.back) { 361 | offset = texture.back; 362 | } 363 | 364 | uv.Add(_00 + offset); 365 | uv.Add(_01 + offset); 366 | uv.Add(_11 + offset); 367 | uv.Add(_10 + offset); 368 | } 369 | } 370 | } -------------------------------------------------------------------------------- /Assets/Scripts/World/Chunk.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3495ead916ccebb4688b5cf5beea1f10 3 | timeCreated: 1435072111 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/World/Noise.cs: -------------------------------------------------------------------------------- 1 | // SimplexNoise for C# 2 | // Author: Heikki Törmälä 3 | 4 | //This is free and unencumbered software released into the public domain. 5 | 6 | //Anyone is free to copy, modify, publish, use, compile, sell, or 7 | //distribute this software, either in source code form or as a compiled 8 | //binary, for any purpose, commercial or non-commercial, and by any 9 | //means. 10 | 11 | //In jurisdictions that recognize copyright laws, the author or authors 12 | //of this software dedicate any and all copyright interest in the 13 | //software to the public domain. We make this dedication for the benefit 14 | //of the public at large and to the detriment of our heirs and 15 | //successors. We intend this dedication to be an overt act of 16 | //relinquishment in perpetuity of all present and future rights to this 17 | //software under copyright law. 18 | 19 | //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | //EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | //MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | //IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 23 | //OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 24 | //ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | //OTHER DEALINGS IN THE SOFTWARE. 26 | 27 | //For more information, please refer to 28 | 29 | 30 | namespace SimplexNoise 31 | { 32 | /// 33 | /// Implementation of the Perlin simplex noise, an improved Perlin noise algorithm. 34 | /// Based loosely on SimplexNoise1234 by Stefan Gustavson 35 | /// 36 | /// 37 | public class Noise 38 | { 39 | /// 40 | /// 1D simplex noise 41 | /// 42 | /// 43 | /// 44 | public static float Generate(float x) 45 | { 46 | int i0 = FastFloor(x); 47 | int i1 = i0 + 1; 48 | float x0 = x - i0; 49 | float x1 = x0 - 1.0f; 50 | 51 | float n0, n1; 52 | 53 | float t0 = 1.0f - x0*x0; 54 | t0 *= t0; 55 | n0 = t0 * t0 * grad(perm[i0 & 0xff], x0); 56 | 57 | float t1 = 1.0f - x1*x1; 58 | t1 *= t1; 59 | n1 = t1 * t1 * grad(perm[i1 & 0xff], x1); 60 | // The maximum value of this noise is 8*(3/4)^4 = 2.53125 61 | // A factor of 0.395 scales to fit exactly within [-1,1] 62 | return 0.395f * (n0 + n1); 63 | } 64 | 65 | /// 66 | /// 2D simplex noise 67 | /// 68 | /// 69 | /// 70 | /// 71 | public static float Generate(float x, float y) 72 | { 73 | const float F2 = 0.366025403f; // F2 = 0.5*(sqrt(3.0)-1.0) 74 | const float G2 = 0.211324865f; // G2 = (3.0-Math.sqrt(3.0))/6.0 75 | 76 | float n0, n1, n2; // Noise contributions from the three corners 77 | 78 | // Skew the input space to determine which simplex cell we're in 79 | float s = (x+y)*F2; // Hairy factor for 2D 80 | float xs = x + s; 81 | float ys = y + s; 82 | int i = FastFloor(xs); 83 | int j = FastFloor(ys); 84 | 85 | float t = (float)(i+j)*G2; 86 | float X0 = i-t; // Unskew the cell origin back to (x,y) space 87 | float Y0 = j-t; 88 | float x0 = x-X0; // The x,y distances from the cell origin 89 | float y0 = y-Y0; 90 | 91 | // For the 2D case, the simplex shape is an equilateral triangle. 92 | // Determine which simplex we are in. 93 | int i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords 94 | if(x0>y0) {i1=1; j1=0;} // lower triangle, XY order: (0,0)->(1,0)->(1,1) 95 | else {i1=0; j1=1;} // upper triangle, YX order: (0,0)->(0,1)->(1,1) 96 | 97 | // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and 98 | // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where 99 | // c = (3-sqrt(3))/6 100 | 101 | float x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords 102 | float y1 = y0 - j1 + G2; 103 | float x2 = x0 - 1.0f + 2.0f * G2; // Offsets for last corner in (x,y) unskewed coords 104 | float y2 = y0 - 1.0f + 2.0f * G2; 105 | 106 | // Wrap the integer indices at 256, to avoid indexing perm[] out of bounds 107 | int ii = i % 256; 108 | int jj = j % 256; 109 | 110 | // Calculate the contribution from the three corners 111 | float t0 = 0.5f - x0*x0-y0*y0; 112 | if(t0 < 0.0f) n0 = 0.0f; 113 | else { 114 | t0 *= t0; 115 | n0 = t0 * t0 * grad(perm[ii+perm[jj]], x0, y0); 116 | } 117 | 118 | float t1 = 0.5f - x1*x1-y1*y1; 119 | if(t1 < 0.0f) n1 = 0.0f; 120 | else { 121 | t1 *= t1; 122 | n1 = t1 * t1 * grad(perm[ii+i1+perm[jj+j1]], x1, y1); 123 | } 124 | 125 | float t2 = 0.5f - x2*x2-y2*y2; 126 | if(t2 < 0.0f) n2 = 0.0f; 127 | else { 128 | t2 *= t2; 129 | n2 = t2 * t2 * grad(perm[ii+1+perm[jj+1]], x2, y2); 130 | } 131 | 132 | // Add contributions from each corner to get the final noise value. 133 | // The result is scaled to return values in the interval [-1,1]. 134 | return 40.0f * (n0 + n1 + n2); // TODO: The scale factor is preliminary! 135 | } 136 | 137 | 138 | public static float Generate(float x, float y, float z) 139 | { 140 | // Simple skewing factors for the 3D case 141 | const float F3 = 0.333333333f; 142 | const float G3 = 0.166666667f; 143 | 144 | float n0, n1, n2, n3; // Noise contributions from the four corners 145 | 146 | // Skew the input space to determine which simplex cell we're in 147 | float s = (x+y+z)*F3; // Very nice and simple skew factor for 3D 148 | float xs = x+s; 149 | float ys = y+s; 150 | float zs = z+s; 151 | int i = FastFloor(xs); 152 | int j = FastFloor(ys); 153 | int k = FastFloor(zs); 154 | 155 | float t = (float)(i+j+k)*G3; 156 | float X0 = i-t; // Unskew the cell origin back to (x,y,z) space 157 | float Y0 = j-t; 158 | float Z0 = k-t; 159 | float x0 = x-X0; // The x,y,z distances from the cell origin 160 | float y0 = y-Y0; 161 | float z0 = z-Z0; 162 | 163 | // For the 3D case, the simplex shape is a slightly irregular tetrahedron. 164 | // Determine which simplex we are in. 165 | int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords 166 | int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords 167 | 168 | /* This code would benefit from a backport from the GLSL version! */ 169 | if(x0>=y0) { 170 | if(y0>=z0) 171 | { i1=1; j1=0; k1=0; i2=1; j2=1; k2=0; } // X Y Z order 172 | else if(x0>=z0) { i1=1; j1=0; k1=0; i2=1; j2=0; k2=1; } // X Z Y order 173 | else { i1=0; j1=0; k1=1; i2=1; j2=0; k2=1; } // Z X Y order 174 | } 175 | else { // x0 0) ? ((int)x) : (((int)x) - 1); 266 | } 267 | 268 | private static int Mod(int x, int m) 269 | { 270 | int a = x % m; 271 | return a < 0 ? a + m : a; 272 | } 273 | 274 | private static float grad( int hash, float x ) 275 | { 276 | int h = hash & 15; 277 | float grad = 1.0f + (h & 7); // Gradient value 1.0, 2.0, ..., 8.0 278 | if ((h & 8) != 0) grad = -grad; // Set a random sign for the gradient 279 | return ( grad * x ); // Multiply the gradient with the distance 280 | } 281 | 282 | private static float grad( int hash, float x, float y ) 283 | { 284 | int h = hash & 7; // Convert low 3 bits of hash code 285 | float u = h<4 ? x : y; // into 8 simple gradient directions, 286 | float v = h<4 ? y : x; // and compute the dot product with (x,y). 287 | return ((h&1) != 0 ? -u : u) + ((h&2) != 0 ? -2.0f*v : 2.0f*v); 288 | } 289 | 290 | private static float grad( int hash, float x, float y , float z ) { 291 | int h = hash & 15; // Convert low 4 bits of hash code into 12 simple 292 | float u = h<8 ? x : y; // gradient directions, and compute dot product. 293 | float v = h<4 ? y : h==12||h==14 ? x : z; // Fix repeats at h = 12 to 15 294 | return ((h&1) != 0 ? -u : u) + ((h&2) != 0 ? -v : v); 295 | } 296 | 297 | private static float grad( int hash, float x, float y, float z, float t ) { 298 | int h = hash & 31; // Convert low 5 bits of hash code into 32 simple 299 | float u = h<24 ? x : y; // gradient directions, and compute dot product. 300 | float v = h<16 ? y : z; 301 | float w = h<8 ? z : t; 302 | return ((h&1) != 0 ? -u : u) + ((h&2) != 0 ? -v : v) + ((h&4) != 0 ? -w : w); 303 | } 304 | } 305 | } 306 | -------------------------------------------------------------------------------- /Assets/Scripts/World/Noise.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dc919958dbf86848a8d68ea7428d24f 3 | timeCreated: 1435380779 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/World/World.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace Minecraft { 5 | public class World : MonoBehaviour { 6 | 7 | public static World instance; 8 | 9 | public GameObject chunkPrefab; 10 | 11 | public int size = 0; 12 | public int seed = 0; 13 | 14 | [Range(0.01f,0.1f)] public float frequency = 0.02f; 15 | [Range(0f,32f)] public float amplitude = 16.0f; 16 | [Range(0f,64f)] public float baseHeight = 32.0f; 17 | 18 | public bool generateTerrain = true; 19 | public bool generateTrees = true; 20 | 21 | void Start () { 22 | if (chunkPrefab == null) { 23 | Debug.LogError("chunkPrefab not assigned"); 24 | return; 25 | } 26 | instance = this; 27 | 28 | if (seed == 0) { 29 | seed = Random.Range(-100000000, 100000000); 30 | } 31 | 32 | StartCoroutine(Generate()); 33 | } 34 | 35 | IEnumerator Generate () { 36 | 37 | Random.seed = World.instance.seed; 38 | Chunk.offset0 = new Vector3(Random.value * 100000f, 0, Random.value * 100000f); 39 | Chunk.offset1 = new Vector3(Random.value * 100000f, 0, Random.value * 100000f); 40 | Chunk.offset2 = new Vector3(Random.value * 100000f, 0, Random.value * 100000f); 41 | 42 | 43 | GameObject chunkGO; 44 | for (int x = -size; x < size; x++) { 45 | for (int z = -size; z < size; z++) { 46 | chunkGO = (GameObject)Instantiate(chunkPrefab, new Vector3(x,0,z) * Chunk.size, Quaternion.identity); 47 | chunkGO.transform.SetParent(transform); 48 | yield return null; 49 | } 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Assets/Scripts/World/World.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df29db55839f84545a26ca93e0d101fb 3 | timeCreated: 1439585786 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - chunkPrefab: {fileID: 189380, guid: 622247ab1b040474ea22238b8158238d, type: 2} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1dc786e5dcdf43840adb256330dc95ce 3 | folderAsset: yes 4 | timeCreated: 1437135006 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Textures/crosshair.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/Assets/Textures/crosshair.png -------------------------------------------------------------------------------- /Assets/Textures/crosshair.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2639c9d0dd7c67447a98f4e8173a3d6e 3 | timeCreated: 1439761626 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: .25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 8 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 32 31 | textureSettings: 32 | filterMode: 0 33 | aniso: 16 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | spriteMode: 1 41 | spriteExtrude: 1 42 | spriteMeshType: 1 43 | alignment: 0 44 | spritePivot: {x: .5, y: .5} 45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 46 | spritePixelsToUnits: 100 47 | alphaIsTransparency: 1 48 | textureType: 8 49 | buildTargetSettings: [] 50 | spriteSheet: 51 | sprites: [] 52 | spritePackingTag: 53 | userData: 54 | assetBundleName: 55 | assetBundleVariant: 56 | -------------------------------------------------------------------------------- /Assets/Textures/terrain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/Assets/Textures/terrain.png -------------------------------------------------------------------------------- /Assets/Textures/terrain.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8710ff6dd1749a84997a15bf1df75e00 3 | timeCreated: 1437075869 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: 7 | 8900000: generatedCubemap 8 | serializedVersion: 2 9 | mipmaps: 10 | mipMapMode: 0 11 | enableMipMap: 1 12 | linearTexture: 0 13 | correctGamma: 0 14 | fadeOut: 0 15 | borderMipMap: 0 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: .25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | grayScaleToAlpha: 0 25 | generateCubemap: 0 26 | cubemapConvolution: 0 27 | cubemapConvolutionSteps: 8 28 | cubemapConvolutionExponent: 1.5 29 | seamlessCubemap: 0 30 | textureFormat: -2 31 | maxTextureSize: 256 32 | textureSettings: 33 | filterMode: 0 34 | aniso: 1 35 | mipBias: -1 36 | wrapMode: 1 37 | nPOTScale: 1 38 | lightmap: 0 39 | rGBM: 0 40 | compressionQuality: 50 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: .5, y: .5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 1 49 | textureType: 0 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | spritePackingTag: 54 | userData: 55 | assetBundleName: 56 | assetBundleVariant: 57 | -------------------------------------------------------------------------------- /Assets/scene.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/Assets/scene.unity -------------------------------------------------------------------------------- /Assets/scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bada928f039493643b767bdcc85141a3 3 | timeCreated: 1435075286 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 André Løfaldli 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Minecraft.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/Minecraft.apk -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.1.3f1 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Minecraft 2 | a clone of minecraft made with Unity3D 3 | 4 | started out by following [this](https://www.youtube.com/playlist?list=PLW2i42bgplOmRWRmo116mUA4N9-i17dIk) tutorial 5 | 6 | ## Features 7 | * Randomized terrain generation using [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise) 8 | * Trees! 9 | * Remove and place blocks 10 | -------------------------------------------------------------------------------- /Web Build/Web Build.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Unity Web Player | Minecraft 6 | 7 | 15 | 63 | 117 | 118 | 119 |

Unity Web Player | Minecraft

120 |
121 |
122 |
123 | 124 | Unity Web Player. Install now! 125 | 126 |
127 |
128 | 129 | Unity Web Player. Install now! Restart your browser after install. 130 | 131 |
132 |
133 |
134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /Web Build/Web Build.unity3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lofaldli/Minecraft/ff3f77c48bd60498888007ea4b0a61116d09fea4/Web Build/Web Build.unity3d --------------------------------------------------------------------------------