예제 #1
0
        private void BlockAdd(int blockNum)
        {
            if (IsBlockExists(blockNum) != null)
            {
                // Do nothing
                return;
            }

            ICubelet newCube = new ICubelet(SelectedBlockAdd);
            newCube.PosX = blockNum % gameBoard.NumBlocks;
            newCube.PosY = blockNum / gameBoard.NumBlocks;

            drawables.Add(newCube);
            gridArray[blockNum] = newCube;
        }
예제 #2
0
        private void LoadSceneFromBuffer(Stream buff)
        {
            BinaryReader read = new BinaryReader(buff);

            // Clear the current models.
            if (MessageBox.Show("Warning: Loading a new scene will delete all changes made to the current scene. Are you sure?", "Are you Sure?", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                buff.Close();
                return;
            }

            drawables.Clear();
            drawables.Add(gameBoard);
            InitializeGridArray();

            while (read.PeekChar() > 0)
            {
                string type = read.ReadString();
                ICubelet cube = new ICubelet(type);

                read.ReadByte();

                cube.PosX = read.ReadInt32();
                read.ReadByte();

                cube.PosY = read.ReadInt32();

                read.ReadByte();

                cube.Orientation = read.ReadInt32();

                read.ReadByte();

                // Add to drawables
                drawables.Add(cube);
                // Add to array
                gridArray[cube.PosX + gameBoard.NumBlocks * cube.PosY] = cube;
            }

            buff.Close();
        }
예제 #3
0
        private void OnBlockSelected(int blockNum)
        {
            switch (SelectedCommand)
            {
                case ToolPanelCommand.CameraDrag:
                    // Do nothing
                    break;
                case ToolPanelCommand.BlockDelete:
                    DeleteBlock(blockNum);
                    break;
                case ToolPanelCommand.BlockDrag:
                    if (IsBlockExists(blockNum) != null)
                    {
                        // First, tell everything that the user clicked here.
                        FirstDragCoordinate = blockNum;
                        // Look it
                        LockedFirstDrag = IsBlockExists(blockNum);

                        if (SelectedDragMode == DragMode.Move)
                        {
                            CurrentDragMode = DragMode.Move;
                        }
                        else if (SelectedDragMode == DragMode.Rotate)
                        {
                            CurrentDragMode = DragMode.Rotate;
                        }
                    }
                    break;
                case ToolPanelCommand.BlockAdd:
                    BlockAdd(blockNum);
                    break;
                default:
                    break; // Do nothing
            }
        }