コード例 #1
0
        //---------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------

        #region Private Member Functions

        //---------------------------------------------------------------------------

        private void DoInventoryWindow(int windowID)
        {
            OpenCog.BlockSet.BaseBlockSet.OCBlock selected = _builder.SelectedBlock;
            selected = DrawInventory(_blockSet, ref scrollPosition, selected);
            _builder.SelectedBlock = selected;
            GameManager.world.voxels.selectedBlock = selected;
        }
コード例 #2
0
        private void BuildBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block)
        {
            renderer.material = block.Atlas.Material;
            MeshFilter filter = GetComponent <MeshFilter>();

            block.Build().ToMesh(filter.mesh);
        }
コード例 #3
0
        // TODO: May need to be re-enabled...hope not, since all blockdata that gets instantiated should get its coordinates too.
        //	public BlockData(Block block) {
        //		this.block = block;
        //		direction = BlockDirection.Z_PLUS;
        //	}

        public OCBlockData(OpenCog.BlockSet.BaseBlockSet.OCBlock block, Vector3i globalPosition)
        {
            this.block    = block;
            this._globalX = globalPosition.x;
            this._globalY = globalPosition.y;
            this._globalZ = globalPosition.z;
            direction     = OCBlockDirection.Z_PLUS;
        }
コード例 #4
0
		// TODO: May need to be re-enabled...hope not, since all blockdata that gets instantiated should get its coordinates too.
	//	public BlockData(Block block) {
	//		this.block = block;
	//		direction = BlockDirection.Z_PLUS;
	//	}
	
//		public OCBlockData() 
//		{
//		}
		
		public OCBlockData Init(OpenCog.BlockSet.BaseBlockSet.OCBlock block, Vector3i globalPosition)
		{
			this.block = block;
			this._globalX = globalPosition.x;
			this._globalY = globalPosition.y;
			this._globalZ = globalPosition.z;
			direction = OCBlockDirection.Z_PLUS;
			return this;
		}
コード例 #5
0
 private static OpenCog.BlockSet.BaseBlockSet.OCBlock DrawInventory(OpenCog.BlockSet.OCBlockSet blockSet, ref UnityEngine.Vector2 scrollPosition, OpenCog.BlockSet.BaseBlockSet.OCBlock selected)
 {
     scrollPosition = GUILayout.BeginScrollView(scrollPosition);
     for (int i = 0, y = 0; i < blockSet.BlockCount; y++)
     {
         GUILayout.BeginHorizontal();
         for (int x = 0; x < 8; x++, i++)
         {
             OpenCog.BlockSet.BaseBlockSet.OCBlock block = blockSet.GetBlock(i);
             if (DrawBlock(block, block == selected && selected != null))
             {
                 selected = block;
             }
         }
         GUILayout.EndHorizontal();
     }
     GUILayout.EndScrollView();
     return(selected);
 }
コード例 #6
0
        private static bool DrawBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block, bool selected)
        {
            UnityEngine.Rect rect = GUILayoutUtility.GetAspectRect(1f);

            if (selected)
            {
                GUI.Box(rect, GUIContent.none);
            }

            UnityEngine.Vector3 center = rect.center;
            rect.width  -= 8;
            rect.height -= 8;
            rect.center  = center;

            if (block != null)
            {
                return(block.DrawPreview(rect));
            }
            return(false);
        }
コード例 #7
0
        private static bool DrawItem(OpenCog.BlockSet.BaseBlockSet.OCBlock block, bool selected)
        {
            Rect position = GUILayoutUtility.GetRect(0, 40, GUILayout.ExpandWidth(true));

            if (selected)
            {
                GUI.Box(position, GUIContent.none);
            }

            GUIStyle labelStyle = new GUIStyle(GUI.skin.label);

            labelStyle.alignment = TextAnchor.MiddleLeft;

            Rect texRect = new Rect(position.x + 4, position.y + 4, position.height - 8, position.height - 8);

            block.DrawPreview(texRect);

            Rect labelRect = position;

            labelRect.xMin = texRect.xMax + 4;
            GUI.Label(labelRect, block.GetName(), labelStyle);

            return(Event.current.type == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition));
        }
コード例 #8
0
 public void SetBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block, int x, int y, int z)
 {
     SetBlock(OCBlockData.CreateInstance <OCBlockData>().Init(block, new Vector3i(x, y, z)), x, y, z);
 }
コード例 #9
0
 public void SetBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block, Vector3i pos)
 {
     SetBlock(OCBlockData.CreateInstance <OCBlockData>().Init(block, pos), pos);
 }
コード例 #10
0
 public void SetBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block, int x, int y, int z)
 {
     SetBlock(new OCBlockData(block, new Vector3i(x, y, z)), x, y, z);
 }
コード例 #11
0
 public void SetBlock(OpenCog.BlockSet.BaseBlockSet.OCBlock block, Vector3i pos)
 {
     SetBlock(new OCBlockData(block, pos), pos);
 }