Ejemplo n.º 1
0
        private float UpdateSelectedBlock()   // return the distance with the selected block
        {
            Vector3 relBlockPos;
            Block   actBlock;
            float   distance = VanillaBlock.getBlockOnRay(this.mWorld.getIsland(), this.mStateMgr.Camera.GetCameraToViewportRay(0.5f, 0.5f), DIST_MAX_SELECTION,
                                                          DIST_MIN_SELECTION, out relBlockPos, out actBlock);

            if (distance > DIST_MAX_SELECTION)
            {
                this.SelectedBlockPos = Vector3.ZERO;
                this.SelectedBlock    = null;
                this.mWireCube.SetVisible(false);
                return(0);
            }

            this.SelectedBlockPos = relBlockPos;
            this.SelectedBlock    = actBlock;
            this.mWireCube.SetVisible(true);
            this.mWireCube.Position = (this.SelectedBlockPos + Vector3.NEGATIVE_UNIT_Z) * Cst.CUBE_SIDE;

            if (!this.mStateMgr.GameInfo.IsInEditorMode)
            {
                ConstructionBlock constr = this.SelectedBlock as ConstructionBlock;
                if (constr != null)
                {
                    this.BuildingMgr.ActConsBlockPos = this.SelectedBlockPos;
                }
                else if (!this.mIsBuilderOpen && this.BuildingMgr.ActConsBlockPos != -Vector3.UNIT_SCALE)
                {
                    this.BuildingMgr.ActConsBlockPos = -Vector3.UNIT_SCALE;
                }
            }

            return(distance);
        }
Ejemplo n.º 2
0
 // Update is called once per frame
 private void Start()
 {
     script = constructionBlock.GetComponent <ConstructionBlock>();
 }