Beispiel #1
0
    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 Load()
    {
        if (SelectedBoard == null)
        {
            return;
        }

        SavedObjectV2 save        = (SavedObjectV2)FileUtilities.LoadFromFile(SelectedBoard.FilePath);
        GameObject    LoadedBoard = SavedObjectUtilities.LoadSavedObject(save);

        HideAll();

        LoadedBoard.transform.position = new Vector3(0, -2000, 0);
        BoardFunctions.RecalculateClustersOfBoard(LoadedBoard);

        BoardPlacer.NewBoardBeingPlaced(LoadedBoard);
        GameplayUIManager.UIState = UIState.BoardBeingPlaced;
    }
Beispiel #3
0
        public override void Do()
        {
            NetObject         parentBoard = NetObject.GetByNetId(Packet.ParentBoardID);
            SavedCircuitBoard savedBoard;

            using (var mem = new MemoryStream(Packet.SavedBoard))
            {
                savedBoard = (SavedCircuitBoard)BinFormatter.Deserialize(mem);
            }

            var boardObj = SavedObjectUtilities.LoadSavedObject(savedBoard, parentBoard?.transform);

            boardObj.transform.position    = Packet.Position;
            boardObj.transform.eulerAngles = Packet.EulerAngles;

            foreach (var item in boardObj.GetComponentsInChildren <CircuitOutput>())
            {
                item.On = item.On; //It works 100% of the times most of the time
            }

            BoardFunctions.RecalculateClustersOfBoard(boardObj);
            SnappingPeg.TryToSnapIn(boardObj);
        }