示例#1
0
        public void GO()
        {
            //myService1 = GetMyService();
            //myService1 = new MyService();
            //Log.Print("myService1 created. Proxy? {0}", (RemotingServices.IsTransparentProxy(myService1) ? "YES" : "NO"));


            int          n            = Utility.ReadInt("Enter battleground size:");
            Battleground battleGround = new Battleground(n);

            battleGround.Print();

            #region Init available ships
            int totalCount     = 0;
            var availableShips = new Dictionary <int, int>();
            for (int length = 1; length <= 4; length++)
            {
                int count = 5 - length;
                availableShips[length] = count;
                totalCount            += count;
            }
            #endregion


            while (totalCount > 0)
            {
                int length = Utility.ReadIntInRange(1, 4, "Enter ship length:");
                if (availableShips.ContainsKey(length) && availableShips[length] > 0)
                {
                    ShipOrientation orientation = (ShipOrientation)Utility.ReadIntInRange(1, 2, "Enter ship orientation:");
                    Ship            ship        = new Ship(length, orientation);
                    //battleGround.AddShip(ship);


                    Console.Clear();

                    battleGround.Draw();
                    Console.CursorVisible = false;
                    Move(battleGround, ship);
                    Console.CursorVisible = !false;
                    Console.SetCursorPosition(0, n);
                    totalCount--;
                }
            }

            //var turn = new Turn();
            //turn.x = 0;
            //YouTurn(turn);

            //myService1.YouTurn(turn);
        }