コード例 #1
0
 public void OnSawArmRelease(Gesture gesture)
 {
     if (selected)
     {
         selected = false;
         transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 0.0f));
         Blade.ResetEdgePosition();
     }
 }
コード例 #2
0
ファイル: DadoCutting.cs プロジェクト: SunixDev/WoodshopGame
    void Update()
    {
        #region CuttingCode
        if (manager.StillCutting)
        {
            currentPiecePosition = manager.GetCurrentBoardPosition();
            totalTimePassed     += Time.deltaTime;
            UpdateFeedRateData();

            if (CurrentState == CutState.ReadyToCut)
            {
                SwitchDado();

                if (SawBlade.CuttingWoodBoard && SawBlade.SawBladeActive)
                {
                    StartWoodCutting();
                    CurrentState = CutState.Cutting;
                    manager.RestrictCurrentBoardMovement(false, true);
                }
            }
            else if (CurrentState == CutState.Cutting && SawBlade.SawBladeActive)
            {
                if (cuttingOutDado)
                {
                    if (SawBlade.NoInteractionWithBoard && !PieceWithinBlade())
                    {
                        CurrentState = CutState.EndOfCut;
                    }
                    else
                    {
                        if (totalTimePassed >= timeUpdateFrequency)
                        {
                            totalTimePassed = 0.0f;
                            FeedRateTracker.UpdateScoreWithRate(playerFeedRate);
                        }
                        if (FeedRateTracker.RateTooSlow || FeedRateTracker.RateTooFast)
                        {
                            totalTimeStalling += Time.deltaTime;
                            FeedRateTracker.ReduceScoreDirectly(0.1f);
                            if (totalTimeStalling >= MaxStallTime && FeedRateTracker.RateTooSlow)
                            {
                                manager.StopGameDueToLowScore("You were cutting too slow, now the wood is burnt.");
                            }
                            else if (totalTimeStalling >= 1.0f && FeedRateTracker.RateTooFast)
                            {
                                manager.StopGameDueToLowScore("You were cutting too fast and caused the saw to bind.");
                            }
                        }
                    }
                }
                else
                {
                    if (SawBlade.NoInteractionWithBoard && !PieceWithinBlade())
                    {
                        timeNotCuttingLine = 0.0f;
                        CurrentState       = CutState.ReadyToCut;
                        SawBlade.ResetEdgePosition();
                        currentDado = null;
                        manager.RestrictCurrentBoardMovement(false, false);
                    }
                    else
                    {
                        timeNotCuttingLine += Time.deltaTime;
                        if (totalTimePassed >= timeUpdateFrequency)
                        {
                            totalTimePassed = 0.0f;
                            FeedRateTracker.ReduceScoreDirectly(0.6f);
                        }
                        if (timeNotCuttingLine >= MaxStallTime)
                        {
                            manager.StopGameDueToLowScore("You were not cutting into the marked dado cut, and now the board is ruined.");
                        }
                    }
                }
            }
            else if (CurrentState == CutState.EndOfCut)
            {
                if (!SawBlade.CuttingWoodBoard && SawBlade.NoInteractionWithBoard && !PieceWithinBlade())
                {
                    currentDado.ScaleDown();
                    if (!currentDado.AnyCutsLeft())
                    {
                        manager.DisplayScore(FeedRateTracker);
                        FeedRateTracker.ResetFeedRate();
                    }
                    manager.SplitMaterial(currentDado);
                    cuttingOutDado = false;
                    currentDado    = null;
                    SawBlade.ResetEdgePosition();
                    CurrentState = CutState.ReadyToCut;
                    manager.RestrictCurrentBoardMovement(false, false);
                }
            }
            #endregion
            previousPiecePosition = currentPiecePosition;
            if (FeedRateTracker.GetLineScore() <= 0.0f)
            {
                manager.StopGameDueToLowScore("This cut is too messed up to keep going.");
            }
            if (totalTimePassed >= timeUpdateFrequency)
            {
                totalTimePassed = 0.0f;
            }
        }
    }
