Example #1
0
 void Awake()
 {
     if (self == null)
     {
         self = this;
     }
     _dataSource = new Block45OctDataSource(AddNodeToBuildList);
 }
Example #2
0
    void Awake()
    {
        Block45Man.self = this;
        _dataSource     = new Block45OctDataSource(AddOctNewNodeToAttach);
        int layer = Pathea.Layer.VFVoxelTerrain;

        Block45ChunkGo._defLayer  = layer;
        Block45ChunkGo._defMats   = _b45Materials;
        Block45ChunkGo._defParent = transform;
        VFGoPool <Block45ChunkGo> .PreAlloc(64);
    }
Example #3
0
 void Awake()
 {
     _dataSource = new Block45OctDataSource(AddNodeToBuildList);
 }
    void Update()
    {
        if (_voxels == null && b45Building != null)
        {
            _voxels = b45Building.DataSource;
        }
        RaycastHit raycastHit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out raycastHit, 100.0f)
            //&& Physics.Raycast(ray, out raycastHitUnused, 100.0f, uiLayerMask) == false
            )
        {
            if (cursorCubeGo != null)
            {
                cursorCubeGo.GetComponent <MeshRenderer>().enabled = true;
                Vector3 snapVec = raycastHit.point;
                //snapVec += raycastHit.normal/2.0f;
                snapVec *= Block45Constants._scaleInverted;
                // round to the nearest constants._scale

                snapVec.x = Mathf.FloorToInt(snapVec.x);
                snapVec.y = Mathf.FloorToInt(snapVec.y);
                snapVec.z = Mathf.FloorToInt(snapVec.z);

                snapVec.x     += Block45Constants._scale / 2.0f;
                snapVec.y     += Block45Constants._scale / 2.0f;
                snapVec.z     += Block45Constants._scale / 2.0f;
                buildCursorPos = new IntVector3(snapVec);
                snapVec       /= Block45Constants._scaleInverted;

                cursorCubeGo.transform.position = snapVec;

                if (snapVec.x >= 0 && snapVec.y >= 0 && snapVec.z >= 0)
                {
                    buildCursorPos.x = Mathf.FloorToInt(buildCursorPos.x);
                    buildCursorPos.y = Mathf.FloorToInt(buildCursorPos.y);
                    buildCursorPos.z = Mathf.FloorToInt(buildCursorPos.z);
                }
                else
                {
                    cursorCubeGo.GetComponent <MeshRenderer>().enabled = false;
                    buildCursorPos = null;
                }
            }
        }
        else
        {
//			if(Physics.Raycast(ray, out raycastHitUnused, 100.0f, uiLayerMask))
//			{
//				print (raycastHitUnused.collider.name);
//			}
//			cursorCubeGo.GetComponent<MeshRenderer>().enabled = false;
//			buildCursorPos = null;
        }
        if (Input.GetMouseButtonUp(0) && Input.GetKey(KeyCode.LeftAlt) && buildCursorPos != null)
        {
            B45Block block;
            block.blockType    = B45Block.MakeBlockType(currentShape, currentRotation);
            block.materialType = (byte)currentMat;
//			_voxels.Write(buildCursorPos.x, buildCursorPos.y, buildCursorPos.z, block, 0);
            b45Building.AlterBlockInBuild(buildCursorPos.x, buildCursorPos.y, buildCursorPos.z, block);
        }
//		if(Input.GetKey(KeyCode.P))
//		{
//			float lv = refPlaneMan.getXYRefPlaneLevel();
//			refPlaneMan.setXYRefPlane(lv + 1);
//		}
//		if(Input.GetKey(KeyCode.O))
//		{
//			float lv = refPlaneMan.getXYRefPlaneLevel();
//			refPlaneMan.setXYRefPlane(lv - 1);
//		}

        testRoutine();
    }