Example #1
0
        public void RenderAll(List<GameObject> objects, List<GameObject> tableInfo, GameObject[,] staticsFallenItems, List<GameObject> movable)
        {
            int counter = 0;
            //Console.SetCursorPosition(0, 0);
            Console.SetCursorPosition(this.MiddleOfTheWindow - this.GridMatrixMiddleCol, 0);

            RenderInfoTable(tableInfo);

            //Adjust top border position
            Console.SetCursorPosition(this.MiddleOfTheWindow - this.GridMatrixMiddleCol, 5);
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine(new string('═', this.GridMatrix.GetLength(1)));

            for (int row = 6; row < this.visibleRows; row++)
            {
                //Adjust left border position
                Console.SetCursorPosition(this.MiddleOfTheWindow - this.GridMatrixMiddleCol - 1, row);
                CreateBordersLeftAndRight(row, Renderer.leftBorder, ConsoleColor.DarkCyan);
                Console.WriteLine();

                for (int col = 0; col < this.visibleCols; col++)
                {
                    ConsoleColor currentColor = ConsoleColor.White;
                    
                    if (this.GridMatrix[row, col] != ' ')
                    {
                        //Set the falling items colors
                        if (counter > 2)
                        {
                            counter = 0;
                        }
                        currentColor = movable[counter].ObjectColor;
                        counter++;

                        //Set the fallen items colors
                        if (staticsFallenItems[row,col] != null)
                        {
                            currentColor = staticsFallenItems[row, col].ObjectColor;
                        }
                        
                    }
                    
                    //Adjust game items - blocks position
                    Console.SetCursorPosition(this.MiddleOfTheWindow - this.GridMatrixMiddleCol + col, row);
                    Console.ForegroundColor = currentColor;
                    Console.Write(this.GridMatrix[row, col]);
                    
                }
               
                CreateBordersLeftAndRight(row, Renderer.rightBorder, ConsoleColor.DarkCyan);
                Console.WriteLine();
                
            }

            //Adjust down border position
            Console.SetCursorPosition(this.MiddleOfTheWindow - this.GridMatrixMiddleCol, this.GridMatrix.GetLength(0));
            Console.WriteLine(new string('═', this.GridMatrix.GetLength(1)));
        }
Example #2
0
        public void AddObject(GameObject obj)
        {
            if (obj is MovableObject)
            {
                this.AddMovableObject(obj);
            }
            else if (obj is StaticObject && !(obj is Text) && !(obj is InfoWall))
            {   
                fallenObjectsContainerMatrix[obj.TopLeft.Row, obj.TopLeft.Col] = obj;
            }
            else
	        {
                AddInfoObjects(obj);
	        }
            allObjects.Add(obj);
        }
Example #3
0
        public void EnqueueItem(GameObject obj)
        {
            char[,] image = obj.GetImage();
            Coordinates topLeft = obj.GetTopLeftCorner();

            int sizeInRows = image.GetLength(0); //End row 
            int sizeInCols = image.GetLength(1); //End col

            int startRow = topLeft.Row;
            int startCol = topLeft.Col;

            for (int row = startRow; row < startRow + sizeInRows; row++)
            {
                for (int col = startCol; col < startCol + sizeInCols; col++)
                {
                    GridMatrix[row, col] = image[(row - startRow), (col - startCol)];
                }
            }
        }
Example #4
0
 private void AddMovableObject(GameObject obj)
 {
     movableObjects.Add(obj);
 }        
Example #5
0
 /// Add objects in the object lists
 private void AddInfoObjects(GameObject obj)
 {
     infoObjects.Add(obj);
 }
Example #6
0
 public static bool HasGameEnded(GameObject obj, Renderer renderer)
 {
     return obj.TopLeft.Row == 5 &&
         renderer.GridMatrix[obj.TopLeft.Row + obj.GetImage().GetLength(1), obj.TopLeft.Col] != ' ';
 }