Exemplo n.º 1
0
        protected override void Awake()
        {
            base.Awake();
            ChunkManagerInstance = GetComponent <ChunkManager>();

            InitData();

            ChunkDataFile.LoadedRegions = new Dictionary <string, string[]>();
            ChunkDataFile.TempChunkData = new Dictionary <string, string>();

            //Set layer
            if (LayerMask.LayerToName(26) != "" && LayerMask.LayerToName(26) != "UniblocksNoCollide")
            {
                Debug.LogWarning("Layer 26 is reservd for uniblocks");
            }
            for (int i = 0; i < 31; i++)
            {
                Physics.IgnoreLayerCollision(i, 26);
            }
            //Check TODO

            //Check Materia;
            GameObject chunkPrefab   = GetComponent <ChunkManager>().ChunkObject;
            int        materialCount = chunkPrefab.GetComponent <Renderer>().sharedMaterials.Length - 1;

            for (ushort i = 0; i < Blocks.Length; i++)
            {
                if (Blocks[i] != null)
                {
                    BaseBlock block = Blocks[i].GetComponent <BaseBlock>();
                    if (block.m_submeshIndex < 0)
                    {
                        Debug.LogError("Block " + i + "material index <0");
                        Debug.Break();
                    }
                    if (block.m_submeshIndex > materialCount)
                    {
                        Debug.LogError("Block " + i + "material index >count");
                        Debug.Break();
                    }
                }
            }


            Inited = true;
        }
Exemplo n.º 2
0
        //Mesh
        public static Vector2 GetTextureOffset(ushort block, Facing facing)
        {
            BaseBlock blockType = GetBlockType(block);

            Vector2[] TextureArray = blockType.m_Texture;
            if (TextureArray.Length == 0)
            {
                //default texture
                return(new Vector2(0, 0));
            }
            else if (blockType.m_CuntomSides == false)
            {
                return(TextureArray[0]);
            }
            else if ((int)facing > TextureArray.Length - 1)
            {
                return(TextureArray[TextureArray.Length - 1]);
            }
            else
            {
                return(TextureArray[(int)facing]);
            }
        }