Пример #1
0
        public void DeployShip(int posX, int posY, bool horizontal)
        {
            /*if (isHorizontal)
             * {
             *  if (((posX + size) > map.Width && posX < map.PosX) && (posY > map.Height && posY < map.PosY))
             *  {
             *      return;
             *  }
             * }
             * else if (!isHorizontal)
             * {
             *  if (((posX + size) > map.Width && posX < map.PosX) && (posY > map.Height && posY < map.PosY))
             *  {
             *      return;
             *  }
             * }*/

            // CHECK SURROUNDING TILES BEFORE DEPLOYING!!!

            // Deploy ship.
            for (int i = 0; i < size; i++)
            {
                int nextPosX = (isHorizontal == true ? posX + i : posX);
                int nextPosY = (isHorizontal == true ? posY : posY + i);

                map.OccupyTile(posX, posY);
                Draw();
            }
        }
Пример #2
0
        public void StringToMap(IPEndPoint endPoint, string mapInfo)
        {
            string[] map       = mapInfo.Split(',');
            int      stringPos = 0;

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (map[stringPos] == "1")
                    {
                        if (endPoint == playerOneEP)
                        {
                            playerOneMap.OccupyTile(i, j);
                        }
                        else if (endPoint == playerTwoEP)
                        {
                            playerTwoMap.OccupyTile(i, j);
                        }
                    }
                    stringPos++;
                }
            }
        }