Пример #1
0
    private void EditBlocks()
    {
        //            var sceneCamera = SceneView.lastActiveSceneView.camera;
        //            var pixelPos = Event.current.mousePosition;
        //            var v3 = new Vector3(pixelPos.x, pixelPos.y, 0.0f);
        //            var ray = sceneCamera.ScreenPointToRay(v3);
        Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);

        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 10000, 1 << LayerMask.NameToLayer("Ground")))
        {
            if (myScript.m_Dataset == null)
            {
                myScript.CreateDataset();
            }

            Debug.Log($"选中了坐标点:{hit.point.x}:{hit.point.z}");

            var pos    = myScript.m_Dataset.GetXYIndex(hit.point.x, hit.point.z);
            var xindex = (int)pos.X;
            var yindex = (int)pos.Y;
            if (myScript.Exist(xindex, yindex))
            {
                Debug.Log($"编辑格子状态,{xindex}:{yindex}");
                myScript.ChangeValid(xindex, yindex);
                myScript.SaveToFile();
            }
            else
            {
                Debug.Log($"没有选中格子,{pos.X}:{pos.Y}");
            }
        }
    }
Пример #2
0
    //判断格子是否存在(必须是有效格子)
    public bool IsBlockExists(int xindex, int yindex)
    {
        if (!GeneralPreJudge())
        {
            return(false);
        }

        if (!_currentBattlebox.Exist(xindex, yindex))
        {
            return(false);
        }

        var block = _currentBattlebox.GetBlockData(xindex, yindex);

        if (block != null && block.BoxBlock != null && !block.BoxBlock.IsValid)
        {
            return(false);
        }

        return(true);
    }