public ISSCBlockVector CalPlacingPosition(Vector3 hitPoint, Vector3 hittedBlockPosition)
    {
        Vector3 dir = hitPoint - hittedBlockPosition;

        dir = ISMath.Clip2NormalDirectionV2(dir);
        return(ISSCBGrid.WorldPositionToGridPosition(dir + hittedBlockPosition, moniter.transform.position));
    }
 void StopCamGLRenderAndPlacingSphere()
 {
     if (cameraScript.selecting)
     {
         Vector3 v1 = selectTipBlock.transform.position;
         ISSCGridPrimitiveShapeUtilities.CreateSphere(core.data, ISSCBGrid.WorldPositionToGridPosition(v1, core.moniter.transform.position), core.currentFillingBlock, radius);
         cameraScript.selecting = false;
         radius = 0;
     }
 }
 void StopCamGLRenderAndPlacingCube()
 {
     if (cameraScript.selecting)
     {
         Vector3         v1           = selectTipBlock.transform.position;
         ISSCBlockVector fromPosition = ISSCBGrid.WorldPositionToGridPosition(v1 + Vector3.one * length, core.moniter.transform.position);
         ISSCBlockVector toPosition   = ISSCBGrid.WorldPositionToGridPosition(v1 - Vector3.one * length, core.moniter.transform.position);
         ISSCGridPrimitiveShapeUtilities.CreateCube(core.data, core.currentFillingBlock, fromPosition, toPosition);
         cameraScript.selecting = false;
         length = 0;
     }
 }
    void CreateTmpGO(RaycastHit hit)
    {
        if (!hit.collider)
        {
            return;
        }
        moving = true;

        tmpVector1 = ISSCBGrid.WorldPositionToGridPosition(hit.transform.position, core.moniter.transform.position);
        tmpID      = core.data.GetRawData() [core.data.EncodeIndex(tmpVector1)];
        fallBackGO = hit.collider.gameObject;
        fallBackGO.SetActive(false);
        tmpGO = Instantiate(fallBackGO) as GameObject;
        tmpGO.SetActive(true);
        tmpGO.transform.localScale *= 0.8f;
        tmpGO.layer = ISSCLayerManager.tmpBlockLayer;
    }
Example #5
0
    public void Submit(string command)
    {
        if (command.StartsWith("select block"))
        {
            string argu = command.Substring(12);
            core.currentFillingBlock = int.Parse(argu);
        }
        else if (command.StartsWith("sb"))
        {
            string argu = command.Substring(2);
            core.currentFillingBlock = int.Parse(argu);
        }
        else if (command.StartsWith("save"))
        {
            string argu = command.Substring(command.IndexOf("\"") + 1, command.LastIndexOf("\"") - command.IndexOf("\"") - 1);
            core.SaveCurrentScene(Application.dataPath + "/Resources/SavedDatas/" + argu);
        }
        else if (command.StartsWith("load"))
        {
            string argu = command.Substring(command.IndexOf("\"") + 1, command.LastIndexOf("\"") - command.IndexOf("\"") - 1);
            core.OpenScene(Application.dataPath + "/Resources/SavedDatas/" + argu);
        }
        else if (command.StartsWith("new"))
        {
            string[] argus = ParseArguments(command);
            int      size  = int.Parse(argus [0]);
            core.NewScene(new ISSCBlockVector(size, size, size), "New Scene");
        }
        else if (command.StartsWith("sphere"))
        {
            string[]        argus        = ParseArguments(command);
            ISSCBlockVector center       = ParseBlockVector(argus [0]);
            int             r            = int.Parse(argus [1]);
            int             fillingBlock = int.Parse(argus [2]);

            ISSCGridPrimitiveShapeUtilities.CreateSphere(core.data, center, fillingBlock, r);
        }
        else if (command.StartsWith("cube"))
        {
            string[]        argus        = ParseArguments(command);
            ISSCBlockVector a            = ParseBlockVector(argus [0]);
            ISSCBlockVector b            = ParseBlockVector(argus [1]);
            int             fillingBlock = int.Parse(argus [2]);

            ISSCGridPrimitiveShapeUtilities.CreateCube(core.data, fillingBlock, a, b);
        }
        else if (command.StartsWith("move"))
        {
            string[]        argus = ParseArguments(command);
            ISSCBlockVector a     = ParseBlockVector(argus [0]);
            ISSCBlockVector b     = ParseBlockVector(argus [1]);
            bool            forceMove;
            switch (argus [2])
            {
            case "true":
                forceMove = true;
                break;

            case "false":
                forceMove = false;
                break;

            default:
                forceMove = true;
                break;
            }

            core.data.MoveBlock(a, b, forceMove);
        }
        else if (command.StartsWith("currentmoveto"))
        {
            string[]        argus = ParseArguments(command);
            ISSCBlockVector a     = ParseBlockVector(argus [0]);
            bool            forceMove;
            switch (argus [1])
            {
            case "true":
                forceMove = true;
                break;

            case "false":
                forceMove = false;
                break;

            default:
                forceMove = true;
                break;
            }
            ISSCBlockVector currentBlock = ISSCBGrid.WorldPositionToGridPosition(core.tipsBlock.transform.position, core.moniter.transform.position);
            core.data.MoveBlock(currentBlock, a, forceMove);
            core.tipsBlock.transform.position = ISSCBGrid.GridPositionToWorldPosition(a, core.moniter.transform.position);
            Debug.Log(ISSCBGrid.GridPositionToWorldPosition(a, core.moniter.transform.position));
        }
    }
 public void SelectBlock(Vector3 position)
 {
     SelectBlock(ISSCBGrid.WorldPositionToGridPosition(position, moniter.transform.position));
 }
 public ISSCBlockVector BlockForWorldPosition(Vector3 position)
 {
     return(ISSCBGrid.WorldPositionToGridPosition(position, moniter.transform.position));
 }