Beispiel #1
0
        /// <summary>
        /// 加载方块数据
        /// </summary>
        /// <param name="filepath">Filepath.</param>
        public void LoadCubeDataFromFile(string filepath)
        {
            if (string.IsNullOrEmpty(filepath))
            {
                return;
            }

            _CubeDatas.Clear();

            byte[] datas = ResourceManger.Instance.GetBytes(filepath);
            if (datas == null || datas.Length == 0)
            {
                return;
            }

            ByteReader reader = new ByteReader(datas);
            int        count  = reader.Read <int> ();

            for (int i = 0; i < count; i++)
            {
                CubeData data = new CubeData();
                data.Position      = reader.ReadVector3();
                data.FrontTexture  = reader.Read <int> ();
                data.BackTexture   = reader.Read <int> ();
                data.TopTexture    = reader.Read <int> ();
                data.BottomTexture = reader.Read <int> ();
                data.LeftTexture   = reader.Read <int> ();
                data.RightTexture  = reader.Read <int> ();
                _CubeDatas.Add(data);
            }
        }
Beispiel #2
0
        /// 创建方块
        /// </summary>
        private Cube CreateCube(CubeData data)
        {
            //GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
            GameObject go = new GameObject();

            Cube newCube = go.AddComponent <Cube> ();

            newCube.Initialize();
            newCube.transform.position = data.Position;
            newCube.transform.SetParent(this.transform);

            newCube.ReplaceTexture(Cube.CubeSide.Top, GetTexture(data.TopTexture));
            newCube.ReplaceTexture(Cube.CubeSide.Bottom, GetTexture(data.BottomTexture));
            newCube.ReplaceTexture(Cube.CubeSide.Left, GetTexture(data.LeftTexture));
            newCube.ReplaceTexture(Cube.CubeSide.Right, GetTexture(data.RightTexture));
            newCube.ReplaceTexture(Cube.CubeSide.Front, GetTexture(data.FrontTexture));
            newCube.ReplaceTexture(Cube.CubeSide.Back, GetTexture(data.BackTexture));

            Renderer render = go.GetComponent <Renderer> ();

            if (render != null)
            {
                render.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
                render.receiveShadows    = false;
            }

            return(newCube);
        }
Beispiel #3
0
        /// <summary>
        /// 执行事件
        /// </summary>
        public void DoEvent()
        {
            if (_LoadCusor < 0 || _LoadCusor >= _TerrianData.CubeDatas.Count)
            {
                return;
            }
            CubeData data = _TerrianData.CubeDatas [_LoadCusor];

            this.CreateCube(data);

            _LoadCusor++;
        }