public void Place() { if (!CurrentPlacementIsValid) { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return; } StuffPlacer.RemoveOutlineFromObject(BoardBeingStacked); StuffPlacer.SetStateOfAllBoxCollidersIn(BoardBeingStacked, true); FloatingPointRounder.RoundIn(BoardBeingStacked, true); SnappingPeg.TryToSnapIn(BoardBeingStacked); MegaMeshManager.AddComponentsIn(StackedBoard); foreach (VisualUpdaterWithMeshCombining visualboi in StackedBoard.GetComponentsInChildren <VisualUpdaterWithMeshCombining>()) { visualboi.AllowedToCombineOnStable = true; } SoundPlayer.PlaySoundAt(Sounds.PlaceOnBoard, BoardBeingStacked); BoardBeingStacked = null; BoardBeingStackedCircuitBoard = null; AllSubBoardsInvolvedWithStacking = new List <GameObject>(); Done(); }
private void IterationsChanged() { if (Iterations >= AllSubBoardsInvolvedWithStacking.Count) { int NumberOfNewBoards = Iterations + 1 - AllSubBoardsInvolvedWithStacking.Count; for (int i = 0; i < NumberOfNewBoards; i++) { GameObject NewBoard = Instantiate(BoardBeingStackedCopy); NewBoard.transform.position = new Vector3(1000, -1000, 1000); // so RecalculateCluster can work unhindered NewBoard.transform.parent = AllSubBoardsInvolvedWithStacking[AllSubBoardsInvolvedWithStacking.Count - 1].transform; StuffPlacer.SetStateOfAllBoxCollidersIn(NewBoard, false); AllSubBoardsInvolvedWithStacking.Add(NewBoard); BoardFunctions.RecalculateClustersOfBoard(NewBoard); MegaMeshManager.RemoveComponentsImmediatelyIn(NewBoard); MegaMeshManager.AddComponentsIn(NewBoard); } } else if (Iterations < AllSubBoardsInvolvedWithStacking.Count) { //int NumberOfExtraBoards = AllSubBoardsInvolvedWithStacking.Count + 1 - Iterations; for (int i = AllSubBoardsInvolvedWithStacking.Count - 1; i > Iterations; i--) { GameObject oldboard = AllSubBoardsInvolvedWithStacking[i]; AllSubBoardsInvolvedWithStacking.Remove(oldboard); oldboard.transform.parent = null; // because the board is not destroyed immediately, this is done to prevent the old board from being used in the interesction test of UpdateHighlight Destroy(oldboard); } } SetAllBoardPositions(); }
public void Done() { StuffPlacer.RemoveOutlineFromObject(BoardBeingStacked); StuffPlacer.SetStateOfAllBoxCollidersIn(BoardBeingStacked, true); if (StackedBoard != null) { SoundPlayer.PlaySoundAt(Sounds.DeleteSomething, StackedBoard); Destroy(StackedBoard); } BoardBeingStacked = null; Destroy(BoardBeingStackedCopy); AllSubBoardsInvolvedWithStacking = new List <GameObject>(); Canvas.enabled = false; GameplayUIManager.UIState = UIState.None; }