コード例 #1
0
ファイル: Map.cs プロジェクト: VB6Hobbyst7/PixelCraft
 void Start()
 {
     CubeConverter.Init();
     //LoadChuck(new Vector2(10, 10));
     //ChuckStream[new Vector2(10, 10)].Present();
     //LoadChuck(new Vector2(10, 11));
     //ChuckStream[new Vector2(10, 11)].Present();
 }
コード例 #2
0
    public void Present()
    {
        bool HasLeft = false, HasRight = false, HasTop = false, HasBottom = false, HasFront = false, HasBehind = false;

        if (ID != BlockInfo.BlockID.Empty)
        {
            int Wx = (int)(pos.x + chuck.Index.x * 16), Wy = (int)pos.y, Wz = (int)(pos.z + chuck.Index.y * 16);
            if (pos.x > 0 && pos.x < 15 && pos.z > 0 && pos.z < 15 && pos.y > 0 && pos.y < 254)
            {
                if (chuck.Blocks[(int)pos.x - 1, (int)pos.y, (int)pos.z] == null || chuck.Blocks[(int)pos.x - 1, (int)pos.y, (int)pos.z].ID == BlockInfo.BlockID.Empty || chuck.Blocks[(int)pos.x - 1, (int)pos.y, (int)pos.z].IsTransparent)
                {
                    HasLeft = true;
                }
                if (chuck.Blocks[(int)pos.x + 1, (int)pos.y, (int)pos.z] == null || chuck.Blocks[(int)pos.x + 1, (int)pos.y, (int)pos.z].ID == BlockInfo.BlockID.Empty || chuck.Blocks[(int)pos.x + 1, (int)pos.y, (int)pos.z].IsTransparent)
                {
                    HasRight = true;
                }
                if (chuck.Blocks[(int)pos.x, (int)pos.y - 1, (int)pos.z] == null || chuck.Blocks[(int)pos.x, (int)pos.y - 1, (int)pos.z].ID == BlockInfo.BlockID.Empty || chuck.Blocks[(int)pos.x, (int)pos.y - 1, (int)pos.z].IsTransparent)
                {
                    HasBottom = true;
                }
                if (chuck.Blocks[(int)pos.x, (int)pos.y + 1, (int)pos.z] == null || chuck.Blocks[(int)pos.x, (int)pos.y + 1, (int)pos.z].ID == BlockInfo.BlockID.Empty || chuck.Blocks[(int)pos.x, (int)pos.y + 1, (int)pos.z].IsTransparent)
                {
                    HasTop = true;
                }
                if (chuck.Blocks[(int)pos.x, (int)pos.y, (int)pos.z - 1] == null || chuck.Blocks[(int)pos.x, (int)pos.y, (int)pos.z - 1].ID == BlockInfo.BlockID.Empty || chuck.Blocks[(int)pos.x, (int)pos.y, (int)pos.z - 1].IsTransparent)
                {
                    HasFront = true;
                }
                if (chuck.Blocks[(int)pos.x, (int)pos.y, (int)pos.z + 1] == null || chuck.Blocks[(int)pos.x, (int)pos.y, (int)pos.z + 1].ID == BlockInfo.BlockID.Empty || chuck.Blocks[(int)pos.x, (int)pos.y, (int)pos.z + 1].IsTransparent)
                {
                    HasBehind = true;
                }
            }
            else
            {
                //Debug.Log(Wx + " Chuck " + Wz + " " + Wy);
                if (map[Wx - 1, Wy, Wz].ID == BlockInfo.BlockID.Empty || map[Wx - 1, Wy, Wz].IsTransparent)
                {
                    HasLeft = true;
                }
                if (map[Wx + 1, Wy, Wz].ID == BlockInfo.BlockID.Empty || map[Wx + 1, Wy, Wz].IsTransparent)
                {
                    HasRight = true;
                }
                if (map[Wx, Wy - 1, Wz].ID == BlockInfo.BlockID.Empty || map[Wx, Wy - 1, Wz].IsTransparent)
                {
                    HasBottom = true;
                }
                if (map[Wx, Wy + 1, Wz].ID == BlockInfo.BlockID.Empty || map[Wx, Wy + 1, Wz].IsTransparent)
                {
                    HasTop = true;
                }
                if (map[Wx, Wy, Wz - 1].ID == BlockInfo.BlockID.Empty || map[Wx, Wy, Wz - 1].IsTransparent)
                {
                    HasFront = true;
                }
                if (map[Wx, Wy, Wz + 1].ID == BlockInfo.BlockID.Empty || map[Wx, Wy, Wz + 1].IsTransparent)
                {
                    HasBehind = true;
                }
            }

            Vector2[] UV = CubeConverter.UV[ID];
            CubeConverter.AddCubeMesh(chuck.Vectexes, chuck.TextureUV, chuck.Triangles, pos.x, pos.y, pos.z, 1, UV[0], UV[1], UV[2], UV[3], UV[4], UV[5], HasLeft, HasRight, HasBottom, HasTop, HasFront, HasBehind);
        }
    }