Ejemplo n.º 1
0
        private void InitializeBoard()
        {
            int xSize = WorldConstants.GAME_DISPLAY_SIZE.X / WorldConstants.BLOCK_SIZE.X;
            int ySize = WorldConstants.GAME_DISPLAY_SIZE.Y / WorldConstants.BLOCK_SIZE.Y;

            Matrix = new Block[xSize, ySize];

            int auxX = WorldConstants.INITIAL_LOCATION.X;
            int auxY = WorldConstants.INITIAL_LOCATION.Y;

            for (int i = 0; i < xSize; i++)
            {
                for (int j = 0; j < ySize; j++)
                {
                    Matrix[i, j] = new EmptyBlock(WorldConstants.BLOCK_SIZE, new Point(auxX, auxY));
                    auxY        += 1;
                }
                auxX += 1;
                auxY  = WorldConstants.INITIAL_LOCATION.Y;
            }
        }
Ejemplo n.º 2
0
        //public int[] GetPositionOnMatrix(Block block)
        //{

        //    int[] fakePos = new int[] { -1, -1 };
        //    for (int i = 0; i < Matrix.GetLength(0); i++)
        //    {
        //        for (int j = 0; j < Matrix.GetLength(1); j++)
        //        {

        //            try
        //            {
        //                return MatrixFinderActions[Matrix[i, j].Equals(block)].Invoke(i, j);
        //            }
        //            catch (KeyNotFoundException e)
        //            {

        //            }
        //        }
        //    }
        //    //throw new NullReferenceException("There is no block like block " + block + " in the matrix");
        //    return fakePos;
        //}

        public void DestroyBlock(Block block)
        {
            Console.WriteLine(block + " destroyed!");
            int[] blockPos = new int[] { block.Location.X, block.Location.Y };
            Matrix[blockPos[0], blockPos[1]] = new EmptyBlock(block);
        }