public void SplitMaterial(DadoBlock dadoToRemove) { if (!dadoToRemove.AnyCutsLeft()) { WoodMaterialObject board = AvailableWoodMaterial[currentPieceIndex].GetComponent <WoodMaterialObject>(); DadosToCut.Remove(dadoToRemove); board.RemoveDado(dadoToRemove); Destroy(dadoToRemove.gameObject); if (board.DadosToCut.Count <= 0) { AvailableWoodMaterial.RemoveAt(currentPieceIndex); Destroy(board.gameObject); if (AvailableWoodMaterial.Count > 0) { currentPieceIndex = 0; AvailableWoodMaterial[currentPieceIndex].SetActive(true); currentBoardController = AvailableWoodMaterial[currentPieceIndex].GetComponent <BoardController>(); UI_Manager.UpdateSelectionButtons(currentPieceIndex, AvailableWoodMaterial.Count); SetupForCutting(); PlacePiece(); } } } SawBlade.TurnOff(); UI_Manager.ChangeSawButtons(false); if (DadosToCut.Count > 0) { UI_Manager.UpdateSelectionButtons(currentPieceIndex, AvailableWoodMaterial.Count); } else { UI_Manager.InfoPanel.SetActive(true); UI_Manager.InfoText.text = "All of the lines are cut. \nOn to the next step."; UI_Manager.HideButton.gameObject.SetActive(false); UI_Manager.StartOverButton.gameObject.SetActive(false); UI_Manager.NextSceneButton.gameObject.SetActive(true); StillCutting = false; float percentage = cumulativeLineScore / numberOfCuts; if (GameManager.instance != null) { GameManager.instance.ApplyScore(percentage); } else { Debug.Log("No Game manager"); } } }
public void RemoveDado(DadoBlock blockToRemove) { DadosToCut.Remove(blockToRemove); }
public void AddDado(DadoBlock blockToAdd) { DadosToCut.Add(blockToAdd); }
public bool ContainsDado(DadoBlock block) { return(DadosToCut.Contains(block)); }
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; } } }
private void SwitchDado() { DadoBlock nearestDado = manager.GetNearestDadoBlock(SawBlade.transform.position); currentDado = nearestDado; }