コード例 #3
0
    void Update()
    {
        #region CuttingCode
        if (manager.StillCutting)
        {
            currentBladePosition = SawBlade.EdgePosition();
            totalTimePassed     += Time.deltaTime;
            UpdateFeedRateDate();

            if (CurrentState == CutState.ReadyToCut)
            {
                SwitchLine();

                if (SawBlade.CuttingWoodBoard && SawBlade.SawBladeActive)
                {
                    Vector3    origin = SawBlade.EdgePosition() + new Vector3(0.0f, 0.5f, 0.0f);
                    Ray        ray    = new Ray(origin, Vector3.down);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit, Mathf.Infinity, mask) && (hit.collider.tag == "Piece" || hit.collider.tag == "Leftover"))
                    {
                        Vector3 bladeEdgePosition = new Vector3(currentLine.GetCurrentCheckpointPosition().x, hit.point.y, hit.point.z);
                        StartWoodCutting(bladeEdgePosition);
                    }
                }
            }
            else if (CurrentState == CutState.Cutting && SawBlade.SawBladeActive)
            {
                if (cuttingAlongLine)
                {
                    currentLine.UpdateLine(SawBlade.EdgePosition());
                    if (currentLine.LineIsCut())
                    {
                        CurrentState = CutState.EndingCut;
                    }
                    else
                    {
                        if (totalTimePassed >= timeUpdateFrequency)
                        {
                            totalTimePassed   = 0.0f;
                            totalTimeStalling = 0.0f;
                            FeedRateTracker.UpdateScoreWithRate(playerFeedRate);
                        }
                        if (FeedRateTracker.RateTooSlow || FeedRateTracker.RateTooFast)
                        {
                            totalTimeStalling += Time.deltaTime;
                            FeedRateTracker.ReduceScoreDirectly(0.1f);
                            if (totalTimeStalling >= MaxStallTime && FeedRateTracker.RateTooSlow)
                            {
                                manager.StopGameDueToLowScore("You were cutting too slow, now the wood is burnt.");
                            }
                            else if (totalTimeStalling >= 1.0f && FeedRateTracker.RateTooFast)
                            {
                                manager.StopGameDueToLowScore("You were cutting too fast and caused the saw to bind.");
                            }
                        }
                    }
                }
                else
                {
                    if (SawBlade.NoInteractionWithBoard)
                    {
                        timeNotCuttingLine = 0.0f;
                        CurrentState       = CutState.ReadyToCut;
                        SawBlade.ResetEdgePosition();
                        currentLine = null;
                        manager.RestrictCurrentBoardMovement(false, false);
                    }
                    else
                    {
                        timeNotCuttingLine += Time.deltaTime;
                        if (totalTimePassed >= timeUpdateFrequency)
                        {
                            totalTimePassed = 0.0f;
                            FeedRateTracker.ReduceScoreDirectly(0.8f);
                        }
                        if (timeNotCuttingLine >= MaxStallTime)
                        {
                            manager.StopGameDueToLowScore("You were not cutting along the line, and now the board is ruined.");
                        }
                    }
                }
            }
            else if (CurrentState == CutState.EndingCut)
            {
                if (!SawBlade.CuttingWoodBoard && SawBlade.NoInteractionWithBoard)
                {
                    manager.DisplayScore(FeedRateTracker);
                    manager.SplitMaterial(currentLine);
                    cuttingAlongLine = false;
                    currentLine      = null;
                    SawBlade.ResetEdgePosition();
                    CurrentState = CutState.ReadyToCut;
                    FeedRateTracker.ResetFeedRate();
                }
            }
        }
        previousBladePosition = currentBladePosition;
        if (FeedRateTracker.GetLineScore() <= 0.0f)
        {
            manager.StopGameDueToLowScore("This cut is too messed up to keep going.");
        }
        #endregion
    }