예제 #1
0
        // Õîä èãðîêà: âíîñèì èçìåíåíèÿ â ìàññèâû computer.ships è human.hits
        public void Turn(Player enemy, int character, int digit)
        {
            hits[character, digit] = 1;

            if (enemy.ships[character, digit] == 2)
            {
                enemy.ships[character, digit] = 3;
            }
        }
예제 #2
0
 public void SetPlayers(Player human, Player computer)
 {
     this.human = human;
     this.computer = computer;
 }
예제 #3
0
        // Õîä êîìïüþòåðà: âíîñèì èçìåíåíèÿ â ìàññèâû human.ships è computer.hits
        public void Turn(Player enemy)
        {
            bool flag = false;

            while (!flag)
            {
                int character = random.Next(Settings.CELL_SIZE);//rand() % Settings.CELL_SIZE; // Êîîðäèíàòû ïî êîòîðûì áóäåò ñòðåëÿòü êîìïüþòåð
                int digit = random.Next(Settings.CELL_SIZE);//rand() % Settings.CELL_SIZE;     // âûáèðàþòñÿ ñëó÷àéíî

                if (hits[character, digit] != 1) // ïðîâåðêà: âûáèðàë ëè óæå êîìïüþòåð ýòè êîîðäèíàòû
                {
                    hits[character, digit] = 1;

                    flag = true;

                    if (enemy.ships[character, digit] == 2)
                    {
                        enemy.ships[character, digit] = 3;
                    }
                }
            }
        }