示例#1
0
        public LinePiece(Vector3 size, Vector3 position)
        {
            Vector3 pos;
            pos = new Vector3((float)(position.X - 3.6f * size.X), position.Y + 0.0f, position.Z + 0.0f);
            cube1 = new Cube(size, pos);

            pos = new Vector3((float)(position.X - 1.2f * size.X), position.Y + 0.0f, position.Z + 0.0f);
            cube2 = new Cube(size, pos);

            pos = new Vector3((float)(position.X + 1.2f * size.X), position.Y + 0.0f, position.Z + 0.0f);
            cube3 = new Cube(size, pos);

            pos = new Vector3((float)(position.X + 3.6f * size.X), position.Y + 0.0f, position.Z + 0.0f);
            cube4 = new Cube(size, pos);

            cube1.setName("CubeLine1");
            cube2.setName("CubeLine2");
            cube3.setName("CubeLine3");
            cube4.setName("CubeLine4");

            this.Add(cube1);
            this.Add(cube2);
            this.Add(cube3);
            this.Add(cube4);

            Size = size;
            Position = position;
            isConstructed = true;
        }
示例#2
0
        public void print()
        {
            TetrisGame.rootObject = new DummyObject();
            TetrisGame.rootObject.setVisible(false);
            Grid3D grid3D = new Grid3D();
            TetrisGame.rootObject.Add(grid3D);
            List<int[]> nextBlockPos = nextBlock.computeActualPos();
            Color cellColornextBlock = this.nextBlock.getColor();
            Vector3 center= new Vector3(0 * (1f + offset), 0, -2 * (1f + offset));
            for (int i = 0; i < nextBlockPos.Count; i++)
            {
                Vector3 pos = center + new Vector3(nextBlockPos[i][0] * (1f + offset), 0, nextBlockPos[i][1] * (1f + offset));
                Cube cube = new Cube(Vector3.One, pos);
                cube.setColor(cellColornextBlock);
                cube.Name = currentBlock.name;
                TetrisGame.rootObject.Add(cube);
            }

              // Console.WriteLine("");
              //  Console.WriteLine("");
            List<int[]> currentBlockPos = currentBlock.computeActualPos();
            for (int y = 0; y < 20; y++)
            {
              //  Console.Write("|");
                string line = "|";
                for (int x = 0; x < 10; x++)
                {
                    TetrisCell currentCell = this.grid.getCell(x, y);
                    string temp="$";
                    bool activeOnCell = false;
                    bool addBlock = false;
                    Color cellColor=Color.Black;

                    for (int i = 0; i < currentBlockPos.Count && activeOnCell==false; i++)
                    {

                        int xCube = currentBlockPos[i][0] ;
                        int yCube = currentBlockPos[i][1];
                        if (xCube == x && yCube == y)
                        {
                            addBlock = true;
                            activeOnCell = true;
                            cellColor = this.currentBlock.getColor();
                        }
                    }
                    if (!activeOnCell)
                    {
                        if (currentCell.isEmpty())
                        {
                            temp = "$";
                        }
                        else
                        {
                            addBlock = true;
                            cellColor = currentCell.getColor();
                        }
                    }

                    temp = GameLogic.getConsoleColor(cellColor);
                    line = line + temp + "|";
                    if (addBlock)
                    {
                    //    Console.Write(temp);
                     //   Console.Write("|");
                        Vector3 pos = new Vector3(x * (1f+offset), 0, y * (1f+offset));
                        Cube cube = new Cube(Vector3.One, pos);
                        cube.setColor(cellColor);
                        if (activeOnCell)
                        {
                            cube.Name = currentBlock.name;
                        }
                        TetrisGame.rootObject.Add(cube);
                    }
                    else
                    {
                    //    Console.Write("#");
                     //   Console.Write("|");
                    }
                }
              //  Console.WriteLine(line);
            //    Console.Write("\n");
            }
             //   Console.WriteLine("");
            //    Console.WriteLine("");
        }