예제 #1
0
    private void UpdateCursor(MeshHitTarget potentialMeshInteraction)
    {
        ConstructionCursor.MouseState state = Input.GetMouseButton(0) ? ConstructionCursor.MouseState.LeftClickDown
            : (Input.GetMouseButton(1) ? ConstructionCursor.MouseState.RightClickDown : ConstructionCursor.MouseState.Hovering);

        cursor.UpdateCursor(potentialMeshInteraction, state);
    }
예제 #2
0
 private void Update()
 {
     if (GroundModificationMode)
     {
         DoEasing();
         GridExpander expander = new GridExpander(gameMain.MainGrid, ExpansionAngleThreshold);
         expander.PreviewExpansion(gameMain.MainGrid);
         if (Input.GetMouseButtonUp(0))
         {
             gameMain.MainGrid.AddToMesh(expander.Points, expander.Edges);
             gameMain.UpdateInteractionGrid();
         }
     }
     else
     {
         MeshHitTarget potentialMeshInteraction = GetPotentialMeshInteraction();
         UpdateCursor(potentialMeshInteraction);
         HandleRightMeshClicks(potentialMeshInteraction);
         HandleLeftMeshClicks(potentialMeshInteraction);
     }
     UpdateCursorHighlight();
     HandleOrbit();
     HandlePan();
     cameraInteraction.HandleMouseScrollwheel();
 }
예제 #3
0
 private void HandleRightMeshClicks(MeshHitTarget hitInfo)
 {
     if (Input.GetMouseButtonUp(1) && hitInfo != null && hitInfo.SourceCell != null)
     {
         hitInfo.SourceCell.Filled = false;
         gameMain.UpdateInteractionGrid();
         gameMain.UpdateVoxelVisuals(hitInfo.SourceCell);
     }
 }
예제 #4
0
 private void HandleLeftMeshClicks(MeshHitTarget hitInfo)
 {
     if (Input.GetMouseButtonUp(0) &&
         hitInfo != null &&
         hitInfo.TargetCell != null)
     {
         hitInfo.TargetCell.Filled = true;
         gameMain.UpdateInteractionGrid();
         gameMain.UpdateVoxelVisuals(hitInfo.TargetCell);
     }
 }
예제 #5
0
    private MeshHitTarget GetPotentialMeshInteraction()
    {
        if (rightDragDetector.IsDragging ||
            leftDragDetector.IsDragging)
        {
            return(null);
        }

        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit))
        {
            MeshHitTarget ret = gameMain.InteractionMesh.GetHitTarget(hit.triangleIndex);
            if (ret != null && !(ret.TargetCell != null && ret.TargetCell.GroundPoint.IsBorder))
            {
                return(ret);
            }
        }
        return(null);
    }