Example #1
0
        public Coordinate[,] getUpperScreenFromOpponent(LowerScreen screen)
        {
            UpperScreen tempScreen = new UpperScreen(debugMode);

            for (int j = 0; j < tempScreen.screen.GetLength(1); j++)
            {
                for (int i = 0; i < tempScreen.screen.GetLength(0); i++)
                {
                    tempScreen.screen[i, j] = screen.screen[i, j];
                }
            }
            return(tempScreen.screen);
        }
Example #2
0
        void getCounts(LowerScreen ls)
        {
            List <Coordinate> listOfCoordinatesFromSunkShips = new List <Coordinate>();

            listofOpponentsSunkShips.ForEach(delegate(Ship ship)
            {
                foreach (KeyValuePair <Coordinate, bool> coord in ship.isHitDictionary)
                {
                    listOfCoordinatesFromSunkShips.Add(coord.Key);
                }
            });

            for (int j = 0; j < 10; j++)
            {
                for (int i = 0; i < 10; i++)
                {
                    heatmap[i, j].count = 0;
                }
            }
            foreach (Ship ship in ls.Ships)
            {
                if (shipIsAlive(ship))
                {
                    for (int j = 0; j < 10; j++)
                    {
                        for (int i = 0; i < 10; i++)
                        {
                            countShipFitHorizontal(ship, i, j, listOfCoordinatesFromSunkShips);
                            countShipFitVertical(ship, i, j, listOfCoordinatesFromSunkShips);
                        }
                    }
                }
            }
            for (int j = 0; j < 10; j++)
            {
                for (int i = 0; i < 10; i++)
                {
                    if (hitOrMissScreen[i, j] == "H")
                    {
                        heatmap[i, j].count = 0;
                    }
                    if (hitOrMissScreen[i, j] == "M")
                    {
                        heatmap[i, j].count = 0;
                    }
                }
            }
        }
Example #3
0
 public void updateHeatMap(LowerScreen ls)
 {
     getCounts(ls);
     printCounts();
 }
Example #4
0
 public Board(bool dm)
 {
     upperScreen = new UpperScreen(dm);
     lowerScreen = new LowerScreen(dm);
 }