@hana01

Почему одинаковый код не работает?

Есть две части кода, почти совершенно одинаковые: отличаются разве что названия кнопок и расположение камеры, структура и алгоритмы одни и те же, но при этом одна часть работает, другая - нет. В чём может быть дело?
Одна часть:
Одна часть
case 1:
            cam = GetComponent<Camera>();
           cam.orthographicSize = 8;
            this.transform.position = new Vector3(0,25,-10);
            LocationButton = new Rect(new Vector2(ScreenCenter_X-200,0), new Vector2(250,190));
           GUI.Box(LocationButton,"");
           LocationButton = new Rect(new Vector2(ScreenCenter_X-85, 10), new Vector2(200,30));
           GUI.Label(LocationButton,"Док");
           LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 50), new Vector2(200,30));
            if(GUI.Button(LocationButton,"Вернуться в меню")){
               PlayerPoleControl.Clear();
               GameMode=0;
           }
           LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 90), new Vector2(200,30));
            if(GUI.Button(LocationButton,"Разместить флот")){
               PlayerPoleControl.randomShips();
           }
           if(PlayerPoleControl.LifeShip()==20){
               LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 130), new Vector2(200,30));
               if(GUI.Button(LocationButton,"В бой")) {
                   if(WhoPlayMode==1){
                       GameMode=2;
                   Player.GetComponent<GameField>().CopyMap();
                   Computer.GetComponent<GameField>().randomShips();
                   } 
               }
           }
            break;


Другая часть:
Другая часть
cam = GetComponent<Camera>();
            cam.orthographicSize = 8;
            this.transform.position = new Vector3(48,27,-10);
            LocationButton = new Rect(new Vector2(ScreenCenter_X-200,0), new Vector2(250,190));
           GUI.Box(LocationButton,"");
           LocationButton = new Rect(new Vector2(ScreenCenter_X-120, 10), new Vector2(200,30));
           GUI.Label(LocationButton,"Первый игрок");
           LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 50), new Vector2(200,30));
            if(GUI.Button(LocationButton,"Вернуться в меню")){
               PlayerPoleControl.Clear();
               GameMode=0;
           }
           LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 90), new Vector2(200,30));
            if(GUI.Button(LocationButton,"Разместить флот1 ")){
               PlayerPoleControl.randomShips();
           }
           if(PlayerPoleControl.LifeShip()==20){
               LocationButton = new Rect(new Vector2(ScreenCenter_X-170, 130), new Vector2(200,30));
               if(GUI.Button(LocationButton,"В бой!")) {
                   Player.GetComponent<GameField>().CopyMap();
               }
           }
            break;


Вот что происходит в первом случае:
до нажатия кнопки размещения кораблей: (линия рядом с полем - показатель количества поставленных палуб, должно быть 20 шт. : красные - палубы нет( уничтожена), зелёная - палуба живая)
Фото
60980084322d7241877442.png


после нажатия:
Фото
60980090bb6bd296664668.png


Вот что происходит во втором случае:
до кнопки размещения кораблей:
Фото
609800a2cdada535367737.png


после:

Фото
609800afbee84682052654.png
  • Вопрос задан
  • 125 просмотров
Пригласить эксперта
Ответы на вопрос 1
MANAB
@MANAB
Разрабатываю на C#: Web, Desktop, Gamedev
Во втором случае нету вызова Computer.GetComponent().randomShips();
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы