Beispiel #1
0
        private static CompleteStructure CreateStructure(byte playerId)
        {
            CompleteStructure structure = CompleteStructure.Create(BuildingController.ExampleStructure, playerId);

            Assert.IsNotNull(structure, "The example structure creation must be successful.");
            structure.transform.position = new Vector3(0, 10, 0);
            return(structure);
        }
Beispiel #2
0
        private static CompleteStructure CreateStructure(byte playerId)
        {
            MutableBitBuffer buffer = new MutableBitBuffer();

            buffer.SetContents(PlayerStructures[playerId]);
            CompleteStructure structure = CompleteStructure.Create(buffer, playerId);

            Assert.IsNotNull(structure, "The example structure creation must be successful.");
            structure.transform.position = new Vector3(0, 10, 0);
            return(structure);
        }
Beispiel #3
0
        private void Update()
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Place();
            }
            else if (Input.GetButtonDown("Fire2"))
            {
                Delete();
            }

            Rotate(Input.GetAxisRaw("MouseScroll"));
            if (Input.GetButtonDown("Fire3"))
            {
                Switch();
            }

            // ReSharper disable once UnusedVariable
            if (GetSelectedBlock(out GameObject block, out BlockPosition position, out byte rotation))
            {
                if (!position.Equals(_previousPreviewPosition))
                {
                    ShowPreview(position, rotation);
                }
            }
            else
            {
                Destroy(_previewObject);
                _previousPreviewPosition = null;
            }

            if (Input.GetButtonDown("Ability"))
            {
                new Action(() => {
                    EditableStructure.Errors errors = _structure.GetStructureErrors();
                    if (errors != EditableStructure.Errors.None)
                    {
                        Debug.Log("Structure error: " + errors);
                        return;
                    }

                    IDictionary <BlockPosition, IPlacedBlock> notConnected = _structure.GetNotConnectedBlocks();
                    Assert.IsNotNull(notConnected, "The lack of the presence of the Mainframe was not shown among the errors.");
                    if (notConnected.Count != 0)
                    {
                        Debug.Log("Structure error: not connected blocks");
                        return;
                    }

                    BitBuffer someBuffer = new MutableBitBuffer((RealPlacedBlock.SerializedBitsSize
                                                                 * _structure.RealBlockCount + 7) / 8);
                    _structure.Serialize(someBuffer);
                    Debug.Log("Structure: " + string.Join(", ", someBuffer.Array));
                    CompleteStructure complete = CompleteStructure.Create(someBuffer, 1);
                    Assert.IsNotNull(complete, "Own CompleteStructure creation mustn't fail.");

                    complete.transform.position = new Vector3(0, 10, 0);
                    complete.gameObject.AddComponent <LocalBotController>();
                    _camera.gameObject.AddComponent <PlayingCameraController>().Initialize(complete);

                    Destroy(_camera.gameObject.GetComponent <BuildingCameraController>());
                    Destroy(gameObject);

                    CompleteStructure otherStructure = CompleteStructure.Create(ExampleStructure, 2);
                    Assert.IsNotNull(otherStructure, "Other CompleteStructure creation mustn't fail.");
                    otherStructure.transform.position = new Vector3(150, 5, 150);
                }).Invoke();
            }
        }